|
So I have a laptop which doesn't have a number pad, which makes item usage a little bit hard.
I downloaded the autohotkey program that let you write some simple script, what I'm interested in is re-mapping the numPad keys over to normal letter keys.
Now I want to able to toggle the mapping on/off during game, so when I talk I don't talk numbers.
Here's the attempt:
toggleOn = 0 9:: if toggleOn = 1 { d::Numpad8 g::Numpad5 v::Numpad2 o::Numpad1 toggleOn = 0 } if toggleOn = 0 { toggleOn = 1 }
The idea is we map the key "9" into the following expression that does the work. But it doesn't work. Instead I find my keys always mapped T+T
Any help would be great : )
|
It's because your second conditional is always true. You're setting toggleOn to 0 and then checking if it's 0, and since it is, it's set to 1.
toggleOn = 0 P:: if toggleOn = 1 { d::Numpad8 g::Numpad5 v::Numpad2 o::Numpad1 toggleOn = 0 } else { toggleOn = 1 }
I'm not sure this does what you want anyway. I think you need to clear the bindings when you toggle it off...
|
Ohh, nice catch. Let me try it your way.
I can maybe store the binding in the other numPads, then swap it back in the else, lolol... gimme some time
Apparently the binding is permanent, when I tried to do d::a d::b
it says "duplicate hotkey", which probably means you can only assign it once...
Oh well, thx for the catch anyways, I write a lot of if (pred) return blahblah
statements, and never occured the ifs can run over each other ha! thanks a lot!
|
toggleOn = 0 9:: if toggleOn = 0 { d::Numpad8 g::Numpad5 v::Numpad2 o::Numpad1 toggleOn = 1 } else { Hotkey, *d, off Hotkey, *g, off Hotkey, *v, off Hotkey, *o, off toggleOn = 0 }
I think that does what you want.
|
Hmm I tried yours, it says "Hotkey nonexistent, specifically "d" " hmmm
Actually, if I just copy/paste your code, "9" does nothing and the binding remains if I flip the initialization of toggleOn to 0 instead of 1, it gives the above error message
wierd!
|
Yeah, I forgot you need asterisks. I tested it and it's really screwy and doesn't work at all haha.
|
Haha, it's still screwey even if we put the *
|
I think we first assigned Numpad8 to d
then we killed it's de-referenced value with "off"
so d never came back, so I can't type d anymore haha
Also I think it's bad to do 9::
as it binds 9 to something weird, in my case 9 got binded to 8
|
Oh, well I just made this really easy.
d::Numpad8 g::Numpad5 v::Numpad2 o::Numpad1 9::Suspend
|
using this at the moment, 9 doesn't toggle at all :/
toggleOn = 0
if (GetKeyState("9")) { if toggleOn = 0 { d::Numpad8 g::Numpad5 v::Numpad2 o::Numpad1 toggleOn = 1 } else { Hotkey, *d, off Hotkey, *g, off Hotkey, *v, off Hotkey, *o, off toggleOn = 0 } }
|
On July 10 2010 18:04 ShadowDrgn wrote:Oh, well I just made this really easy. d::Numpad8 g::Numpad5 v::Numpad2 o::Numpad1 9::Suspend
Yay thx! syscall ftw
lololol
|
I already had AHK help open from when I was working on a script earlier. Good timing.
|
|
This is a classic. You need to check if the button is being held, or if it has been released. I'm going to mash up something in pseduo-code because I don't know AHK.
I don't know if this is clear so what it's supposed to do is: When you press the button, it should set the released flag to false. Now, when you release the button again, both has_been_released, and keystate(*button*) should be false, and thus change the state of our "lightswitch" / whatever.
Oh, and you could've posted it here for more replies, I think. http://www.teamliquid.net/forum/viewmessage.php?topic_id=134491
Edit: Oh, and I forgot to add, but you obviously need a if(state == 1) { do whatever with hotkeys here }.
var has_been_released = true var state = 0
for(ever) //insert infinite loop here { if (keystate(*button*) == true) { has_been_released = false } if (keystate(*button*) == false && has_been_released == false) { has_been_released = true if (state == 1) { state = 0 } if (state == 0) { state = 1 } } }
|
|
I'm sure there are existing solutions, but it can be fun coding :p
|
|
|
|