How to pass variable to hotkey?

Get help with using AutoHotkey and its commands and hotkeys
fabiolwg
Posts: 9
Joined: 08 May 2016, 03:25

How to pass variable to hotkey?

15 May 2016, 21:13

Hello to with a very big problem not I select a shortcut key at run time to perform some tasks someone can help in a simple example ?

Gui Add, Hotkey, vhotkeydefesa x456 y158 w75 h21
Gui Show,, teste
Return

%hotkeydefesa%::
send, a
sleep 100
return
User avatar
boiler
Posts: 5200
Joined: 21 Dec 2014, 02:44

Re: How to pass variable to hotkey?

15 May 2016, 23:24

Use the Hotkey command to identify the label to go to when a certain hotkey is pressed.

btw, this thread should be under Ask For Help.
fabiolwg
Posts: 9
Joined: 08 May 2016, 03:25

Re: How to pass variable to hotkey?

15 May 2016, 23:44

can not you can send an example based on what I posted ?
fabiolwg
Posts: 9
Joined: 08 May 2016, 03:25

Re: How to pass variable to hotkey?

15 May 2016, 23:45

if quisr post the complete code for you to understand
Coco-guest

Re: How to pass variable to hotkey?

16 May 2016, 00:25

Can you give this a try:

Code: Select all

Gui New
Gui Font, s10, Consolas
Gui Margin, 5, 5
Gui Add, Hotkey, w200 r1 vhotkeydefesa gDefHotkey
Gui Show
return
GuiEscape:
GuiClose:
	ExitApp

DefHotkey(args*)
{
	global hotkeydefesa
	if (hotkeydefesa != "") {
		static prev_hotkey := ""
		if (prev_hotkey != "")
			HotKey %prev_hotkey%, Off
		HotKey %hotkeydefesa%, SendA, On
		prev_hotkey := hotkeydefesa
	}
}

SendA()
{
	Send a
	Sleep 100
}
fabiolwg
Posts: 9
Joined: 08 May 2016, 03:25

Re: How to pass variable to hotkey?

16 May 2016, 00:29

Thanks u saved a soul and you goes to heaven
Coco-guest

Re: How to pass variable to hotkey?

16 May 2016, 00:35

Fixed a little bit:

Code: Select all

Gui New
Gui Font, s10, Consolas
Gui Margin, 5, 5
Gui Add, Hotkey, w150 r1 vhotkeydefesa gDefHotkey
Gui Show
return
GuiEscape:
GuiClose:
	ExitApp

DefHotkey(args*)
{
	global hotkeydefesa
	static prev_hotkey := ""
	if (prev_hotkey != "")
		HotKey %prev_hotkey%,, Off
	if (hotkeydefesa != "")
		HotKey %hotkeydefesa%, SendA, On
	prev_hotkey := hotkeydefesa
}

SendA()
{
	Send a
	Sleep 100
}
Guest888

Re: How to pass variable to hotkey?

17 May 2016, 04:10

the IniReads in your code can be simplified by loops.

Code: Select all


loop 11
 IniRead, parametro%A_Index%, semdedokfm.ini, Defesa, parametro%A_Index% , 0
........
fabiolwg
Posts: 9
Joined: 08 May 2016, 03:25

can someone fix it there

20 May 2016, 20:15

Gui New
Gui Font, s10, Consolas
Gui Margin, 5, 5
Gui Add, Hotkey, w150 r1 vhotkeydefesa gDefHotkey
global defesa1
defesa1 = 1
Gui Show
return
GuiEscape:
GuiClose:
ExitApp

DefHotkey(args*)
{
global hotkeydefesa
static prev_hotkey := ""
if (prev_hotkey != "")
HotKey %prev_hotkey%,, Off
if (hotkeydefesa != "")
HotKey %hotkeydefesa%, SendA, On
prev_hotkey := hotkeydefesa
}


SendA()
{
Send {%hotkeydefesa% down}
;while(GetKeyState("Numpad0","P"))
while(GetKeyState(%hotkeydefesa%,"P"))
{
Send 1
sleep 100
Send 2
sleep 100
Send 3
Sleep 100
Send 4
Sleep 100
Send 5
Sleep 100
Send 6
Sleep 100
}
Send {%hotkeydefesa% up}
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 150 guests