Help with script to activate when pressing specific key

Get help with using AutoHotkey and its commands and hotkeys
testerplay
Posts: 3
Joined: 13 Jan 2019, 15:51

Help with script to activate when pressing specific key

13 Jan 2019, 16:12

Hello,

First of all im basically a noob at this.
Currently i have a script that sends the key g after i release mouse1.
~lbutton up::
Sleep, 20
send g
return
But the problem i have now is every time i release mouse1 it sends g and i only want it to work when i press g first.
Is there is anyone who knows how the script only works after i press g before and stops again after running 1 time.

So it should look like:
''Press g script starts working"
~lbutton up::
Sleep, 20
send g
return
"Script stops working"
Thanks in advance for your help
rommmcek
Posts: 539
Joined: 15 Aug 2014, 15:18

Re: Help with script to activate when pressing specific key

13 Jan 2019, 17:04

How do you want to send g?
- while pressing g down and clicking?
- first pressing g and releasing it, then clicking (once or multiple times)?

Code: Select all

~g::Togle:=!Toggle

~lbutton up::
	if !Togle
		return
	Sleep, 20
	send g
	Togle:=!Togle
 return

Code: Select all

g & ~lbutton up::
	Sleep, 20
	send g
 return
testerplay
Posts: 3
Joined: 13 Jan 2019, 15:51

Re: Help with script to activate when pressing specific key

14 Jan 2019, 09:41

rommmcek wrote:
13 Jan 2019, 17:04
How do you want to send g?
- while pressing g down and clicking?
- first pressing g and releasing it, then clicking (once or multiple times)?

Code: Select all

~g::Togle:=!Toggle

~lbutton up::
	if !Togle
		return
	Sleep, 20
	send g
	Togle:=!Togle
 return

Code: Select all

g & ~lbutton up::
	Sleep, 20
	send g
 return
First of all thanks for the reply.
I tested both of them but they dont seem to work.
I basically want a script when i press g first release the button and after that i use mouse1 and after the release i want it to send g.
So it doesn't send a g input everytime i use mouse1 but only when i press g before i use my mouse1.

I apologize for my bad english, its not my native language
rommmcek
Posts: 539
Joined: 15 Aug 2014, 15:18

Re: Help with script to activate when pressing specific key

14 Jan 2019, 10:39

Sorry for the script full of bugs and typos! It couldn't work!
This should:

Code: Select all

$g::Toggle:=!Toggle

~lbutton up::
	if !Toggle
		return
	Sleep, 20
	sendinput, g
	Toggle:=!Toggle
return
testerplay
Posts: 3
Joined: 13 Jan 2019, 15:51

Re: Help with script to activate when pressing specific key

14 Jan 2019, 12:25

No problem,
so i tested it out in notepad and the script is working but not like i need to.
the part where it only sends g after i release mouse1 works.
But the problem im having is the times when i only press g it doesn't give me a g input and only works as a toggle if u understand what i mean.
Now it looks like: (what i type on keyboard and what comes up "/" means nothing)
"press g" "release mouse1" this looks like ---> "/" "/" "g"
And it should look like --------------------------> "g" "/" "g"
Thats what the original thing did but the problem there was that every time i press mouse1 it sends g and i only want it to work when i press g before mouse 1 but the first g also still be a input if your still following :crazy: :D
Sleep, 20
send g
return
So the problem i have now is that i need that i need g to toggle the script but also has to be a input.

Sorry for all the problems
rommmcek
Posts: 539
Joined: 15 Aug 2014, 15:18

Re: Help with script to activate when pressing specific key

14 Jan 2019, 13:04

I'm not sure if I understand you, but try this ~$g::Toggle:=!Toggle if it suits you!
or:

Code: Select all

~$g::
if !Toggle
	Toggle:=!Toggle
return

~lbutton up::
	if !Toggle
		return
	Sleep, 20
	sendinput, g
	Toggle:=!Toggle
return
There are still many combinations. Just test it and dont hesitate to adapt the script!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], MannyKSoSo, Samantha and 140 guests