I use the following script to have the "3" key continuously run a macro as long as I am holding down the key.
$3::
While GetKeyState("3","p"){
Send 3
Sleep 90
}
return
It worked perfectly for what I need. However, now I would like to change the key to one of the keys on my number pad. However, simply inserting Numpad3 into the appropriate places doesn't seem to work. Can anyone please help me.
Thanks
Need help Maping Number Pad Key
Re: Need help Maping Number Pad Key
It seems to work for me. Make sure that Numlock is toggled on.
Code: Select all
$NumPad3::
While GetKeyState("NumPad3","p"){
Send, {NumPad3}
Sleep 90
}
return
Re: Need help Maping Number Pad Key
In my original script, I have: Send 3 and this seems to work. In the script you posted, you have: Send, {NumPad3} and I am wondering if the comma after "send" and the opening and closing braces around "NumPad3" in your script are necessary to make it work properly.kon wrote:It seems to work for me. Make sure that Numlock is toggled on.Code: Select all
$NumPad3:: While GetKeyState("NumPad3","p"){ Send, {NumPad3} Sleep 90 } return
Re: Need help Maping Number Pad Key
Certain keys need to be enclosed in braces to be sent. See Key Names.Meyika wrote:In my original script, I have: Send 3 and this seems to work. In the script you posted, you have: Send, {NumPad3} and I am wondering if the comma after "send" and the opening and closing braces around "NumPad3" in your script are necessary to make it work properly.
Try removing the braces. The literal text "NumPad3" will be sent instead of the key.
The comma is optional, it won't make a difference.
Re: Need help Maping Number Pad Key
Since the numpad keys have essentially two states, one when the numlock key is on and one when it's off, it's important to remember that there are two separate names for each key. If the numlock is on the 5 key is {numpad5} but when the numlock is off the same key is named {numpadclear}. Also some games do not enable the numlock by default so if you really want the 5 key you might want to precede the 5 key with send, {numlock} and after the 5 key is sent do send, {numlock} again to make sure everything goes back to normal.
Re: Need help Maping Number Pad Key
So just do something like this:
Also, you could probably use something like this for the while statement:
A_ThisHotKey holds the name of the key that triggered the thread.
Code: Select all
numpadclear::
numpad5::
While (GetKeyState("numpadclear","p") || GetKeyState("numpad5","p")){
; continuously runs while one of the keys is held
Sleep 90
}
return
Code: Select all
While (GetKeyState(A_ThisHotKey,"p")){
Re: Need help Maping Number Pad Key
Another method of doing this is like so:
I think this method is more CPU efficient as you are doing less checks on the state of the key.
It is also useful in a wider variety of situations - for example to check if this key AND that key are held
Code: Select all
key_down := 0
numpadclear::
numpad5::
key_down := 1
return
numpadclear up::
numpad5 up::
key_down := 0
return
heartbeat()
return
heartbeat(){
global key_down
Loop {
if (key_down){
; this runs continuously while key held
}
sleep 90
}
}
It is also useful in a wider variety of situations - for example to check if this key AND that key are held
Who is online
Users browsing this forum: No registered users and 51 guests