Trying to make an Autohotkey script that works with TC

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
metaforce
Junior Member
Junior Member
Posts: 8
Joined: 2016-04-02, 23:28 UTC

Trying to make an Autohotkey script that works with TC

Post by *metaforce »

I'm trying to make an Autohotkey script that activates the Multi Rename Tool and then loads a certain setting when the number of files in the active folder in TC is below 1000 and another setting if the number is over (and including) 1000.

This is what I wrote so far but it doesn't work:

Code: Select all

#IfWinActive, ahk_class TTOTAL_CMD
F1::
; get the active folder path from TC
ControlGetText sPath, TMyPanel2

; send ctrl m to activate Multi Rename Tool
Send, ^m

Sleep, 100

; get the number of files
NumberOfFiles = % ComObjCreate("Scripting.FileSystemObject").GetFolder(sPath).Files.Count

; send F2 to select a setting from the multi rename tool window
Send, {F2}

if (NumberOfFiles > 999) {
Send, 4
}
else {
Send, 3
}
Return
#IfWinActive
Anyone knowing AHK could help me?
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

Please be aware that the 64bit version of TC uses different window class names than the 32bit version. Thus, your AutoHotScript as it is now will not work for both 32bit and 64bit versions of TC.

Anyway, i did a quick check with AutoHotKey's Window Spy and the 32bit version of TC.

I guess you want to get the path string from the label left of the command line, right? If so, try querying TMyPanel3 (TMyPanel2 is just the parent container of this label, hence querying TMyPanel2 will get you no text). Note that the string contains a ">" as last character which you have to remove before passing the string to the GetFolder() function...
metaforce
Junior Member
Junior Member
Posts: 8
Joined: 2016-04-02, 23:28 UTC

Post by *metaforce »

elgonzo wrote:Please be aware that the 64bit version of TC uses different window class names than the 32bit version. Thus, your AutoHotScript as it is now will not work for both 32bit and 64bit versions of TC.

Anyway, i did a quick check with AutoHotKey's Window Spy and the 32bit version of TC.

I guess you want to get the path string from the label left of the command line, right? If so, try querying TMyPanel3 (TMyPanel2 is just the parent container of this label, hence querying TMyPanel2 will get you no text). Note that the string contains a ">" as last character which you have to remove before passing the string to the GetFolder() function...
I'm using a 32bit version of TC. Thanks for the hint about AutoHotKey's Window Spy. I replaced the TMyPanel2 with TMyPanel3 and added StringMid sPath, sPath, 1, StrLen(sPath) -1 and it worked.

Here's the final version of the code for anyone interested:

Code: Select all

#IfWinActive, ahk_class TTOTAL_CMD

; Multi-rename files
F1::
ControlGetText sPath, TMyPanel3
StringMid sPath, sPath, 1, StrLen(sPath) -1

Send, ^m
Sleep, 100

NumberOfFiles = % ComObjCreate("Scripting.FileSystemObject").GetFolder(sPath).Files.Count
Send, {F2}

if (NumberOfFiles > 999) {
  Send, 4
}
else {
  Send, 3
}

Sleep, 100
Send, !o

Return
#IfWinActive
Post Reply