Инструменты пользователя

Инструменты сайта


en:autorun:documentation:tweaks_setmessageaction

SetMessageAction

SetMessageAction [/P] <msg/msgname> <cmd> [params]

The command performs actions for the specified message sent to the Total Commander window.

Parameters

<msg>
<msgname>
The numeric value of the message number, or a string for registering a custom message number.
<cmd>Autorun internal command or custom function.
<params>Command parameters (if applicable). Parameters are passed «as is», calculated parameters are calculated each time the command is called.

Switches

/POptional. When the switch is set, the four parameters passed in the message will be added to the available command parameters: hWnd, uMsg, wParam и lParam.

Remarks

First of all, the command is intended to execute a user-defined function when sending a message to the Total Commander window from external sources. The command only performs actions when a message arrives, but does not block or change it in any way. Thus, although it can also be used to set an action on a system message, the inability to block its further execution or obtain data from accompanying structures greatly limits the scope of the command.

It is strongly recommended to use only user messages with numbers greater than or equal to 0x400 (WM_USER), in this case the function does not check message numbers in the range reserved by the system, which speeds up the work. Use handlers for reserved system messages only if you really need to and if you know exactly what you are doing, as this can slow down or even break Total Commander.

Example

Code in Autorun configuration:

# The function to be executed when the message is received
Func MyMessageFunc()
  MsgBox "The message is received"
EndFunc
 
# Bind the function to the message logged by the string "MyMessage"
SetMessageAction "MyMessage" MyMessageFunc
 
# You can bind to a fixed number, but this option is less reliable,
# since a randomly chosen message number may intersect
# with already used
SetMessageAction 55555 MyMessageFunc

Script in Autoit, calling the function «MyMessageFunc» via the registered number:

; Register the message specified by the string "MyMessage"
$nMsg = DllCall("user32", "uint", "RegisterWindowMessageW", "wstr", "MyMessage")[0]
; Find the Total Commander window
$hWnd = WinGetHandle("[CLASS:TTOTAL_CMD]")
; Sending a registered message to the Total Commander window
DllCall("user32", "lresult", "SendMessageW", "hwnd", $hWnd, _
                                             "uint", $nMsg, _
                                             "wparam", 0, _
                                             "lparam", 0)

Call using utility TCFS2 by fixed number:

TCFS2.exe /ef "msg(55555, 0, 0)"
en/autorun/documentation/tweaks_setmessageaction.txt · Последнее изменение: 2022/09/26 15:01 — loopback

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki