Skip to content

Instantly share code, notes, and snippets.

@valuex
Created August 3, 2023 11:55
Show Gist options
  • Save valuex/90885a1bfecc4246d3523df9530cde5a to your computer and use it in GitHub Desktop.
Save valuex/90885a1bfecc4246d3523df9530cde5a to your computer and use it in GitHub Desktop.
Send Message to Total Commander
; Script name: SendTCCommand.ahk
; Sends a Total Commander command to a TC instance.
; Can be used from the scheduler for example.
; Specify the TC command as command line parameter for example:
; AutoHotkey.exe SendTCCommand.ahk cm_FtpNew
; Or if the script is compiled:
; SendTCCommand.exe cm_FtpNew
sCmdParam := %1%
SendTCCommand( sCmdParam )
Return
;
; SendTCCommand 0.2
;
; Function purpose:
; Sends a Total Commander internal command to a TC instance.
; It can be used to automate Total Commander.
;
; Parameters:
; xsTCCommand: The Total Commander internal command, see the list here:
; %COMMANDER_PATH%\TOTALCMD.INC
; xbWait: Whether to wait for the command to execute,
; or just post it and return.
;
; Usage example:
; SendTCCommand( "cm_RereadSource", False )
;
SendTCCommand( xsTCCommand, xbWait:=1 )
{
loop Read COMMANDER_PATH . "TOTALCMD.INC"
{
asCommands:=StrSplit(A_LoopReadLine,"=")
if (asCommands[1] = xsTCCommand)
{
asCommandsValues:=StrSplit(asCommands[2],";")
Break
}
}
if !(asCommandsValues[1] > 0)
return
if (xbWait)
SendMessage(1075, asCommandsValues[1], 0, , "ahk_class TTOTAL_CMD")
else
PostMessage( 1075, asCommandsValues[1], 0, , "ahk_class TTOTAL_CMD")
}
@dvygolov
Copy link

Is this for Autohotkey v2?

@valuex
Copy link
Author

valuex commented Oct 28, 2023

Is this for Autohotkey v2?

Yes. You can tell it by the syntax of Sendmessage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment