AutoHotkey: Send a user command to Total Commander: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
/*
Script Name: SendTCUserCommand.ahk
; Script Name: SendTCUserCommand.ahk
AutoHotkey 版本: 1.1.2.3
; AutoHotkey 版本: 1.1.2.3
操作系统:    Windows XP
; 操作系统:    Windows XP
作者:        sunwind <1576157@qq.com>  
; 作者:        sunwind <1576157@qq.com>  
博客:        http://blog.csdn.net/liuyukuan
; 博客:        http://blog.csdn.net/liuyukuan
脚本说明:此工具用来发送TC用户命令。
; 脚本说明:此工具用来发送TC用户命令。
脚本版本:  v1.0
; 脚本版本:  v1.0
*/


;~ 需要Total Commander 的usercmd.ini文件中定义好用户命令,比如em_openDefaultTab
;~ [em_openDefaultTab]
;~ button=
;~ cmd=OPENTABS %COMMANDER_PATH%\tab\!!!.tab


#1::  ;TEST
  SendTCUserCommand("em_openDefaultTab")
Return


SendTCUserCommand(Command) ; string
; 需要Total Commander 的usercmd.ini文件中定义好用户命令,比如em_openDefaultTab
  {
; [em_openDefaultTab]
    If  Command <>
; button=
      {
; cmd=OPENTABS %COMMANDER_PATH%\tab\!!!.tab
        VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)  ; Set up the structure's memory area.
 
        dwData := Asc("E") + 256 * Asc("M")
#1::  ;TEST
        NumPut(dwData,  CopyDataStruct, 0)
  SendTCUserCommand("em_openDefaultTab")
        cbData := (StrLen(Command) + 1) * (A_IsUnicode ? 2 : 1)  ;SizeInBytes
Return
        NumPut(cbData, CopyDataStruct, A_PtrSize)  ; OS requires that this be done.
 
        NumPut(&Command, CopyDataStruct, 2*A_PtrSize)  ; Set lpData to point to the string itself.
SendTCUserCommand(Command) ; string
        SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_class TTOTAL_CMD ; 0x4a is WM_COPYDATA. Must use Send not Post.
  {
      }
    If  Command <>
  }
      {
        VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)  ; Set up the structure's memory area.
        dwData := Asc("E") + 256 * Asc("M")
        NumPut(dwData,  CopyDataStruct, 0)
        cbData := (StrLen(Command) + 1) * (A_IsUnicode ? 2 : 1)  ;SizeInBytes
        NumPut(cbData, CopyDataStruct, A_PtrSize)  ; OS requires that this be done.
        NumPut(&Command, CopyDataStruct, 2*A_PtrSize)  ; Set lpData to point to the string itself.
        SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_class TTOTAL_CMD ; 0x4a is WM_COPYDATA. Must use Send not Post.
      }
  }
 
Back to [[AutoHotkey]]
 
[[Category:AutoHotkey scripts|Send a command to Total Commander]]
[[de:AutoHotkey: Schicke einen Befehl an den Total Commander]]

Revision as of 16:05, 12 September 2011

; Script Name: SendTCUserCommand.ahk
; AutoHotkey 版本: 1.1.2.3
; 操作系统:    Windows XP
; 作者:        sunwind <1576157@qq.com> 
; 博客:        http://blog.csdn.net/liuyukuan
; 脚本说明:此工具用来发送TC用户命令。
; 脚本版本:   v1.0


; 需要Total Commander 的usercmd.ini文件中定义好用户命令,比如em_openDefaultTab
; [em_openDefaultTab]
; button=
; cmd=OPENTABS %COMMANDER_PATH%\tab\!!!.tab
#1::  ;TEST
  SendTCUserCommand("em_openDefaultTab")
Return
SendTCUserCommand(Command) ; string
  {
    If  Command <>
      {
        VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)  ; Set up the structure's memory area.
        dwData := Asc("E") + 256 * Asc("M")
        NumPut(dwData,  CopyDataStruct, 0)
        cbData := (StrLen(Command) + 1) * (A_IsUnicode ? 2 : 1)  ;SizeInBytes
        NumPut(cbData, CopyDataStruct, A_PtrSize)  ; OS requires that this be done.
        NumPut(&Command, CopyDataStruct, 2*A_PtrSize)  ; Set lpData to point to the string itself.
        SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_class TTOTAL_CMD ; 0x4a is WM_COPYDATA. Must use Send not Post.
      }
  }

Back to AutoHotkey