Jump to content

Can't interrupt script on win11


Go to solution Solved by DanielT,

Recommended Posts

Before, on my old computer running win10, I never had any problems interrupting scripts by seting a hotkey to call an exit function. Now on the new computer with win11 it seems that I'm no longer able to interrupt a scripts unless I call a sleep function. Sadly I have no way to tell exactly what version of autoit I was running back then, but right now I'm using v3.3.16.1.

Here's a basic script which I'm unable to interrupt by hitting ESC:

HotKeySet("{ESC}", "Stop")

MouseClick("left", 300, 300)
MouseClick("left", 600, 300)
MouseClick("left", 600, 600)
MouseClick("left", 300, 600)
MouseClick("left", 300, 300)
MouseClick("left", 600, 300)
MouseClick("left", 600, 600)
MouseClick("left", 300, 600)


Func Stop()
    Exit
EndFunc

Now if I add sleep in between the clicks then I'm able to interrupt the script:
 

HotKeySet("{ESC}", "Stop")

MouseClick("left", 300, 300)
Sleep(100)
MouseClick("left", 600, 300)
Sleep(100)
MouseClick("left", 600, 600)
Sleep(100)
MouseClick("left", 300, 600)
Sleep(100)
MouseClick("left", 300, 300)
Sleep(100)
MouseClick("left", 600, 300)
Sleep(100)
MouseClick("left", 600, 600)
Sleep(100)
MouseClick("left", 300, 600)


Func Stop()
    Exit
EndFunc


Ty for any help.

Link to comment
Share on other sites

It takes around 4s to end, but even if I increase the amounf ot instructions for it to take 10+ seconds I still cant interrupt it.

Here's an actual script that I was able to interrupt before:
 

#RequireAdmin
HotkeySet ("{F10}", "Stop")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; accept button position
$xAcceptPos = 1816
$yAcceptPos = 350

; decrease button position
$xDecreasePos = 1779
$yDecreasePos = 324

; first slot position
$xSlotPos = 1745
$ySlotPos = 286

; y distance
$yDistance = 18

; delay for after restoring window
$restoreDelay = 1000

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Open window
MouseClick( "left", 90, 1060)

; Wait for it to open
Sleep( $restoreDelay )

$i = 1
While $i < 999999
    If Mod($i, 2) = 0 Then
       MouseClick( "left", $xSlotPos, $ySlotPos + $yDistance)
       MouseClick( "left", $xSlotPos, $ySlotPos)
       MouseClick( "left", $xDecreasePos, $yDecreasePos)
       MouseClick( "left", $xAcceptPos, $yAcceptPos)
    Else
       MouseClick( "left", $xSlotPos, $ySlotPos)
       MouseClick( "left", $xSlotPos, $ySlotPos + $yDistance)
       MouseClick( "left", $xDecreasePos, $yDecreasePos + $yDistance)
       MouseClick( "left", $xAcceptPos, $yAcceptPos + $yDistance)
    EndIf


    Send("1")
    $i = $i + 1
WEnd

Func Stop ()
        Exit 0
EndFunc

 

Link to comment
Share on other sites

I have to admit, that's a strange behavior. I tried the code below and I see what you mean. If I add a tiny sleep of 10 ms it works but If I just delay the mouse clicks even with 100 ms still doesn't work. Also in an infinite loop or if I do some other operations in the loop the hot key is triggered but not with MouseClick(). I'm not sure about the internal implementation of these functions so I can't say if it's a bug. Maybe others can try this code on different OS to check if this issue is persistent.

;~ AutoItSetOption('MouseClickDelay', 100)

HotKeySet("{ESC}", "Stop")

$Timer = TimerInit()

While TimerDiff($Timer) < 10000
    MouseClick("left", 300, 600)
;~  Sleep(10)
WEnd

Func Stop()
    Exit
EndFunc

 

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...