Search code examples
autohotkeymsgbox

Autohotkey: MsgBox "Done" after Run


I have a python script I want ran on a shortcut key, but I want the Msgbox to tell me it's done once it finishes. How do I do that?

I've tried putting the MsgBox, Done in different places like so

F8::Runwait, C:\python36\python.exe  "C:\Users\jason\Google Drive\pycharm\test.py"; 
MsgBox, Done
F9::Run, C:\python36\python.exe  "C:\Users\jason\Google Drive\pycharm\test1.py"; 
MsgBox, Done1

Didn't see any examples of this in the Run or MsgBox section of the docs.

Would like a "Done" after any hotkeys are executed.


Solution

  • Could you just use RunWait instead of Run so the program waits for the script to finish before it continues? Also you need to use the multi-line hotkey syntax if you want multiple lines to execute. Below is an edited version of your script:

    F8::
        RunWait, C:\python36\python.exe  "C:\Users\jason\Google Drive\pycharm\test.py"; 
        MsgBox, Done
        Return
    
    F9::
        RunWait, C:\python36\python.exe  "C:\Users\jason\Google Drive\pycharm\test1.py"; 
        MsgBox, Done1
        Return
    

    Please note that if your python script starts another process, your AutoHotkey script will not wait on that second process.