Hotkey dynamic definition %Joykey%::something()

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
CreeAll
Posts: 23
Joined: 01 Oct 2013, 12:18

Hotkey dynamic definition %Joykey%::something()

29 Oct 2013, 22:00

Hi everyone,

I'm trying to define hotkeys on the fly for a game. Th euser have the possibility to edit his Custom button from his Joystick.
But then I need to take this info and initiate the hotkey.

Example :
User define the button A to be 1joy3 (using gui text field) thus this name is stored in the variable KeyA
I need to be able to do something like :
%KeyA%::DoSomething()

How can I do that ? if even possible ?
timeFlies
Posts: 146
Joined: 22 Oct 2013, 20:54
Location: Somewhere in the northern hemisphere.

Re: Hotkey dynamic definition %Joykey%::something()

29 Oct 2013, 22:21

No, you cannot do that. Instead, you need to use the Hotkey command. I don't have time to explain it right now, so I'll just point you to the help file (it's rather hard to find it if you don't know where it is--it doesn't seem to appear in the table of contents and a search brings so much others stuff it's hard to find). Look here.
Verdlin
Posts: 63
Joined: 04 Oct 2013, 08:55
Contact:

Re: Hotkey dynamic definition %Joykey%::something()

30 Oct 2013, 09:47

The general answer for these questions has always been No; but with AutoHotkey_H, then it actually is possible. You can find an exact example of what you are trying to do here
CreeAll
Posts: 23
Joined: 01 Oct 2013, 12:18

Re: Hotkey dynamic definition %Joykey%::something()

30 Oct 2013, 23:33

Thanks guyz,
AHK_H is something I'll need to look into, but not yet, still a bit to high for my level.
I made a workaround with GetKeyState loops for the moment. And focus on the other big issues.

EDit :

I feel dumb everytime this happens to me, but english isn't that easy with all the words with double sens with french ones. Well, I finally understood how to use these "label" out of Gui context.
And it's just as simple as to write:

Code: Select all

Hotkey, %foo%, myLabelName
with the label somewhere:

Code: Select all

myLabelName:
     something to do...
     return
Creeall_Anonymously

Re: Hotkey dynamic definition %Joykey%::something()

05 Nov 2013, 03:15

I still have a hard time understanding how to disable hotkeys defined with Hotkey, XXX, label command.
Contextual hotkey to be precise. Those you create with a Hotkey, IfWinActive, before.
Must be something I don't get with the way I place those command in the code and Not enough, if any example of this case in documentation :(
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Hotkey dynamic definition %Joykey%::something()

08 Nov 2013, 04:04

Sorry for my bad english. Not sure if this is what you need

Code: Select all

Hotkey, ~1,ratonix
Hotkey, ~2,anula
return

ratonix:
            Msgbox Insert shutdown command here after testing		
return

anula:
Hotkey, ~1,nada
return

nada:
Sleep,1
return

esc::
ExitApp
return
Pressing the 2 key you disable the hotkey 1.

Greetings!
Everything is possible!
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Hotkey dynamic definition %Joykey%::something()

08 Nov 2013, 10:21

Code: Select all

MyContextSensitiveHotkey := "Esc"

EnableHotkeys:
   Hotkey, IfWinActive, MyWindow          ; start of context-sensitive hotkeys
   Hotkey, %MyContextSensitiveHotkey%, MyHotkeyLabel, On
   Hotkey, IfWinActive                    ; end of context-sensitive hotkeys
Return

DisableHotkeys:
   Hotkey, IfWinActive, MyWindow          ; start of context-sensitive hotkeys
   Hotkey, %MyContextSensitiveHotkey%, Off
   Hotkey, IfWinActive                    ; end of context-sensitive hotkeys
Return

MyHotkeyLabel:
   MsgBox, You pressed %A_ThisHotkey%!
Return
?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Lpanatt and 323 guests