How to stop script, if its intended task was already done?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SerioslyFrustrated
Posts: 3
Joined: 04 Aug 2022, 05:22

How to stop script, if its intended task was already done?

Post by SerioslyFrustrated » 08 Feb 2023, 04:25

so I have this script

Code: Select all

Run, "C:\Items List.xlsx"
Sleep, 180000
WinClose, A
unfortunately it closes what ever window happens to be open on screen

Is there any way to make it close the specific .xlsx file, after the time has passed? Also should the .xlsx file have been closed manually before the time ran out, have the script just stop?

User avatar
mikeyww
Posts: 26869
Joined: 09 Sep 2014, 18:38

Re: How to stop script, if its intended task was already done?

Post by mikeyww » 08 Feb 2023, 06:27

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33
book     := "test.xlsx"
winTitle := book " ahk_exe EXCEL.EXE"
Run % A_ScriptDir "\" book
Sleep 3000
WinClose % winTitle
Explained: WinTitle

Try v2.

Code: Select all

#Requires AutoHotkey v2.0
book     := "test.xlsx"
winTitle := book " ahk_exe EXCEL.EXE"
Run A_ScriptDir "\" book
Sleep 3000
Try WinClose winTitle

Post Reply

Return to “Ask for Help (v1)”