Middle mouse button - customisable popup menu

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

User avatar
Hacker
Moderator
Moderator
Posts: 13066
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Middle mouse button - customisable popup menu

Post by *Hacker »

I have created a quick and dirty middle mouse button menu tool in AHK, similar to QAP but much much more basic. It consists of two files, MouseMenu.ahk, which is the actual script, which reads in MouseMenuConfig.ahk where all the relevant window classes (ahk_class) and script snippets to execute are defined. The user changes MouseMenuConfig.ahk to his liking.

MouseMenu.ahk:

Code: Select all

#Include, MouseMenuConfig.ahk

FileRead, Code, MouseMenuConfig.ahk

MButton::
	Found := False

	MouseGetPos, MouseX, MouseY, WinUnderMouse
	WinActivate, ahk_id %WinUnderMouse%
	WinGetClass, ActiveWinClass, ahk_id %WinUnderMouse%

	Loop, Parse, Code, `n, `r
		If (InStr(A_LoopField, "MenuFunction" . CommandNameDelimiter . "ahk_class" . SpaceReplacement . ActiveWinClass) = 1)
		{
			If (Found = False)
			{
				Gui, MouseMenu: New, -Caption
				Gui, MouseMenu: Margin, 0, 0
				Found := True
			}
			Gui, MouseMenu: Add, Button, gButtonClicked, % StrReplace(SubStr(A_LoopField, InStr(A_LoopField, CommandNameDelimiter, , , 2) + StrLen(CommandNameDelimiter), -2), SpaceReplacement, " ")
		}

	Gui, MouseMenu: Show, X%MouseX% Y%MouseY%
Return

#IfWinActive, ahk_class AutoHotkeyGUI
MButton::
Esc::Gui, MouseMenu: Destroy

ButtonClicked()
{
	global SpaceReplacement
	global CommandNameDelimiter
	global WinUnderMouse
	global ActiveWinClass
	FunctionToCall := % "MenuFunction" . CommandNameDelimiter . "ahk_class" . SpaceReplacement . ActiveWinClass . CommandNameDelimiter . StrReplace(A_GuiControl, " ", SpaceReplacement)
	Gui, Destroy
	WinActivate, ahk_id %WinUnderMouse%
	%FunctionToCall%()
}
MouseMenuConfig.ahk (example):

Code: Select all

SpaceReplacement := "___"
CommandNameDelimiter := "_#_"

MenuFunction_#_ahk_class___TTOTAL_CMD_#_Edit___Files()
{
	Send, {F4}
}
MenuFunction_#_ahk_class___TTOTAL_CMD_#_Copy___Files()
{
	Send, {F5}
}
MenuFunction_#_ahk_class___TTOTAL_CMD_#_Move___Files()
{
	Send, {F6}
}
MenuFunction_#_ahk_class___MozillaWindowClass_#_Reload()
{
	Send, ^r
}
MenuFunction_#_ahk_class___MozillaWindowClass_#_Next___Tab()
{
	Send, ^{Tab}
}
I hope it's more or less self-explanatory.

HTH
Roman
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
nsp
Power Member
Power Member
Posts: 1806
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Middle mouse button - customisable popup menu

Post by *nsp »

I jump a bit late but i personally used powerpro with context menu integration (Right Click) to create dedicated menus for mousse addict.

You can create inside powerpro a dedicated section for TotalCommander "context File"/ context Folder and use tcfs tools to send command...
The bigest advantage, is that you know witch file is under the cursor and can do filtering to have contextual menu parts (Archive,Image....)

Learning curve of powerpro is not ultra fast and the current status is mot in active development but if you are a programmer it's woth a try. Support group is not on yahoo anymore...
The Bible for PowerPro and TC is http://ppro.totalcmd.net/ you can find a sample context menu sample if you search "context" .
Post Reply