Start

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Start

06 Apr 2020, 17:24

Hello,
When I double click it suspend the script.. how to make it when I double click again to un-suspend/start the script?

Code: Select all

#NoEnv 
LButton::
if (A_TickCount - LButton_Tick <= 330) AND (LButton_Tick >= 1)
{
Suspend
}
else
{
Send {LButton down}
if (GetKeyState("LButton" , "P"))
Send {w down}
}
SetTimer, ClickBackUp, -1
LButton_Tick := A_TickCount


ClickBackUp:
if !(GetKeyState("LButton" , "P"))
{
Send {w up}
Send {LButton up}
}
else
SetTimer, ClickBackUp, -1
return 
o::ExitApp
[Mod edit: [code][/code] tags added]
User avatar
SirSocks
Posts: 360
Joined: 26 Oct 2018, 08:14

Re: Start

06 Apr 2020, 22:01

Use the built in toggle mode for suspend.

Code: Select all

 
#NoEnv 
LButton::
if (A_TickCount - LButton_Tick <= 330) AND (LButton_Tick >= 1)
{
Suspend, toggle ; Changes to the opposite of its previous state (On or Off).
}
else
{
Send {LButton down}
if (GetKeyState("LButton" , "P"))
Send {w down}
}
SetTimer, ClickBackUp, -1
LButton_Tick := A_TickCount


ClickBackUp:
if !(GetKeyState("LButton" , "P"))
{
Send {w up}
Send {LButton up}
}
else
SetTimer, ClickBackUp, -1
return 
o::ExitApp
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Start

07 Apr 2020, 07:04

It doesn't work :(

Code: Select all

LButton::
if (A_TickCount - LButton_Tick <= 330) AND (LButton_Tick >= 1)
{
Suspend, toggle
}
else
{
Send {LButton down}
if (GetKeyState("LButton" , "P"))
Send {w down}
}
SetTimer, ClickBackUp, -1
LButton_Tick := A_TickCount


ClickBackUp:
if !(GetKeyState("LButton" , "P"))
{
Send {w up}
Send {LButton up}
}
else
SetTimer, ClickBackUp, -1
return
[Mod edit: [code][/code] tags added. Thank you for using them in the future!]
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Start

07 Apr 2020, 08:05

Maybe I am doing it the wrong way but from what I tried,this will work only if you use keyboard keys.
Once the script is suspended,mouse buttons will do nothing(probably intended)
With keyboard keys,this is allowed

What exactly are you trying to do(maybe there is a better way than suspending the hotkeys...or maybe you mean,you want to pause the script,not the hotkeys)
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Start

07 Apr 2020, 08:48

vsub wrote:
07 Apr 2020, 08:05
Maybe I am doing it the wrong way but from what I tried,this will work only if you use keyboard keys.
Once the script is suspended,mouse buttons will do nothing(probably intended)
With keyboard keys,this is allowed

What exactly are you trying to do(maybe there is a better way than suspending the hotkeys...or maybe you mean,you want to pause the script,not the hotkeys)
I want when I perform a double click the whole script to be invalid and everything to act like there is not script..
But when I double click again, to activate the script.
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Start

07 Apr 2020, 09:10

That's can't happens because mouse clicks are ignored when the script is suspended.
You have few options
1.Run another script that disables\enables that other one
2.Edit your script in a way that don't suspend the script but changes some variable that acts as enabler for the rest of your code
3.Use keyboard key to enable\disable it(this is the easiest way)

Post your script
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Start

07 Apr 2020, 11:14

vsub wrote:
07 Apr 2020, 09:10
That's can't happens because mouse clicks are ignored when the script is suspended.
You have few options
1.Run another script that disables\enables that other one
2.Edit your script in a way that don't suspend the script but changes some variable that acts as enabler for the rest of your code
3.Use keyboard key to enable\disable it(this is the easiest way)

Post your script
Can I only disable the w button ?
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Start

07 Apr 2020, 11:32

Do you want that "w" hotkey to be active globally when it is not disabled or only for specific windows

Code: Select all

~LButton::
Keywait,LButton
If ((A_TimeSincePriorHotkey <= 300) & (A_PriorKey = "LButton"))
{
If WKey =
WKey = 1
Else
WKey =
}
Return

#If (WKey = "")
W::
MsgBox,,,,1
Return
At start pressing w will show a msgbox and if you double click,it will work normally(double clicking again will show the msgbox again

You can place all of your hotkeys below "#If (WKey = "")" and they will all be enabled\disabled by double clicking(that command is needed only once and everything below it will obey that rule until you place some other "#If" condition)
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Start

07 Apr 2020, 11:58

vsub wrote:
07 Apr 2020, 11:32
Do you want that "w" hotkey to be active globally when it is not disabled or only for specific windows

Code: Select all

~LButton::
Keywait,LButton
If ((A_TimeSincePriorHotkey <= 300) & (A_PriorKey = "LButton"))
{
If WKey =
WKey = 1
Else
WKey =
}
Return

#If (WKey = "")
W::
MsgBox,,,,1
Return
At start pressing w will show a msgbox and if you double click,it will work normally(double clicking again will show the msgbox again

You can place all of your hotkeys below "#If (WKey = "")" and they will all be enabled\disabled by double clicking(that command is needed only once and everything below it will obey that rule until you place some other "#If" condition)
How can I add it in my script? I am ok with the ''w'' to not be active when it's disabled

Code: Select all

#NoEnv 
LButton::
if (A_TickCount - LButton_Tick <= 330) AND (LButton_Tick >= 1)
{
Suspend
}
else
{
Send {LButton down}
if (GetKeyState("LButton" , "P"))
Send {w down}
}
SetTimer, ClickBackUp, -1
LButton_Tick := A_TickCount


ClickBackUp:
if !(GetKeyState("LButton" , "P"))
{
Send {w up}
Send {LButton up}
}
else
SetTimer, ClickBackUp, -1
return 
o::ExitApp
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Start

07 Apr 2020, 12:09

Umm,I am not sure I understand that code
Do you want lbutton to send w when you are doing a single click,disable sending w when you double click once and send w on left click again after you double click.

Code: Select all

Mode = On

~LButton::
Keywait,LButton
If ((A_TimeSincePriorHotkey <= 300) & (A_PriorKey = "LButton"))
{
If Mode = on
{
Mode = Off
Return
}
Else
Mode = on
}
Else
{
If Mode = On
Send,w
}
Return
Do you want to block lbutton when sending w or not?
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Start

07 Apr 2020, 12:14

vsub wrote:
07 Apr 2020, 12:09
Umm,I am not sure I understand that code
Do you want lbutton to send w when you are doing a single click,disable sending w when you double click once and send w on left click again after you double click.

Code: Select all

Mode = On

~LButton::
Keywait,LButton
If ((A_TimeSincePriorHotkey <= 300) & (A_PriorKey = "LButton"))
{
If Mode = on
{
Mode = Off
Return
}
Else
Mode = on
}
Else
{
If Mode = On
Send,w
}
Return
Do you want to block lbutton when sending w or not?
yes, both or at least the first one
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Start

07 Apr 2020, 12:16

Well this is doing that
At start it is sending lbutton and w
When you double click,it sends just lbutton
When you double click again,it start sending w and lbutton again
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Start

07 Apr 2020, 17:37

vsub wrote:
07 Apr 2020, 12:16
Well this is doing that
At start it is sending lbutton and w
When you double click,it sends just lbutton
When you double click again,it start sending w and lbutton again
doesn't work
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Start

09 Apr 2020, 05:46

help

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 346 guests