Cancel a script by if-statement

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mr[Pepparkaka]
Posts: 3
Joined: 23 Apr 2018, 07:56

Cancel a script by if-statement

23 Apr 2018, 08:29

Hi!
I'm making a script that copies the value of a cell in Excel and pastes it into anther Excel file. The script ask you in a inputbox how many cells you wish to copy, and then does the work.
But here's the problem.
If i hit "cancel" or the" close (x)" in the inputbox that comes up, the Script still runs.
I tried to put in an if/else, but I cant make it work.
Basically, I only want the script to run if I put a number value, else I want it to exit the script. Can someone guide me in the right direction? Thanks.


Here's my code, a bit simplified.

Code: Select all

Script:																													
F12loop = 10																	

inputbox, count, Cells to copy, How many cells do you want to copy?								
Sleep, 3000								
			
 if (%count% > 0) {													
    sleep, 1500																									
		loop, %F12loop% {											
			send, `t											
			sleep, 100											
				}																								
			}
else {
    send, {ESC}
    }
    
    Escape::ExitApp
			
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Cancel a script by if-statement

23 Apr 2018, 09:26

read the inputbox docs, theres an example towards the bottom

also dont do this Send, {key} to trigger a hotkey to use a command
instead use the command directly

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Joey5, Proxima and 316 guests