AutoHotkey Community

It is currently May 27th, 2012, 7:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: February 20th, 2006, 9:29 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 10:44 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 11:00 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 11:03 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 11:14 pm 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
You have to use the "Hotkey, ..." command method if you want to manipulate a hotkey such as turning it on/off and changing it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2006, 12:12 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2006, 12:19 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2006, 3:35 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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).

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2006, 6:09 pm 
Offline

Joined: February 5th, 2006, 6:55 am
Posts: 35
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], Leef_me, sjc1000 and 75 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group