AutoHotkey Community

It is currently May 27th, 2012, 6:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: July 27th, 2011, 9:15 am 
Hi,

I've read the documentation HotKey command and searched forums many times, but I just don't get it.
What I want to achieve is to be able to toggle some of the key binds using left alt.
Here is my code:
Code:
j::Left
l::Right

LAlt::
   HotKey, j, Toggle
   HotKey, l, Toggle
return


But with this I get nonexistent hotkey error.
Would appreciate some advice, thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2011, 12:40 pm 
Offline

Joined: February 6th, 2010, 5:17 pm
Posts: 57
To toggle a hotkey with the Hotkey command, the hotkey has to be defined with the Hotkey command:
Code:
Hotkey, j, label_j
Hotkey, l, label_l
return

label_j:
Send, {Left}
return

label_l:
Send, {Right}
return

LAlt::
HotKey, j, Toggle
HotKey, l, Toggle
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2011, 2:10 pm 
Thanks for clarification! But there is a problem - I can't use Send, because i need those keys to work in combination with other keys.

My other approach was this

Code:
mode := 0
LALt::
    if (mode = 0) {
         j::j
         k::k
         ...
    } else {
        j::Left
        k::Down
        ...
    }
    mode := !mode
return


but I kept on getting 'duplicate hotkey' message.

I also tried making two simple scripts which would overwrite each other's key mappings, but that didn't work that smooth.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2011, 2:17 pm 
Use #If
Code:
mode := 0

LALt::
mode:=!mode
Return

#if (mode = 0)
j::j
k::k
#if

#if (mode = 1)
j::Left
k::Down
#if
:?: http://www.autohotkey.net/~Lexikos/Auto ... ds/_If.htm


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2011, 3:03 pm 
This is great! Thanks! :)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, Bing [Bot], JSLover and 61 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