Three Functions from a Single Toolbar Button Using LMB, RMB & MMB

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
jinsight
Senior Member
Senior Member
Posts: 299
Joined: 2003-02-25, 19:47 UTC
Location: Wooster, Ohio, USA

Three Functions from a Single Toolbar Button Using LMB, RMB & MMB

Post by *jinsight »

I suggest a new feature: three functions from a single toolbar button using the left mouse button, the right mouse button and the middle mouse button.
License #1945
Windows 10 Pro x64
Version 22H2 (OS Build 19045.3930)
TC 11.00 x64 and x86, Everything 1.5.0.1366a x64, QAP 11.6.3.1 x64
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Three Functions from a Single Toolbar Button Using LMB, RMB & MMB

Post by *petermad »

RMB on a button in the buttonbar is already used for the button context menu.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
jinsight
Senior Member
Senior Member
Posts: 299
Joined: 2003-02-25, 19:47 UTC
Location: Wooster, Ohio, USA

Re: Three Functions from a Single Toolbar Button Using LMB, RMB & MMB

Post by *jinsight »

It is true that RMB on a button in the buttonbar is already used for the button context menu. It is also true that the same options are available off of the toolbar the button is on. I am suggesting an enriched feature set for buttons/toolbars because I think this would enhance the use and appeal of Total Commander.
License #1945
Windows 10 Pro x64
Version 22H2 (OS Build 19045.3930)
TC 11.00 x64 and x86, Everything 1.5.0.1366a x64, QAP 11.6.3.1 x64
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Three Functions from a Single Toolbar Button Using LMB, RMB & MMB

Post by *Horst.Epp »

I use a old Autohotkey script named Toolbar which allows Normal, Shift and Ctrl presses of a button.
It was part of the ButtonBar eXtended tool from Samuel but its no longer on this thread.
Its much simpler as ButtonBar eXtended but I like it.
https://www.ghisler.ch/board/viewtopic.php?t=20274

Here the sample toolbar.ini file which shows how to configure it:

Code: Select all

; ------------------------------------------------------------------------------
; Commandline Tool for calling different commands on modifiers or running macros
; (when modifiers are pressed at startup its possible to launch different commands)
;
; Just call "Toolbar.exe" with parameter "[C]"
; where "[C]" is the number of the button you like to execute.
; ------------------------------------------------------------------------------


; CopyNamesToClip
[Button 1 Normal]
1_Command=2017

; Copy path to clipboard
[Button 1 Shift]
1_Command=2018

; CD to path in clipbord
[Button 1 Ctrl]
Needs_Parameters=1
Wait_Ctrl_Up=1
1_File=c:\tools\NirSoft\x64\nircmd.exe
1_Parameter=exec show C:\Tools\Wincmd\totalcmd64.exe /O /S /A /L="~$clipboard$"

; Clear Clipboard
[Button 1 Alt]
1_File=c:\tools\NirSoft\x64\nircmd.exe
1_Parameter=Clipboard Clear

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Default view
[Button 2 Normal]
1_Command=8500

; Comment view
[Button 2 Shift]
1_Command=272

; Search View
[Button 2 Ctrl]
1_Command=275

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; AkelPad
[Button 3 Normal]
Needs_Parameters=1
1_File=C:\Tools\AkelPad\AkelPad.exe
1_Parameter=%S

; Syn2
[Button 3 Shift]
Needs_Parameters=1
1_File=C:\Tools\Wincmd\PLUGINS\Syn2\Syn.exe
1_Parameter=%S
=================================================================

Here the script Toolbar.ahk (I use a compiled version):

Code: Select all

; "Toolbar" the little brother of "ButtonBar eXtended" for Total Commander
; Version: 0.4
; Freeware by Samuel Plentz - www.SamuelPlentz.de.vu

#NoTrayIcon
#SingleInstance off
SetBatchLines -1

; ### --------------------------------------------------------------------------
; ### current section in ini-file

Getkeystate,Keystate_Ctrl ,Ctrl
Getkeystate,Keystate_Alt  ,Alt
Getkeystate,Keystate_Shift,Shift
if(Keystate_Ctrl=="D"){
 Section=[Button %1% Ctrl]
}else if(Keystate_Alt=="D"){
 Section=[Button %1% Alt]
}else if(Keystate_Shift=="D"){
 Section=[Button %1% Shift]
}else{
 Section=[Button %1% Normal]
}

; ### --------------------------------------------------------------------------
; ### get parameters if needed (with internal command)

Needs_Parameters := NewIniRead(Section,"Needs_Parameters")
if(Needs_Parameters=="1"){
 Clipboard_Backup:=ClipboardAll
 Clipboard=
 PostMessage,1075,2018,0,,ahk_class TTOTAL_CMD
 if(WinExist("Total Commander ahk_class #32770")) {
  Send {Space}
 } else {
  ClipWait,0.5
 }
 Selected_Files=%Clipboard%
 Clipboard:=Clipboard_Backup
 Clipboard_Backup=
 
 Loop,parse,Selected_Files,`n,`r
 {
  if(A_Index=="1") {
   Parameter_N="%A_LoopField%"
   Parameter_S="%A_LoopField%"
   SplitPath,A_LoopField,,Parameter_P
   Parameter_P=%Parameter_P%\
  } else {
   Parameter_S=%Parameter_S% "%A_LoopField%"
  }
 }
}

; ### -------------------------------------------------------------------------- 
; ### wait if programs behave different with pressed down ctrl

Wait_Ctrl_Up := NewIniRead(Section,"Wait_Ctrl_Up")
if(Wait_Ctrl_Up=="1") {
 Loop{
  Getkeystate,Keystate_Ctrl ,Ctrl
  Getkeystate,Keystate_Alt  ,Alt
  Getkeystate,Keystate_Shift,Shift
  if(Keystate_Ctrl!="D" && Keystate_Alt!="D" && Keystate_Shift!="D"){
   break
  }
 }
}

; ### --------------------------------------------------------------------------
; ### execute commands & files

Loop {
 Current_Command   := NewIniRead(Section,A_Index . "_Command")
 Current_File      := NewIniRead(Section,A_Index . "_File")
 Current_SendInput := NewIniRead(Section,A_Index . "_SendInput")
 transform,Current_File,deref,%Current_File%
 if(Current_Command=="" && Current_File=="" && Current_SendInput=="") {
  if(A_Index=="1") {
   msgbox,16,No instructions for this button!,No entry in section "%Section%" of "Toolbar.ini".
;   msgbox,16,Keine Anweisungen für den Knopf!,Kein Eintrag in Sektion "%Section%" der "Toolbar.ini".
  }
  break
 }
 if(Current_Command!="") {
  if(InStr(Current_Command,"em_")==1){
  	EM_Command(Current_Command)
 	} else {
   SendMessage,1075,%Current_Command%,0,,ahk_class TTOTAL_CMD
  }
 }
 if(Current_File!="") {
  Current_Parameter := NewIniRead(Section,A_Index . "_Parameter")
  Current_Path      := NewIniRead(Section,A_Index . "_Path")
  transform,Current_Path,deref,%Current_Path%
  StringReplace,Current_Path,Current_Path,`%P,%Parameter_P%,All
  StringReplace,Current_Parameter,Current_Parameter,`%P,%Parameter_P%,All
  StringReplace,Current_Parameter,Current_Parameter,`%N,%Parameter_N%,All
  StringReplace,Current_Parameter,Current_Parameter,`%S,%Parameter_S%,All
  if(Current_Parameter=="") {
   Run,"%Current_File%",%Current_Path%
  } else {
   Run,"%Current_File%" %Current_Parameter%,%Current_Path%
  }
 }
 if(Current_SendInput!="") {
  SendInput %Current_SendInput%
 }
}

ExitApp

; ### --------------------------------------------------------------------------
; ### read entry from ini file (own version because sometimes "" are omited)

NewIniRead(Section,Key)
{
 static File_Content
 if(File_Content=="") {
  FileRead,File_Content,Toolbar.ini
 }
 Current_Section=0
 Loop,parse,File_Content,`n,`r
 {
  if(InStr(A_LoopField,"[")=="1") { ; Section
   if(A_LoopField==Section) {
    Current_Section=1
   } else {
    Current_Section=0
   }
  } else {                          ; Key
   if(Current_Section=="1" && InStr(A_LoopField,Key . "=")=="1"){
    StringTrimLeft,Result,A_LoopField,InStr(A_LoopField,"=")
    return Result
   }
  }
 }
 return ""
}

; ### --------------------------------------------------------------------------
; ### execute em_commands

EM_Command(ByRef SentParameter)
{
 VarSetCapacity(CopyDataStruct,12)
 InsertInteger(Asc("E")+256 * Asc("M"),CopyDataStruct)
 InsertInteger(StrLen(SentParameter)+1,CopyDataStruct,4)
 InsertInteger(&SentParameter,CopyDataStruct,8)
 SendMessage,0x4A,,&CopyDataStruct,,ahk_class TTOTAL_CMD
}

InsertInteger(pInteger,ByRef pDest,pOffset=0,pSize=4)
{
 mask := 0xFF
 Loop %pSize%
 {
  DllCall("RtlFillMemory",UInt,&pDest+pOffset+A_Index-1,UInt,1,UChar,(pInteger & mask)>>8*(A_Index-1))
  mask := mask<<8
 }
}
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
jinsight
Senior Member
Senior Member
Posts: 299
Joined: 2003-02-25, 19:47 UTC
Location: Wooster, Ohio, USA

Re: Three Functions from a Single Toolbar Button Using LMB, RMB & MMB

Post by *jinsight »

2Horst.Epp

Thanks a lot for this info. I would never have learned of it otherwise.
License #1945
Windows 10 Pro x64
Version 22H2 (OS Build 19045.3930)
TC 11.00 x64 and x86, Everything 1.5.0.1366a x64, QAP 11.6.3.1 x64
Post Reply