Would like to turn off/on my script

Ask gaming related questions (AHK v1.1 and older)
Saiko_Style
Posts: 3
Joined: 27 Jul 2015, 00:50

Would like to turn off/on my script

27 Jul 2015, 00:56

Hey all... new here, i've used ahk a few times before, and just recently started again... i currently use:

Code: Select all


space::
Sendinput {3}
Sendinput {4}
Sendinput {5}
Return


to use three utility flasks whenever i hit space, and it works wonderfully, but i was wondering if i could add a little more functionality.

What i'd like, is for it to only work when a certain window is open..... and for it to turn off/on when i hit enter.

basically, when i hit enter, to open chat, it will no longer override my space bar... and when i hit enter to send message or close chat, it will start again.... is this possible?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Would like to turn off/on my script

27 Jul 2015, 03:57

Here you go, this should do basically what you want.

Code: Select all

ChatMode :=0

~Enter::
   ChatMode := !ChatMode
   return

~space::
if (ChatMode){
   return
}
Sendinput {3}
Sendinput {4}
Sendinput {5}
Return
Saiko_Style
Posts: 3
Joined: 27 Jul 2015, 00:50

Re: Would like to turn off/on my script

27 Jul 2015, 04:38

hmm.... it sorta works... hitting enter did, indeed turn it off/on.... but it didn't send enter, as well... so chat never opened/closed.... i added a sendinput, so that worked, and upon testing, i found a new problem: .... in chat, hitting space didn't send 345.... but it also didn't send space... i'm fiddling to try and get that to work, but adding a sendinput {space} just gives me a popup about sending 71 hotkeys, whenever i hit space, in chatmode.


Thanks for the help thus far, though! ... it helped immensely :)
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Would like to turn off/on my script

27 Jul 2015, 04:55

That's why I added the ~ to the start of Enter:: and Space::
The ~ symbol means that the key will not be blocked from the OS.

If you have space as a trigger key that then sends space, you may end up in a loop.
You may have to put a $ symbol at the start (ie $~Space::) to tell AHK to ignore spaces that it sent.
Saiko_Style
Posts: 3
Joined: 27 Jul 2015, 00:50

Re: Would like to turn off/on my script

27 Jul 2015, 04:59

aah, okay, thanks... i removed the ~ from space, because it was sending space345 .... and space closes the minimap, lol.... that helps a lot :)

Edit: just fiddled a little more, and it works excellently now:

Code: Select all


ChatMode :=0
 
$~Enter::
   ChatMode := !ChatMode
   return
 
$space::
if (ChatMode){
Sendinput {Space}
   return
}
Sendinput {3}
Sendinput {4}
Sendinput {5}
Return
Thanks a ton for all your help... it's workable now :)

now i just need to make it only work only for the game, so google doesn't think i am crazy all the time, and such, lol.


Edit again... i figured that one out on my own, via some searching... it works perfectly... thanks yet again :)
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Would like to turn off/on my script

14 Sep 2015, 18:20

try this

Code: Select all

~Enter::
toggle := !toggle
Sleep, 300
return

#If toggle

$space::
Sendinput {3}
Sendinput {4}
Sendinput {5}
Return

#If
:wave: There is always more than one way to solve a problem. ;)

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 47 guests