TC opens closes and reopens new tab on middle mousebutton

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

TC opens closes and reopens new tab on middle mousebutton

Post by *Samuel »

TC opens closes and reopens new tab on a click with middle mousebutton when it is inactive.

Steps to reproduce:
1) open more than 1 tab (register) in one panel
2) activate another program (for example Notepad)
3) without explicitly activating TC click with the middle mouse button on the rightmost tab.

-> TC will close this tab (intended) but it will also clone the tab to the left.
User avatar
fenix_productions
Power Member
Power Member
Posts: 1979
Joined: 2005-08-07, 13:23 UTC
Location: Poland
Contact:

Post by *fenix_productions »

Confirmed with RC2 but I think it will be fixed in final version ;)
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...

#128099
User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

Btw: TC 7.04a has the same behavior.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, cannot reproduce. :(
The tab closes and stays closed here.
Author of Total Commander
https://www.ghisler.com
User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

See movie here:
http://www.drivehq.com/file/df.aspx/publish/SamuelPlentz/Dateien/Middleclick.avi

More than 1 tab is important. Also closing the rightmost.
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

I cannot repruduce this bug either - not with my usual ini nor with a clean ini file.

I am using Windows standard HID mouse driver with a Microsoft wireless mouse,
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

I cannoit reproduce it either. I have a Micorsoft scroll wheel mouse with the wheel set as double-click and it works like it is supposed to for me.
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

I need to get ashamed now. :oops:

You need the current ButtonBar eXtended to reproduce. I wrote a "MouseTool.ahk" for it, which is causing that.
It is used to be able to use the middle mouse button to execute different commands in the Toolbar. (Toolbar eXtended still works with ctrl, alt, shift without the tool running.)

So its up to me to fix this bug. :oops: I will report here when I fixed it.
fenix_productions I assume you also use my Buttonbar eXtended with MouseTool.

PS: The only thing Christian can do here is to include multiple commands per button (upon different modifiers / mousebuttons) into TC. :lol:
User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

This is strange.

Normally MouseTool catches the MiddleMouseButton events and replaces them with other MiddleMouseButton events. (if the events are catched above the ButtonBar MouseTool sends LeftMouseButton events)

But AutoHotkey apparently can't replace a MiddleMouseButtonUp event, if it doesn't know of the according MiddleMouseButtonDown event. Instead both events (the one from the user and the one created by MouseTool) are seen by Total Commander.

As a workaround I removed this line:

Code: Select all

#ifWinActive ahk_class TTOTAL_CMD
Any comments or suggestions are welcome!

This is the new code of "MouseTool.ahk":

Code: Select all

; "MouseTool" for "ButtonBar eXtended" for Total Commander
; Version: 1.2
; Freeware by Samuel Plentz - www.SamuelPlentz.de.vu

#NoTrayIcon
#SingleInstance FORCE
SetBatchLines -1

; read values from ini
MB1=0
IniRead,MB2     ,ButtonBar eXtended.ini,MouseTool,UseMouseButton2,0
IniRead,MB3     ,ButtonBar eXtended.ini,MouseTool,UseMouseButton3,1
IniRead,MB4     ,ButtonBar eXtended.ini,MouseTool,UseMouseButton4,1
IniRead,MB5     ,ButtonBar eXtended.ini,MouseTool,UseMouseButton5,1
IniRead,ShowIcon,ButtonBar eXtended.ini,MouseTool,ShowIcon       ,1

if(ShowIcon!="0"){
 menu,tray,Icon
 menu,tray,Tip,"MouseTool" for "ButtonBar eXtended"
}

; create the redirect keys
#ifWinActive ahk_class TTOTAL_CMD 
$LButton:: RedirectClick(1)
$RButton:: RedirectClick(2)
$MButton:: RedirectClick(3)
$XButton1::RedirectClick(4)
$XButton2::RedirectClick(5)
#ifWinActive



; simulates a normal mouseclick on click with mouse2 - mouse5 on the buttonbar
RedirectClick(Number)
{
 global

 if((MB%Number%!="0") && (OverButtonBar())){
  ClearMutex() 
  SetMutex(Number)
  PressMouseButton(1,0)
  WaitForKey(Number)
  PressMouseButton(1,1)
 }else{
  ClearMutex()
  PressMouseButton(Number,0)
  WaitForKey(Number)
  PressMouseButton(Number,1)
 }
 return

}

; checks if the mouse actually is over the buttonbar or not
OverButtonBar()
{
 if(WinActive("ahk_class TTOTAL_CMD")){
  MouseGetPos,,,,Control
  if(Control=="TButtonBar1"){
   return 1
  }
 }
 return 0
}

; waits for mousekey release
WaitForKey(Number)
{
 if(Number==1){
  KeyWait,LButton
 }else if(Number==2){
  KeyWait,RButton
 }else if(Number==3){
  KeyWait,MButton
 }else if(Number==4){
  KeyWait,XButton1
 }else if(Number==5){
  KeyWait,XButton2 
 }
}
  
; simulates mouseclick
PressMouseButton(Number,up)
{
 if(Number==1 && up==0){
  Click down L
 }else if(Number==1 && up==1){
  Click up L
 }else if(Number==2 && up==0){
  Click down R
 }else if(Number==2 && up==1){
  Click up R
 }else if(Number==3 && up==0){
  Click down M
 }else if(Number==3 && up==1){
  Click up M
 }else if(Number==4 && up==0){
  Click down X1
 }else if(Number==4 && up==1){
  Click up X1
 }else if(Number==5 && up==0){
  Click down X2
 }else if(Number==5 && up==1){
  Click up X2
 }
}

; create a mutex to notify "ButtonBar eXtended.exe" what MouseButton has been pressed
SetMutex(Number)
{
 global

 Mutex%Number% := DllCall("kernel32\CreateMutexA",Long,"0&",Int,"1",Str,"BBX_" . Number)
}

; close previous mutexes
ClearMutex()
{
 global
 
 if(Mutex2!=""){
  DllCall("CloseHandle","UInt",Mutex2)
  Mutex2=
 }
 if(Mutex3!=""){
  DllCall("CloseHandle","UInt",Mutex3)
  Mutex3=
 }
 if(Mutex4!=""){
  DllCall("CloseHandle","UInt",Mutex4)
  Mutex4=
 }
 if(Mutex5!=""){
  DllCall("CloseHandle","UInt",Mutex5)
  Mutex5=
 }
}
Last edited by Samuel on 2009-09-06, 15:32 UTC, edited 1 time in total.
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Should be moved to "Total Commander (English)" or "TC7.5 Behaviour which will not be changed"
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

[mod]Moved to the Plugins and Addons forum.

Hacker (Moderator)[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Why don't you change the code before triggering?
I'm not sure if TButtonBar1 can have other numbers or not, thus the RegExMatch instead of a direct == comparison.

Code: Select all

#ifWinActive ahk_class TTOTAL_CMD
{
	MouseGetPos, ,,,aControl
	if( RegExMatch(aControl, "^TButtonBar") )
	{
		/* HotKeyDefinitions here */
	}
}
return
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

Sorry this does not help.

1) I think you didnt understand the problem. Your suggestions are unrelated.

2) Currently there is only a TButtonBar1 control in TC. So no need for RegEx.

3) Hotkeys in AutoHotkey only work at top Level. You cant nest them into functions.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Except ... you're wrong

Code: Select all

Do_WinFunction(key)
{
	MouseGetPos, ,,,aControl
	if( aControl == "TButtonBar1" )
	{
		MsgBox, Win+%key%
	}
	else
	{
		Send, #%key%
	}
	return
}

#ifWinActive ahk_class TTOTAL_CMD
{
	$#r::Do_WinFunction("r")
}
return
Or more relevant to your purposes:

Code: Select all

Do_MouseAction()
{
	MouseGetPos, ,,,aControl
	if( aControl == "TButtonBar1" )
	{
		if( GetKeyState("Shift") == 1 )
		{
			MsgBox, ExtendedButtonBar Shift
		}
		else
		if( GetKeyState("Ctrl") == 1 )
		{
			MsgBox, ExtendedButtonBar Ctrl
		}
		;etc
	}
	else
	{
		Click Down
		KeyWait LButton
		Click Up
	}
	return
}
#ifWinActive ahk_class TTOTAL_CMD
{
	$Lbutton::Do_MouseAction()
}
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Samuel wrote:This is strange.
But AutoHotkey apparently can't replace a MiddleMouseButtonUp event, if it doesn't know of the according MiddleMouseButtonDown event. Instead both events (the one from the user and the one created by MouseTool) are seen by Total Commander.
And this is incorrect too, here's my AHK script for MButton:

Code: Select all

$Mbutton:: 
{
	MinMaxClose := WM_NCHITTEST()
	if( RegExMatch(MinMaxClose, "^(MINBUTTON|MAXBUTTON|CLOSE)$" ))
	{
		Send, {MButton}
		return
	}

	ControlGetFocus, aControl, ahk_class TTOTAL_CMD
	if( RegExMatch(aControl, "TMyListBox(1|2)") 
	&& !GetKeyState("Shift") )
	{
		;; TC ALIAS: CTRL+DEL = em_recycle
		;; 	   em_recycle = recycle.exe %S
		Send, ^{Delete}		
/*
		Send, {Delete}
		WinWait, ahk_class #32770
		ControlClick, &Yes
*/
		return
	}
	else
	if( WinActive("ahk_class SDL_app") )
	{
		Click, Down Middle
		KeyWait, Mbutton
		Click, Up Middle
	}
	else
	if( WinActive("ahk_class OpWindow") )
	{
		if( GetKeyState("Ctrl") == 1 )
		{
			Send, {.}		; STOP & OpKey: ^{.}
			return
		}
		else
			Send, {Delete}
	}
	else
		Send, {Delete}
	return
}
Notice, "Click Down Middle", and "Click Up Middle"
Post Reply