| View previous topic :: View next topic |
| Author |
Message |
ultrapro Guest
|
Posted: Mon Feb 20, 2006 8:29 pm Post subject: remapping keys several times in script |
|
|
Hi. I am trying to make a script that will rebind keys when the right mouse button is pressed and unbind them when it is pressed again.
To keep it simple just say i want a to change to left arrow.
I have tried the following:
| Code: | toggle := false
RButton::
If toggle
{
a::a
toggle=false
}
Else
{
a::Left
toggle=true
}
return |
The error i get when I run this is
Line text: *a
Error: duplicate label.
I don't understand this. It's as if it's running all the code at once. What am I doing wrong? Thanks. |
|
| Back to top |
|
 |
ultrapro Guest
|
Posted: Mon Feb 20, 2006 9:44 pm Post subject: |
|
|
the full version of what im trying to do would use space and be a press/release toggle
the below doesn't work but it should show what i want to do:
| Code: | ^Space::Space ; Ctrl-Space replaces Space to center on events.
Space::
w::up
a::left
s::down
d::right
return
Space up::
w::w
a::a
s::s
d::d
return |
|
|
| Back to top |
|
 |
polyethene
Joined: 11 Aug 2004 Posts: 5248 Location: UK
|
Posted: Mon Feb 20, 2006 10:00 pm Post subject: |
|
|
Try this: | Code: | RButton::toggle := !toggle ; switches 'toggle' between true/false each time
a::
If toggle ; if toggle is true
Send, a
Else
Send, left ; if you want to use the left direction key, use {Left}
Return |
_________________ GitHub • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
ultrapro Guest
|
Posted: Mon Feb 20, 2006 10:03 pm Post subject: |
|
|
Thanks for you suggestion. I am trying to do it with a::a rather than 'send' because I understand it's better for using with games etc to have a 'hard' link.
What I don't understand is why one script can't seem to redefine a key using :: more than once? |
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1237
|
Posted: Mon Feb 20, 2006 10:14 pm Post subject: |
|
|
| You have to use the "Hotkey, ..." command method if you want to manipulate a hotkey such as turning it on/off and changing it. |
|
| Back to top |
|
 |
ultrapro Guest
|
Posted: Mon Feb 20, 2006 11:12 pm Post subject: |
|
|
Thanks for the suggestion. I tried to use hotkey but couldn't get it working.
Specifically if i have alreay done:
a::Up
how do i then later do
a::a
using hotkey? I am trying to use a::Up etc using remaps rather than using send. |
|
| Back to top |
|
 |
ultrapro Guest
|
Posted: Mon Feb 20, 2006 11:19 pm Post subject: |
|
|
All i'm trying to do is the equivalent of having two scripts:
Script 1:
w::up
a::left
s::down
d::right
script 2:
w::w
a::a
s::s
d::d
I'm trying to put this functionality into one script with a toggle between. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6836 Location: France (near Paris)
|
Posted: Tue Feb 21, 2006 2:35 pm Post subject: |
|
|
I first thought that the Hotkey command couldn't allow to remap keys (from reading its help page).
But reading the Remapping Keys and Buttons page, I see that key remapping actually works as a pair of hotkeys.
So I suggest you read carefully this page and try to implement your hotkeys the way it is shown (and using tips given by other people in this topic). _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
jtbalogh
Joined: 05 Feb 2006 Posts: 35
|
Posted: Sun Mar 26, 2006 5:09 pm Post subject: |
|
|
| Quote: | | I tried to use hotkey but couldn't get it working. |
At beginning of program I use,
Hotkey, w, up
Hotkey, w, off ; deactivate hotkey until needed
Later in program, I could manipulate it like,
Hotkey, w, on ; use new hotkey
Hotkey, w, down ; change it to another key
Hotkey, w, mylabel ; change it to a label to jump to |
|
| Back to top |
|
 |
|