How to exit AHK Script after Programm ends Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
need4speed
Posts: 143
Joined: 22 Apr 2016, 06:50

How to exit AHK Script after Programm ends

05 Jun 2018, 14:19

I have created a small script to colorize cells in Excel

Code: Select all

#SingleInstance, Force
SetTitleMatchMode, 2
#IfWinActive Excel
    F1::
        Send, !HH
        Send, {Tab 23}
        Send, {Enter}
    return
    F2::
        Send, !HH
        Send, {Tab 9}
        Send, {Enter}
    return  
#IfWinActive
I like to have the script exit automatically after Excel is closed manually.
Please provide some hint/code for this task. Thank You.
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: How to exit AHK Script after Programm ends  Topic is solved

05 Jun 2018, 14:54

ExitApp closes AHK. The thing is - how to determine Excel has closed? I would suggest SetTimer every minute or something to see if WinExist, and if it doesn't - see first sentence.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
need4speed
Posts: 143
Joined: 22 Apr 2016, 06:50

Re: How to exit AHK Script after Programm ends

05 Jun 2018, 15:02

thanks all and please forgive me my laziness.

a simple check does the trick.

Code: Select all

#Persistent
SetTimer, CheckExcelRunning, 1000

CheckExcelRunning:
Process, Exist, EXCEL.EXE
if(!errorlevel)
    ExitApp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: GEOVAN and 271 guests