AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

NumberPad switching between applications

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
NT
Guest





PostPosted: Sun Jul 31, 2005 9:52 am    Post subject: NumberPad switching between applications Reply with quote

Hello!

I'm trying to get the number pad to change its function depending on the program used. I've seen a couple of posts that suggest how to do it for a single key*, but the ones I saw didn't support held keys (that use the "up" state as well). Here's what I've got so far:

Code:
IfWinActive, ahk_class SmartSketchMDIFrame
   Gosub, FlashShortcuts

IfWinActive, ahk_class Notepad
   Gosub, NotePadShortcuts

$*Numpad1::Send,{%currentNumPadValue1% down}
$*Numpad1 up::Send,{%currentNumPadValue% up}
 
$*Numpad2::Send,{%currentNumPadValue2% down}
$*Numpad2 up::Send,{%currentNumPadValue2% up}

$*Numpad3::Send,{%currentNumPadValue3% down}
$*Numpad3 up::Send,{%currentNumPadValue3% up}

return

FlashShortcuts:

currentNumPadValue1 = x
currentNumPadValue2 = c
currentNumPadValue3 = v
return

NotePadShortcuts:

currentNumPadValue1 = a
currentNumPadValue2 = b
currentNumPadValue3 = c
return

Ideally, I want to be able to add as many applications as I need, but have a convenient place to view and change the mappings. I have to use both the down AND the up state because I'm remapping the lower number pad keys to CTRL, ALT, and Shift. They don't seem to function properly without both. For example, I want to program Numpad3 to be V, and hold the 0 key for CTRL.

The values of currentNumPad aren't being passed to the hotkeys. Sad

Any help would be greatly appreciated. Thanks in advance!

---NT


* One of the scripts I saw had the hotkey followed by the individual applications. While that worked for single keys and for 2 or 3 applications, updating that script with 10 or more programs would be a nightmare!

A sample of that code is below.

Code:
$*Numpad1::
IfWinActive, ahk_class SmartSketchMDIFrame ;This is the class name for Flash
   Send, {x}
   
IfWinActive, ahk_class Notepad
   Send, {a}
   
Else
   Send, {1}
return
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Mon Aug 01, 2005 5:20 pm    Post subject: Reply with quote

One way to have context sensitive hotkeys is to use SetTimer. Here is an example that I tested briefly and it seems to work. It will probably need refinement:
Code:
SetTimer, WatchActiveWindow, 100
return

WatchActiveWindow:
IfWinActive, ahk_class SmartSketchMDIFrame  ; Flash
{
   currentNumPadValue1 = x
   currentNumPadValue2 = c
   currentNumPadValue3 = v
}
else ; All other windows, such as Notepad.
{
   currentNumPadValue1 = a
   currentNumPadValue2 = b
   currentNumPadValue3 = c
}
return

*Numpad0::Send {LControl down}
*Numpad0 up::Send {LControl up}

$*Numpad1::Send,{%currentNumPadValue1% down}
$*Numpad1 up::Send,{%currentNumPadValue% up}

$*Numpad2::Send,{%currentNumPadValue2% down}
$*Numpad2 up::Send,{%currentNumPadValue2% up}

$*Numpad3::Send,{%currentNumPadValue3% down}
$*Numpad3 up::Send,{%currentNumPadValue3% up}
Back to top
View user's profile Send private message Send e-mail
NT



Joined: 31 Jul 2005
Posts: 2
Location: Seattle, WA USA

PostPosted: Mon Aug 01, 2005 6:15 pm    Post subject: Thanks! Reply with quote

Thanks, Chris. That seems to have done the trick!

What a great program! Very Happy

---Natt
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group