SendInput function Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Zurydix
Posts: 21
Joined: 12 Jul 2017, 06:15

SendInput function

15 Jul 2017, 07:53

Hello,

I'm new with AHK and I have a problem that I'm sure its stupid to solve but I didn't found how to :(

So I want to be able to use a macro if the checkbox is checked, this is working, but I added an Hotkey function who edit the macro.
Here,

Code: Select all

SendInput {m[1] "{" m[2] "} Down}
{m[1] "{" m[2] "} should be changed by the hotkey but it doesn't, when I use it, it just send Down Up Down Up......

Code: Select all

Gui, -Sysmenu
Gui, Add, GroupBox, x190 y39 w180 h110 , Others
Gui, Add, CheckBox, x195 y102 w90 h16 vReload gReload, Reload Cancel
Gui, Add, Hotkey, x290 y102 w40 h20 vReloadk gReloadk
Gui, Add, Button, x503 y5 w100 h30 gClose, Close
Gui, Show, x157 y151 h275 w610, test
Return

Reload:
Gui, Submit, NoHide
Return

Reloadk:
Gui, Submit, NoHide
Return

Close:
ExitApp

#If (Reload = 1)

	CapsLock::
	Gui, Submit, NoHide
	RegExMatch(Reloadk,"O)([\^+!]+|)(.*)", m)
	Loop
		{
		if not GetKeyState("CapsLock","P")
		break
		SendInput {Space Down}
		Sleep 020
		SendInput {Space Up}
		Sleep 047
		SendInput {m[1] "{" m[2] "} Down}
		Sleep 016
		SendInput {Space Down}
		Sleep 030
		SendInput {m[1] "{" m[2] "} Up}
		Sleep 031
		SendInput {Space Up}
		Sleep 020
		}
	return
Thanks if you can help :)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: SendInput function

19 Jul 2017, 16:48

Check your SendInput lines, they should look something like this:

Code: Select all

q::
m := ["a","b"]
SendInput, % "{" m[1] "}{" m[2] "}"
ToolTip, % "{" m[1] "}{" m[2] "}"
;MsgBox, % "{" m[1] "}{" m[2] "}"
return
Note: I've added some ToolTip/MsgBox lines that will allow you to check what the string you are going to use with SendInput, actually looks like.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Guest

Re: SendInput function

20 Jul 2017, 16:42

Thanks for reply,

I changed to this :

Code: Select all

#If (Reload = 1)
	CapsLock::
	Gui, Submit, NoHide
	RegExMatch(Reloadk,"O)([\^+!]+|)(.*)", m)
	Loop
		{
		if not GetKeyState("CapsLock","P")
		break
		SendInput {Space Down}
		Sleep 020
		SendInput {Space Up}
		Sleep 047
		SendInput, % "{" m[1] "}{" m[2] "} Down}"
		Sleep 016
		SendInput {Space Down}
		Sleep 030
		SendInput, % "{" m[1] "}{" m[2] "} Up}"
		Sleep 031
		SendInput {Space Up}
		Sleep 020
		}
	return
Now the hotkey is working, but I want to set it down, or up and I don't find how to, I'm sure it's easy :facepalm:

When I use it I have something like

Code: Select all

 2 Down 2 Up 2 Down 2 Up 2 Down 2 Up (2 is example)
Thanks :wave:
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: SendInput function  Topic is solved

20 Jul 2017, 19:48

I'm not actually 100% clear what you want to do. A problem is that you seem to have too many closing curly braces. It is quite hard to look at, the text with the object references inside, so what I tend to do is start with some literal text and convert it.

Code: Select all

;SendInput, % "{a}{b}"
;-> SendInput, % "{" m[1] "}{" m[2] "}"

;SendInput, % "{a down}{b down}"
;-> SendInput, % "{" m[1] " down}{" m[2] " down}"

;SendInput, % "{a up}{b up}"
;-> SendInput, % "{" m[1] " up}{" m[2] " up}"

q::
m := ["Shift","b"]
SendInput, % "{" m[1] " down}"
Sleep 300
SendInput, % "{" m[2] "}"
Sleep 300
SendInput, % "{" m[1] " up}"
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], zerox and 323 guests