DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: ReRun - Run a program repeatedly on hotkey  (Read 8,766 times)

Boyce

  • Participant
  • Joined in 2021
  • *
  • Posts: 1
ReRun - Run a program repeatedly on hotkey
« on: July 23, 2021, 05:13 AM »
When a certain hotkey is pressed, ReRun asks you for a program and runs it. From then on, everytime this hotkey is pressed, the program is run again.

This is useful if you working to improve a script/ ahk file / batch file and need to test it repeatedly, or are needing to manually compile/deploy/run commands repeatedly. Using rerun is faster than finding the active window and clicking on a program to launch it.

Code: ( cpp)
; Change line 6 to a new hotkey: see http://www.autohotkey.com/docs/Hotkeys.htm#symbols
 
#NoEnv 
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
§::
if program =
        FileSelectFile, program, 3, , Open a file, Programs (*.bat; *.com; *.exe)
if program <>  
{
        SplitPath, program ,, OutDir
        SetWorkingDir %OutDir% 
        RunWait, %program%
}
return

Note: the default hotkey is §, which is handy if you have a mac uk keyboard, but annoying if you don't. So change the start of line 5.

Mod Note: though the poster turned out to be a spammer, the script might be of use to someone.
« Last Edit: July 24, 2021, 02:08 PM by wraith808 »

Original address: https://www.donationcoder.com/forum/index.php?topic=51593.0