Search code examples
user-interfaceautohotkeymsgbox

autohotkey msgbox closes gui when pressing "ok" button


I made a script with a gui. In the gui I placed a button that opens a messagebox to show more information. The overall use of the script is that it deletes chrome browser history. It just started as a joke but now I try to develop this more and more to learn to code more features and is in general just a practise script. I stumbled upon this issue however with the messagebox and gui system.

If I click the "ok" button or the red X to close the messagebox, it doesn't just closes the messagebox, it also closes the gui. Any idea on how I could fix this?

This is my script:

#SingleInstance Force
SetWorkingDir, %A_ScriptDir%
Coordmode, Mouse, Screen
Coordmode, Pixel, screen





global Opstartsnelheid
global Scriptsnelheid

IniRead, Opstartsnelheid, settings.ini, Snelheid, Opstartsnelheid, 2000
IniRead, Scriptsnelheid, settings.ini, Snelheid, Scriptsnelheid, 1000


Gui, +AlwaysOnTop
Gui, history:New
Gui, Add, Text,, B-History Cleaner BETA
Gui, Add, Text, x25 y25, Opstartsnelheid in milliseconden
Gui, Add, Edit, w80 vOpstartsnelheid Number, %Opstartsnelheid%
Gui, Add, Text,, Scriptsnelheid in milliseconden
Gui, Add, Edit, w80 vScriptsnelheid Number, %Scriptsnelheid%


Gui, Add, Text,, BELANGRIJK!
Gui, Add, Text,, Druk eerst op save voordat je op run klikt
Gui, Add, Button, x25 y170 Default w80 gSubmit, Save
Gui, Add, Button, w80 gClose, Exit Program
Gui, Add, Text,, Je kunt ten alle tijden het programma sluiten
Gui, Add, Text,, door op ESC te drukken
Gui, Add, Button, x150 y170 w80 gRun, Run
Gui, Add, Button, w80 gCredits, Information


Gui, show, w250 h300, B-History Cleaner Instellingen
return




Submit:
    Gui, Submit, NoHide
    IniWrite, %Opstartsnelheid%, settings.ini, Snelheid, Opstartsnelheid
    IniWrite, %Scriptsnelheid%, settings.ini, Snelheid, Scriptsnelheid
    return

Information:
    MsgBox, 0, Information, More Information soon to be added

Close:
    ExitApp
    return








Run:
RunWait, Chrome
Sleep, %Opstartsnelheid%

ImageSearch, maximisex, maximisey, 0, 0, A_ScreenWidth, A_ScreenHeight, maximise.png
MouseMove, maximisex, maximisey
Click
Sleep, %Scriptsnelheid%

Send, ^h
Sleep, %Scriptsnelheid%

ImageSearch, browsergegevenswissenx, browsergegevenswisseny, 0, 0, A_ScreenWidth, A_ScreenHeight, browsergegevenswissen.png
MouseMove, browsergegevenswissenx, browsergegevenswisseny
Click
Sleep, %Scriptsnelheid%

ImageSearch, periodex, periodey, 0, 0, A_ScreenWidth, A_ScreenHeight, periode.png
MouseMove, periodex, periodey
Click
Sleep, %Scriptsnelheid%

ImageSearch, altijdblauwx, altijdblauwy, 0, 0, A_ScreenWidth, A_ScreenHeight, altijdblauw.png
If Errorlevel = 0
    goto, jump
else if errorlevel = 1
    ImageSearch, altijdwitx, altijdwity, 0, 0, A_ScreenWidth, A_ScreenHeight, altijdwit.png
    MouseMove, altijdwitx, altijdwity
    Click
Jump:

Sleep, %Scriptsnelheid%
ImageSearch, gegevenswissenx, gegevenswisseny, 0, 0, A_ScreenWidth, A_ScreenHeight, gegevenswissen.png
Mousemove, gegevenswissenx, gegevenswisseny
Click
Sleep, %Scriptsnelheid%


return
esc::ExitApp

Solution

  • You're missing a return :)

    Information:
    MsgBox, 0, Information, More Information soon to be added
    RETURN ;<------- add this