FAQs: automate/script TC with AutoHotkey AHK
Moderators: white, Hacker, petermad, Stefan2
FAQs: automate/script TC with AutoHotkey AHK
AutoHotkey and Total Commander
Also see our wiki and search for "autohotkey"
https://www.ghisler.ch/wiki/index.php?title=Main_Page
https://www.ghisler.ch/wiki/index.php?title=AutoHotkey
https://www.ghisler.ch/wikide/index.php/AutoHotkey
- - - English
AutoHotkey is a small, portable freeware tool to automate many things in WindowsTM.
For example: Click a Button, manipulate text, access clipboard, read or write files.
See "AutoHotkey – Wikipedia" > https://en.wikipedia.org/wiki/AutoHotkey
We use often AutoHotkey to "extend" Total Commander.
Download the file "AutoHotkey.zip" from https://autohotkey.com/download/
Please also note the Documentation > https://autohotkey.com/docs/AutoHotkey.htm
Beginner Tutorial AutoHotkey v2 by tidbit > https://lexikos.github.io/v2/docs/Tutorial.htm
Beginner Tutorial AutoHotkey by tidbit > https://autohotkey.com/docs/Tutorial.htm
- - -
If you have AutoHotkey installed, you can just double click the script.ahk file from every where.
Or you can just unpack the downloaded "AutoHotkey.zip" and use the exe as standalone portable.
Use it then in that way, open a cmd console window and type:
"D:\rive\Path to\AHK\AutoHotkey.exe" "D:\rive\Path to\your script.ahk"
Or put the script.ahk into the AHK folder, open a cmd console window and type:
AutoHotkey.exe "your script.ahk"
If you utilize AutoHotkeyU64.exe or AutoHotkeyU32.exe or AutoHotkey.exe doesn't matter here.
If in forum is mentioned a "AutoHotkey.exe" which you don't find, then just use "AutoHotkeyU32.exe" instead.
I like to unpack die ZIP-Archive to a folder called "AHK" inside of your Total Commander folder. So it is all portable.
- - -
For scripts is could be important to utilize die right Exe-Version (1.0.x -or- 1.1.x)
There is a older AutoHotkey version, Version 1.0, "classic" or "basic" (the last was 1.0.48.05 from 2013)
And there is a newer one with version always start with 1.1.x, like "AutoHotkey_1.1.30.00.zip"
- - -
If you are provided with a script to solve your problem, use it this way:
- Create a new text file in folder "Total Commander\AHK\new.ahk"
- Copy and paste the script into this "new.ahk" file and save it.
-----Example script: MsgBox HEY, that really works! ;-)
- Execute that script (as temporary solution, as an test):
--- Change to "Total Commander\AHK\" folder
------ Either:
Drag&Drop the AutoHotkey.exe on the Button bar.
Drag now the file "new.ahk" on the new created button.
------ Or :
Type 'AutoHotkey new.ahk' in TC-command line
(or launch a black CMD command line window)
(Please note, in the message box that Smiley is not displayed, because the semi-colon is the line comment sign of AHK)
To create a button for that script, which can work on any place,
not only in the AHK-folder, we need to use full paths to Exe and script.
--------------------------------------
Command: "AHK\AutoHotkey.exe" "AHK\neue.ahk"
Parameters: << leave empty, or as advised in forum >>
Start path: << leave empty, or as advised in forum >>
Icon file : "AHK\AutoHotkey.exe" <or WCMICONS.DLL>
Tooltip : What does this button|Line break|Another new line
--------------------------------------
- - - Deutsch
AutoHotkey ist ein kleines, portables Freeware Tool, um viele Dinge in WindowsTM zu automatisieren.
Zum Beispiel: Klicke einen Button, manipuliere Text, greife auf die Zwischenablage zu, lese oder schreibe Dateien.
Siehe "AutoHotkey – Wikipedia" > https://de.wikipedia.org/wiki/AutoHotkey
Wir benutzen oftmals AutoHotkey um den Total Commander zu "erweitern".
Lade dir die Datei "AutoHotkey.zip" von https://autohotkey.com/download/ herunter.
Beachte auch die Documentation > https://autohotkey.com/docs/AutoHotkey.htm
AutoHotkey Anfänger-Tutorial von tidbit > https://ahkde.github.io/docs/Tutorial.htm
Kurze Einführung in Autohotkey (mit Beispielen) > https://office-tipps.net/kleine-einfuehrung-in-autohotkey-mit-beispielen/
Entpacke das ZIP-Archiv in einen Ordner Namnes "AHK" in deinen Total Commander-Ordner.
Wenn im Forum auf "AutoHotkey.exe" verwiesen wird und du diese nicht findest, dann verwende einfach die Datei "AutoHotkeyU32.exe".
Bei Skripten kann es wichtig sein, die korrekte Exe-Version (1.0.x -oder- 1.1.x) zu verwenden.
Von AutoHotkey gibt es eine ältere "classic" oder "basic" versions als Version 1.0 (die Letzte war 1.0.48.05 von 2013)
Das neuere AutoHotkey hat immer eine Version 1.1.x, wie zB "AutoHotkey_1.1.30.00.zip"
Wenn dir ein AHK-Skript zur Lösung deines Problems angeboten wird, verwende es folgendermaßen:
- Erstelle eine neue Textdatei im Ordner "Total Commander\AHK\neue.ahk"
- Kopiere das Skript in die Datei "neue.ahk" und speichere diese.
-----Beispielsskript: MsgBox HEY, das klappt ja! ;-)
- Führe das Skript aus (als vorläufige Lösung, als Test):
--- Wechsel in den Ordner "Total Commander\AHK\"
----- Entweder:
Drag&Drop die AutoHotkey.exe auf die Buttonbar.
Ziehe dann die Datei "neue.ahk" auf den eben erstellten Button.
----- Oder:
Tippe 'AutoHotkey neue.ahk' in die TC-Kommandozeile ein
(oder öffne ein schwarzes CMD Kommandozeilen Fenster)
(Beachte das das Smiley in der Messagebox nicht angezeigt wird, weil das Semikolon das "Kommentarzeichen" bei AHK ist)
Um mit dem Skript einen Button zu erstellen, welcher überall funktionieren soll,
und nicht nur im aktuellen AHK-Ordner, benötigen wir die kompletten Pfade zur Exe und zum Skript.
--------------------------------------
Kommando: "AHK\AutoHotkey.exe" "AHK\neue.ahk"
Parameter: << leer lassen, oder wie im Forum angegeben >>
Startpfad:
Icondatei: "AHK\AutoHotkey.exe" <oder WCMICONS.DLL>
Tooltip : Was macht dieser Button|hier Zeilenumbruch|erneuter Umbruch
--------------------------------------
- - - the files / die Dateien
AutoHotkey_1.1.30.00.zip (22-Aug-2018)
Compiler\
Installer.ahk
AutoHotkey.chm
AutoHotkeyA32.exe ANSI, 32-bit, also for 64-bit OS (800byte)
AutoHotkeyU64.exe Unicode, 64-bit, for 64-bit OS only and not really needed (for us). (1200b)
AutoHotkeyU32.exe Unicode, 32-bit, also for 64-bit OS (900b)
WindowSpy.ahk
license.txt
Template.ahk
AutoHotkey104805_v1.0.48.05.zip (30-Sep-2013)
AutoScriptWriter\
Compiler\
Extras\
AU3_Spy.exe
AutoHotkey.chm
AutoHotkey.exe (250byte)
AutoHotkey Website.url
license.txt
Also see our wiki and search for "autohotkey"
https://www.ghisler.ch/wiki/index.php?title=Main_Page
https://www.ghisler.ch/wiki/index.php?title=AutoHotkey
https://www.ghisler.ch/wikide/index.php/AutoHotkey
- - - English
AutoHotkey is a small, portable freeware tool to automate many things in WindowsTM.
For example: Click a Button, manipulate text, access clipboard, read or write files.
See "AutoHotkey – Wikipedia" > https://en.wikipedia.org/wiki/AutoHotkey
We use often AutoHotkey to "extend" Total Commander.
Download the file "AutoHotkey.zip" from https://autohotkey.com/download/
Please also note the Documentation > https://autohotkey.com/docs/AutoHotkey.htm
Beginner Tutorial AutoHotkey v2 by tidbit > https://lexikos.github.io/v2/docs/Tutorial.htm
Beginner Tutorial AutoHotkey by tidbit > https://autohotkey.com/docs/Tutorial.htm
- - -
If you have AutoHotkey installed, you can just double click the script.ahk file from every where.
Or you can just unpack the downloaded "AutoHotkey.zip" and use the exe as standalone portable.
Use it then in that way, open a cmd console window and type:
"D:\rive\Path to\AHK\AutoHotkey.exe" "D:\rive\Path to\your script.ahk"
Or put the script.ahk into the AHK folder, open a cmd console window and type:
AutoHotkey.exe "your script.ahk"
If you utilize AutoHotkeyU64.exe or AutoHotkeyU32.exe or AutoHotkey.exe doesn't matter here.
If in forum is mentioned a "AutoHotkey.exe" which you don't find, then just use "AutoHotkeyU32.exe" instead.
I like to unpack die ZIP-Archive to a folder called "AHK" inside of your Total Commander folder. So it is all portable.
- - -
For scripts is could be important to utilize die right Exe-Version (1.0.x -or- 1.1.x)
There is a older AutoHotkey version, Version 1.0, "classic" or "basic" (the last was 1.0.48.05 from 2013)
And there is a newer one with version always start with 1.1.x, like "AutoHotkey_1.1.30.00.zip"
- - -
If you are provided with a script to solve your problem, use it this way:
- Create a new text file in folder "Total Commander\AHK\new.ahk"
- Copy and paste the script into this "new.ahk" file and save it.
-----Example script: MsgBox HEY, that really works! ;-)
- Execute that script (as temporary solution, as an test):
--- Change to "Total Commander\AHK\" folder
------ Either:
Drag&Drop the AutoHotkey.exe on the Button bar.
Drag now the file "new.ahk" on the new created button.
------ Or :
Type 'AutoHotkey new.ahk' in TC-command line
(or launch a black CMD command line window)
(Please note, in the message box that Smiley is not displayed, because the semi-colon is the line comment sign of AHK)
To create a button for that script, which can work on any place,
not only in the AHK-folder, we need to use full paths to Exe and script.
--------------------------------------
Command: "AHK\AutoHotkey.exe" "AHK\neue.ahk"
Parameters: << leave empty, or as advised in forum >>
Start path: << leave empty, or as advised in forum >>
Icon file : "AHK\AutoHotkey.exe" <or WCMICONS.DLL>
Tooltip : What does this button|Line break|Another new line
--------------------------------------
- - - Deutsch
AutoHotkey ist ein kleines, portables Freeware Tool, um viele Dinge in WindowsTM zu automatisieren.
Zum Beispiel: Klicke einen Button, manipuliere Text, greife auf die Zwischenablage zu, lese oder schreibe Dateien.
Siehe "AutoHotkey – Wikipedia" > https://de.wikipedia.org/wiki/AutoHotkey
Wir benutzen oftmals AutoHotkey um den Total Commander zu "erweitern".
Lade dir die Datei "AutoHotkey.zip" von https://autohotkey.com/download/ herunter.
Beachte auch die Documentation > https://autohotkey.com/docs/AutoHotkey.htm
AutoHotkey Anfänger-Tutorial von tidbit > https://ahkde.github.io/docs/Tutorial.htm
Kurze Einführung in Autohotkey (mit Beispielen) > https://office-tipps.net/kleine-einfuehrung-in-autohotkey-mit-beispielen/
Entpacke das ZIP-Archiv in einen Ordner Namnes "AHK" in deinen Total Commander-Ordner.
Wenn im Forum auf "AutoHotkey.exe" verwiesen wird und du diese nicht findest, dann verwende einfach die Datei "AutoHotkeyU32.exe".
Bei Skripten kann es wichtig sein, die korrekte Exe-Version (1.0.x -oder- 1.1.x) zu verwenden.
Von AutoHotkey gibt es eine ältere "classic" oder "basic" versions als Version 1.0 (die Letzte war 1.0.48.05 von 2013)
Das neuere AutoHotkey hat immer eine Version 1.1.x, wie zB "AutoHotkey_1.1.30.00.zip"
Wenn dir ein AHK-Skript zur Lösung deines Problems angeboten wird, verwende es folgendermaßen:
- Erstelle eine neue Textdatei im Ordner "Total Commander\AHK\neue.ahk"
- Kopiere das Skript in die Datei "neue.ahk" und speichere diese.
-----Beispielsskript: MsgBox HEY, das klappt ja! ;-)
- Führe das Skript aus (als vorläufige Lösung, als Test):
--- Wechsel in den Ordner "Total Commander\AHK\"
----- Entweder:
Drag&Drop die AutoHotkey.exe auf die Buttonbar.
Ziehe dann die Datei "neue.ahk" auf den eben erstellten Button.
----- Oder:
Tippe 'AutoHotkey neue.ahk' in die TC-Kommandozeile ein
(oder öffne ein schwarzes CMD Kommandozeilen Fenster)
(Beachte das das Smiley in der Messagebox nicht angezeigt wird, weil das Semikolon das "Kommentarzeichen" bei AHK ist)
Um mit dem Skript einen Button zu erstellen, welcher überall funktionieren soll,
und nicht nur im aktuellen AHK-Ordner, benötigen wir die kompletten Pfade zur Exe und zum Skript.
--------------------------------------
Kommando: "AHK\AutoHotkey.exe" "AHK\neue.ahk"
Parameter: << leer lassen, oder wie im Forum angegeben >>
Startpfad:
Icondatei: "AHK\AutoHotkey.exe" <oder WCMICONS.DLL>
Tooltip : Was macht dieser Button|hier Zeilenumbruch|erneuter Umbruch
--------------------------------------
- - - the files / die Dateien
AutoHotkey_1.1.30.00.zip (22-Aug-2018)
Compiler\
Installer.ahk
AutoHotkey.chm
AutoHotkeyA32.exe ANSI, 32-bit, also for 64-bit OS (800byte)
AutoHotkeyU64.exe Unicode, 64-bit, for 64-bit OS only and not really needed (for us). (1200b)
AutoHotkeyU32.exe Unicode, 32-bit, also for 64-bit OS (900b)
WindowSpy.ahk
license.txt
Template.ahk
AutoHotkey104805_v1.0.48.05.zip (30-Sep-2013)
AutoScriptWriter\
Compiler\
Extras\
AU3_Spy.exe
AutoHotkey.chm
AutoHotkey.exe (250byte)
AutoHotkey Website.url
license.txt
Re: FAQs: automate/script TC with AutoHotkey AHK
Hi Stefan2!
The latest version is v1.1.30.01 - November 11, 2018 (From https://www.autohotkey.com/download/)
The latest version is v1.1.30.01 - November 11, 2018 (From https://www.autohotkey.com/download/)
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
#259941, TC 11.01 x64, Windows 7 SP1 x64
- ghisler(Author)
- Site Admin
- Posts: 48124
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: FAQs: automate/script TC with AutoHotkey AHK
I welcome these FAQ threads. However, I would appreciate if you could also update the Wiki pages directly. You can log in to the Wiki with your forum user name and password! Thanks.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: FAQs: automate/script TC with AutoHotkey AHK
Hi,
I'd be happy if there was a basic documentation/wiki page on how to get the control's texts and names and which tools are used to build a ahk script efficiently. (window spy is not enough)
There are many example scripts in the wiki but no documentation inside them on how the author extracted this or that control (only window classes are not enough in most cases)
Thanks
I'd be happy if there was a basic documentation/wiki page on how to get the control's texts and names and which tools are used to build a ahk script efficiently. (window spy is not enough)
There are many example scripts in the wiki but no documentation inside them on how the author extracted this or that control (only window classes are not enough in most cases)
Thanks
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64
Re: FAQs: automate/script TC with AutoHotkey AHK
aviasd,
It's arcane knowledge passed between generations of mighty wizards, only referred to in the ancient book of History.txt:
Roman
It's arcane knowledge passed between generations of mighty wizards, only referred to in the ancient book of History.txt:
HTH08.06.16 Release Total Commander 9.0 beta 1 (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1011/1012 to get index of first file in list (-1 if there are no files) (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1009/1010 to get index of first item (0 if there is no updir, 1 otherwise) (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1007/1008 to get index of current item (caret) (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1005/1006 to get total number of selected items (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1003/1004 to get total number of items (including those hidden by quick filter (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1001/1002 to get number of items in left/right list (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1000 to get active panel: 1=left, 2=right (32/64)
08.06.16 Added: Send WM_USER+50 with wparam=1..29 -> returns window handle of control. Controls are: 1=leftlist, 2=rightlist, 3=active list, 4=inactive list, 5=leftheader, 6=rightheader, 7=leftsize, 8=rightsize, 9=leftpath, 10=rightpath, 11=leftinfo, 12=rightinfo, 13=leftdrives, 14=rightdrives, 15=leftpanel, 16=rightpanel, 17=bottompanel, 18=lefttree, 19=righttree, 20=cmdline, 21=curdirpanel, 22=inplaceedit, 23=splitpanel, 24=leftdrivepanel, 25=rightdrivepanel, 26=lefttabs, 27=righttabs, 28=buttonbar, 29=buttonbarvertical (32/64)
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Re: FAQs: automate/script TC with AutoHotkey AHK
LOL
Indeed, hidden knowledge and sacred relics can be found in the book of history
Alas, these spells are too advanced for me. I just needed to get the control names and it turns out au3_spy.exe actually does it out of the box.
Cheers
Indeed, hidden knowledge and sacred relics can be found in the book of history
Alas, these spells are too advanced for me. I just needed to get the control names and it turns out au3_spy.exe actually does it out of the box.
Cheers
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64
Re: FAQs: automate/script TC with AutoHotkey AHK
I had the same question:
TC9: "Send WM_USER+50 with wparam" - how-to?
viewtopic.php?t=44451
Just some basics, tests and examples.
Read the History.txt and search the forum for WM_USER or AutoHotkey to collect your own knowledge.
Also there is the wiki > https://www.ghisler.ch/wiki/index.php/AutoHotkey
A more complete documentation I tried to collect from others right now in German language only:
Post 5 - TC von außen steuern / SendMessage / WM_USER
viewtopic.php?p=346996#p346996
Re: FAQs: automate/script TC with AutoHotkey AHK
aviasd,
HTH
Roman
Alas, these spells are too advanced for me. I just needed to get the control names
Code: Select all
; WM_USER+50 = 1074
; "bottom panel" (i.e. path string left of command line) based on history.txt = 17
SendMessage, 1074, 17
HandleOfBottomPanel = %ErrorLevel%
WinGetText, PathInTC, ahk_id %HandleOfBottomPanel%
MsgBox, Active path in TC = %PathInTC%
Be aware that the control names differ between TC 32-bit and 64-bit, and AFAIR they are not even consistent between instances of TC 64-bit as they are generated dynamically upon each program start.au3_spy.exe actually does it out of the box
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Re: FAQs: automate/script TC with AutoHotkey AHK
2Stefan2
Thanks for that! That is indeed enough info to get me started with Windows Messages+TC , and thanks to google translate, even the German page is useful
2Roman
The Send message method seems to be much more seamless way of interacting with exact window handles and also nice to be able to send wm_commands via script.
My use case is actually much more simple:
I'm working on a script to detect all file copy errors and clicking on skip all automatically - I cannot get SkippedFileCopy option to work and this is a hackish attempt at it.
It's not even a control - it's a new window with separate class.
Since it looks like you have a lot of experience with AHK+TC - maybe you know how to detect the text in file dialog errors (ahk_class TExtMsgForm) - ahk detects only the buttons and not text (even with DetectHiddenText,on) - and I want to target specific errors like "Access denied" etc, not all errors - that info is available as part of the error dialog window text which ahk does not detect..
Sorry if I got off topic...
Thanks for that! That is indeed enough info to get me started with Windows Messages+TC , and thanks to google translate, even the German page is useful
2Roman
Yes, I was wondering exactly that since I never encountered inconsistencies with control names, But maybe I was using 32bit apps back then.Be aware that the control names differ between TC 32-bit and 64-bit, and AFAIR they are not even consistent between instances of TC 64-bit as they are generated dynamically upon each program start.
The Send message method seems to be much more seamless way of interacting with exact window handles and also nice to be able to send wm_commands via script.
My use case is actually much more simple:
I'm working on a script to detect all file copy errors and clicking on skip all automatically - I cannot get SkippedFileCopy option to work and this is a hackish attempt at it.
It's not even a control - it's a new window with separate class.
Since it looks like you have a lot of experience with AHK+TC - maybe you know how to detect the text in file dialog errors (ahk_class TExtMsgForm) - ahk detects only the buttons and not text (even with DetectHiddenText,on) - and I want to target specific errors like "Access denied" etc, not all errors - that info is available as part of the error dialog window text which ahk does not detect..
Sorry if I got off topic...
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64
Re: FAQs: automate/script TC with AutoHotkey AHK
aviasd,
Roman
What would be the easiest way to provoke such a dialog to test on my own?maybe you know how to detect the text in file dialog errors (ahk_class TExtMsgForm) - ahk detects only the buttons and not text (even with DetectHiddenText,on) - and I want to target specific errors like "Access denied" etc, not all errors - that info is available as part of the error dialog window text which ahk does not detect
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Re: FAQs: automate/script TC with AutoHotkey AHK
Open a pdf file in foxit or adobe and then try to overwrite it with F5 from the other panel
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64
Re: FAQs: automate/script TC with AutoHotkey AHK
aviasd,
Amazing. No idea why the text cannot be read. Christian?
Roman
Amazing. No idea why the text cannot be read. Christian?
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
- ghisler(Author)
- Site Admin
- Posts: 48124
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: FAQs: automate/script TC with AutoHotkey AHK
TExtMsgForm is a Delphi form. Delphi/Lazarus uses text without window handle for plain text fields (static text).
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com