Getting a script to stay off. On a toggle.

Get help with using AutoHotkey and its commands and hotkeys
AllMateria
Posts: 1
Joined: 07 Feb 2018, 07:37

Getting a script to stay off. On a toggle.

07 Feb 2018, 07:45

*$LButton::


{

GoSub clicky

}

Return ; <<This?



clicky:

{

MouseClick, left,,,1,0,D

Sleep 1200

MouseClick, left,,,1,0,U

}

Return


Thats the script I'm currently using to hold my left mouse button down for 1.2 seconds. Works nicely, just that I cant stop it. Pausing it doesn't work. Well it would if my left mouse button wouldn't auto start it back up again. I'd like to be able to turn this off without having it take 1.2 seconds to click when I dont need it too.

I've also searched everywhere for an answer. Nothing I've tried seems to work. Left click starts by itself. need it to be on a toggle, where even if I click it wont activate, until I retoggle it. F12 or something.

Would anyone be able to help me with this?
User avatar
divanebaba
Posts: 775
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Getting a script to stay off. On a toggle.

07 Feb 2018, 19:05

If you want to suspend your script, try this tricky code I found in the forum

Code: Select all

$Pause::
While, GetKeyState("Pause","P") {
suspend, on
Sleep, 150
}
KeyWait, Pause, D
suspend, off 
return

*$LButton::
GoSub clicky
Return ; <<This is ok. Sometimes not necessary but never too much 

clicky:
{
	MouseClick, left,,,1,0,D
	Sleep 1200
	MouseClick, left,,,1,0,U
}
Return
It will suspend and activate your script with same key.

BTW: Welcome to the AHK forum :mrgreen: :mrgreen:
User avatar
Off Topic
Posts: 43
Joined: 07 Oct 2017, 20:57

Re: Getting a script to stay off. On a toggle.

07 Feb 2018, 19:39

Another handy trick -- you can also use PostMessage to directly interact with scripts:

Code: Select all

PostMessage, 0x111, 65307,,, NewAutoHotkeyScript.ahk - AutoHotkey
It doesn't require the script directory, just replace "NewAutoHotkeyScript.ahk" with the name (and .ahk suffix) of the script needed. Any script can then pause, suspend, kill, edit, or run any other script this way through hotkeys, labels, etc.

Code: Select all

; PostMessage REF
		; PostMessage, 0x111, 65304,,, SCRIPT.ahk - AutoHotkey
		; Open:    65300
		; Help:    65301
		; Spy:     65302
		; Reload:  65303
		; Edit:    65304
		; Suspend: 65305
		; Pause:   65306
		; Exit:    65307
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

Re: Getting a script to stay off. On a toggle.

07 Feb 2018, 20:18

F12::Suspend should work for you; not sure why the complex scripts requesting you work off of using a second script?

This would disable all hotkeys in your script.

If you need to be selectively disabling this hotkey, it can be done by using #If and custom variables. See toggle examples in (Note: The first link is from the old forums, the second link is on these forums) http://www.autohotkey.com/board/topic/6 ... re-thread/ or https://autohotkey.com/boards/viewtopic.php?f=7&t=11952

Return to “Ask For Help”

Who is online

Users browsing this forum: Chunjee, DRocks, Enlprck, Google [Bot], MannyKSoSo, openstar21, vsub and 157 guests