! test.ahk -_- run scripts and execute script lines with CTRL + R

[test.ahk]  [test.zip]   -_-  AutoHotKey exeS [ ahk_L.exe ] [ basic ahk.exe ]

With the test.ahk you can execute easily single line actions i.e run url, run path\, msgbx  + .....  lines and even some complexe scripts, without saving the line(s)  or the script.


TO DO • highlight the code line(S) • [CTRL] + [R]

The main purpose from the "test.ahk" code was it to test  in the Autohotkey forums published scripts.

The following code requires AutoHotKey installed, otherwise the "open with" dialog box will appear → select open with 1.exe

ctrl & r:: ; trigger CTRL + R
ClipSave := ClipboardAll ; saves the clipboard content
Clipboard = ;empties the clipboard
Send ^c ; copy
clipwait 2
Clipboard .= "`nesc::ExitApp" ; adds an exit function via the [Esc] key
ToolTip, %Clipboard% ; displays the script in a tooltip
FileDelete %A_Temp%\~temp.ahk
FileAppend , %Clipboard%, %A_Temp%\~temp.ahk
Run %A_Temp%\~temp.ahk ;. ahk needs to be associatet with an AutoHotKey.exe
Clipboard := ClipSave ; restores the clipboard
Sleep 5000
ToolTip ; deletes the ToolTip

ADDED: an C:\1.exe path, if AutoHotKey is not installed ▼

if you want you can remove from the code
•the 3 blue tooltip lines
•the 3 lines ¹clipboard = ²Clipboard := ClipSave ³ClipSave := ClipboardAll
•the line Clipboard .= "`nesc::ExitApp"

The same script with german comments and an additional line, which makes it more convenient to test multiple scripts or to execute script lines

ctrl & r:: ; hotkeys Strg + R
ClipSave := ClipboardAll ; sichern der Zwischenablage
Clipboard =
Send ^c ;Kopiert den Code
clipwait 2 ;Wartezeit ist notwendig zum "Reinladen" des Textes
Clipboard .= "`nesc::ExitApp" ;anhängen einer Abbruch-Funktion mit dem Hotkey "Esc"
ToolTip, %Clipboard% ;Anzeigen des zu startenden Scripts
FileDelete %A_Temp%\~temp.ahk
FileAppend , #singleinstance force`n, %A_Temp%\~temp.ahk
FileAppend , %Clipboard%, %A_Temp%\~temp.ahk
Run %A_Temp%\~temp.ahk ;.ahk muss natürlich mit autohotkey.exe verknüpft sein
Clipboard := ClipSave
Sleep 5000
ToolTip ;ToolTip löschen

without the "add #singleinstance force" line the running ~temp.ahk will alert you always that the "script" is running. You will save one click or to exit the running "~tmp.ahk" script via [esc]

You can exit a test.ahk file via the H tray rightclick menu.
Other menu entries: edit, reload, suspend the shortcut, pause. The Help entry requiers the autohotkey.cfm in the AutoHotKey directory, if created via an autohotkey installer.

Leave a Reply