End Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ben the Coder

End Script

Post by Ben the Coder » 16 May 2022, 10:58

I have a script that I am trying to stop, but ExitApp and Return aren't working for me. It still keeps running in the background, doing nothing. Can anyone help me with this?
Thanks!

User avatar
boiler
Posts: 16772
Joined: 21 Dec 2014, 02:44

Re: End Script

Post by boiler » 16 May 2022, 11:00

ExitApp would always work, so the fact that it's not exiting means that your script isn't actually executing that line. You would have to show the details of your script so we can identify the issues with how it's structured and how the code flows.

Ben the Coder

Re: End Script

Post by Ben the Coder » 16 May 2022, 15:41

Wait...
I've figured out a solution! My script is working now!

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: End Script

Post by BoBo » 16 May 2022, 15:50

@Ben G - would you mind showing it?! ;)

Ben the Coder

Re: End Script

Post by Ben the Coder » 16 May 2022, 15:54

Sorry, do you want me to show my script?

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: End Script

Post by BoBo » 16 May 2022, 15:59

Yep, especially how you've solved your issue.

Ben the Coder

Re: End Script

Post by Ben the Coder » 16 May 2022, 16:11

The problem (for me) was that the script was running in the background, so when you went to re-open it sometime, it would put up a pop-up saying that there was a older version of this script running, and asking if I want to terminate the older one and run the new one. I "solved" this by adding the code:

Code: Select all

#SingleInstance Force
Here's my entire program below:

Code: Select all

#SingleInstance Force
MsgBox, Welcome to SimpleCalc!
InputBox, Firstnum, SimpleCalc, Enter first number.
InputBox, Secnum, SimpleCalc, Enter second number.

 ;Operator buttons below
Gui, -Caption +LastFound -SysMenu +ToolWindow -DPIScale
Gui, Font, s15
Gui, Add, Text,, Please enter operator:   
Loop, Parse,% "+,-,*,/,^", CSV
	Gui, Add, Button, x+ y20 gOperator,% A_LoopField
Gui, Show
Return
Operator:
Operator := StrReplace(A_GuiControl, "&&", "&")
Gui, Destroy
Switch, Operator
{
Case "+":Result := Firstnum + Secnum
; ...
Case "*":Result := Firstnum * Secnum
; ...
Case "-":Result := Firstnum - Secnum
; ...
Case "/":Result := Firstnum / Secnum
; ...
Case "^":Result := Firstnum ** Secnum
}
MsgBox,% "The answer is: " Result
MsgBox, 4,, Would you like to start another session?
IfMsgBox Yes
	Run, SimpleCalc.exe
else
    Sleep, 10000
    return
return
return
ExitApp [, ExitCode]
Thanks so much everyone!

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: End Script

Post by BoBo » 16 May 2022, 16:35

Congrats to you for solving this on your own! :thumbup:

Post Reply

Return to “Ask for Help (v1)”