Jump to content

Hotkey ESC + Exit doesn't appear to be working


Recommended Posts

I'm trying to stop the script by pressing ESC, but it doesn't appear to do anything. 

I can't even right-click the taskbar icon to exit the script. I have to kill the process through task manager. 

Using W10 and the ImageSearch 64 bit library

#include <ImageSearch.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

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

MsgBox($MB_OK, "start", "start")

global $y = 0, $x = 0, $searchAgain = true

Func _Quit()
    Exit
EndFunc

while 1
    $searchAgain = true
    local $search = _ImageSearch('button.PNG', 1, $x, $y, 100)
    If $search = 1 Then
        $searchAgain = false
        MouseMove($x, $y, 10)
        MouseClick($MOUSE_CLICK_LEFT, $x, $y, 1)
        Sleep(100)
    EndIf
    
    if $searchAgain Then
        local $search = _ImageSearch('button2.PNG', 1, $x, $y, 100)
        If $search = 1 Then
            MouseMove($x, $y, 10)
            MouseClick($MOUSE_CLICK_LEFT, $x, $y, 1)
            Sleep(100)
        EndIf
    EndIf
WEnd

 

Link to comment
Share on other sites

5 hours ago, Technix said:

I'm trying to stop the script by pressing ESC, but it doesn't appear to do anything. Using W10 and the ImageSearch 64 bit library

I do not use the ImageSearch UDF, so the error may result from that.
Just as a proof of concept, try this :

;~ #include <ImageSearch.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

HotKeySet("{ESC}", _Quit)

MsgBox($MB_OK, "start", "start")

Global $y = 0, $x = 0, $search, $searchAgain = True

While 1
    $searchAgain = True
    If $search = 1 Then
        $searchAgain = False
        Sleep(100)
    EndIf

    If $searchAgain Then
        If $search = 1 Then
            MouseMove($x, $y, 10)
            MouseClick($MOUSE_CLICK_LEFT, $x, $y, 1)
            Sleep(100)
        EndIf
    EndIf
WEnd

Func _Quit()
    MsgBox(BitOR(4096, 64), "Message :", "Script terminated" & @CRLF)
    Exit
EndFunc   ;==>_Quit

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Developers

Guess the program that has the focus is capturing the Esc...   which program are you automating?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

On 5/20/2022 at 6:12 PM, Musashi said:

I do not use the ImageSearch UDF, so the error may result from that.
Just as a proof of concept, try this :

Ok, this properly terminated. This is good (and bad)

On 5/20/2022 at 8:26 PM, Jos said:

Guess the program that has the focus is capturing the Esc...   which program are you automating?

Google Chrome. If it has any impact, website GUI is running Vuetify. Automating data entry

Edited by Technix
Link to comment
Share on other sites

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...