Error dialog keeps appearing, any fix? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Error dialog keeps appearing, any fix?

19 Apr 2021, 20:03

hi, this is my script

Code: Select all

MaxPresses := 2



~Space::

Presses += 1

SetTimer, ResetPresses, -600

If (Pressed <= MaxPresses)

	GoSub, Presses%Presses%

return



ResetPresses:

Presses := 0

return



Presses1:

TrayTip, %A_ThisLabel%, You pressed Space 1 time

return



Presses2:

TrayTip, %A_ThisLabel%, You pressed Space 2 times

return

it works as normal but here's the problem
if I press "space" three or more times rapidly within 600ms, the error dialog pops up saying this
1.PNG
1.PNG (22.44 KiB) Viewed 429 times
I can minimize this problem by adjusting the settimer value down to 200ms or something
but is there a way I can stop it from showing completely?
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Error dialog keeps appearing, any fix?

19 Apr 2021, 20:16

Two ways:

1. Add a line that skips the Gosub if the value is invalid.

2. Reset the value after it reaches the maximum.
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Re: Error dialog keeps appearing, any fix?

19 Apr 2021, 20:50

thank you for the reply
but how to add a line to skip gosub?

I tried to put else after GoSub, Presses%Presses% which did nothing

:(
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Error dialog keeps appearing, any fix?

19 Apr 2021, 21:24

I think I would change Pressed to Presses.

Code: Select all

~Space::
Presses++
SetTimer, ResetPresses, -600
If Presses between 1 and 2
 TrayTip, Presses, Times pressed: %Presses%
Return

ResetPresses:
Presses := 0
Return
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Re: Error dialog keeps appearing, any fix?

19 Apr 2021, 21:43

mikeyww wrote:
19 Apr 2021, 21:24
I think I would change Pressed to Presses.

Code: Select all

~Space::
Presses++
SetTimer, ResetPresses, -600
If Presses between 1 and 2
 TrayTip, Presses, Times pressed: %Presses%
Return

ResetPresses:
Presses := 0
Return
oh, that seems to work but I am sorry to say my real script is not traytip, it is two different actions that I want it to take.
I am not sure this makes sense but

Code: Select all

~Space::
Presses++
SetTimer, ResetPresses, -600
{
If Presses 1
do something  (for example ctrl s)
If Presses 2
do another thing (for example ctrl o)
return

ResetPresses:
Presses := 0
Return
is this possible? thx
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Error dialog keeps appearing, any fix?  Topic is solved

19 Apr 2021, 21:49

Code: Select all

~Space::
Presses++
SetTimer, ResetPresses, -600
Switch Presses {
 Case 1: Send ^s
 Case 2: Send ^o
}
Return

ResetPresses:
Presses := 0
Return
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Re: Error dialog keeps appearing, any fix?

19 Apr 2021, 22:46

mikeyww wrote:
19 Apr 2021, 21:49

Code: Select all

~Space::
Presses++
SetTimer, ResetPresses, -600
Switch Presses {
 Case 1: Send ^s
 Case 2: Send ^o
}
Return

ResetPresses:
Presses := 0
Return
omg there's problem. in the example case, pressing space twice gives me both "save as" and "open dialog"
how to avoid this? I want two work separately.

and another problem is if I add #warn for integrity check, error saying:
Attachments
222.PNG
222.PNG (18.14 KiB) Viewed 357 times
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Error dialog keeps appearing, any fix?

20 Apr 2021, 07:03

Code: Select all

~Space::
KeyWait, Space
KeyWait, Space, DT.3
If ErrorLevel {      ; Pressed once
 Send ^s
 SoundBeep, 1700
} Else Send ^o       ; Pressed twice
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bobak, jaka1, MrDoge and 241 guests