New to AHK and stuck Topic is solved
-
- Posts: 4
- Joined: 14 Jul 2018, 17:17
New to AHK and stuck
I've been trying to get this script to work but I can't seem to get it just right. I'm trying to get a macro that can toggle on and off. For example, say I want to press crtl+c whenever I press c (which i can do) but I also want one of my function keys to toggle the script on and off, I'm very new to coding and honestly have no idea how to do this. I feel like this is super simple but I'm just very clueless
-
- Posts: 4
- Joined: 14 Jul 2018, 17:17
Re: New to AHK and stuck
If it helps, the actual keys i want to press is Mouse 4 to activate crtl+e
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: New to AHK and stuck
So what you are looking for is something like this?
The toggle can be done using Toggle := !Toggle which switches between 2 numbers (basically a yes and a no). And to turn it off you put a break in that checks when its completed and the toggle has changed to a no.
Also not that the toggle has to be noted before the loop starts otherwise it will break.
Code: Select all
F7::
Toggle := !Toggle
while (Toggle) {
If not Toggle
break
;rest of code
}
Return
Also not that the toggle has to be noted before the loop starts otherwise it will break.
-
- Posts: 4
- Joined: 14 Jul 2018, 17:17
Re: New to AHK and stuck
Im still a little bit confused, just that, how would I add my macro to this.MannyKSoSo wrote:So what you are looking for is something like this?The toggle can be done using Toggle := !Toggle which switches between 2 numbers (basically a yes and a no). And to turn it off you put a break in that checks when its completed and the toggle has changed to a no.Code: Select all
F7:: Toggle := !Toggle while (Toggle) { If not Toggle break ;rest of code } Return
Also not that the toggle has to be noted before the loop starts otherwise it will break.
I still want an action to be played only when i press a certain key and i just don't know how to do that while having a toggle along side.
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: New to AHK and stuck
So F7 activates the hot key. You can change it to any button using the ones from this list https://autohotkey.com/docs/KeyList.htm
But that depends on the type of toggle you are looking for. If you are looking for something that can Suspend the script so your button doesn't do the command you can read this https://autohotkey.com/docs/commands/Suspend.htm (specifically the 1st example)
Mouse button 4 is specific to and you can set it to play once by doing this
But that depends on the type of toggle you are looking for. If you are looking for something that can Suspend the script so your button doesn't do the command you can read this https://autohotkey.com/docs/commands/Suspend.htm (specifically the 1st example)
Mouse button 4 is specific to
Code: Select all
XButton1
Code: Select all
XButton1:: Send ^{e}
-
- Posts: 4
- Joined: 14 Jul 2018, 17:17
Re: New to AHK and stuck Topic is solved
Ok so I figured it out (no thanks to MannyKSoSo)
I looked at the suspend code and came up with
And yeah i was correct, it was a lot simpler than i thought.
I looked at the suspend code and came up with
Code: Select all
F1::Suspend
XButton1:: Send ^{e}
Return
Return
Re: New to AHK and stuck
F7 to toggle the "c" hotkey
Code: Select all
F7::Toggle := !Toggle
#if Toggle
C::MsgBox, hi!
Who is online
Users browsing this forum: Google [Bot], hedehede81, OrangeCat and 317 guests