Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

User Configurable Mouse Menu


  • Please log in to reply
31 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Update:
1. The menu can have both global items & dynamic entries that are based on active application.
2. Global items are sorted. Dynamic items appear at the bottom of menu (i figured this was most optimal)
3. Menu items can have spaces.

(instructions in script)

Run the script and press middle mouse button to show a menu near mouse which can have user defined items and launches user defined script sections based on the item selected(clicked).

Posted Image

I've made it so that if u already use the middle mouse button for some purpose then it won't hinder that... it needs the middle mouse button to be pressed for a li'l while more than a normal click (about half a second) to launch the menu... so a simple click won't launch it! ...the delay is configurable too.

;___________________________________________
;____User Configurable Menu   - Rajat_______
;___________________________________________


;You can set any title here for the menu

MenuTitle = -=-=-=-=-=-=-=-

;Delay after which the menu is shown
UMDelay = 20

SetFormat, float, 0.0
SetBatchLines, 10ms
SetTitleMatchMode, 2


;___________________________________________
;_____Menu Definitions______________________

; Create / Edit Menu Items here.
; You can use spaces in values (MenuItems) but not in
; section names.

; Don't worry about the order, the menu will be sorted.

MenuItems = Notepad/Calculator/Section 3/Section 4/Section 5

;___________________________________________
;______Dynamic menuitems here_______________

; Syntax:
;     Dyn# = MenuItem|Window title

Dyn1 = MS Word|- Microsoft Word
Dyn2 = Notepad II|- Notepad

;___________________________________________



Exit



;___________________________________________
;_____Menu Sections_________________________

;Create / Edit Menu Sections here.

Notepad:
	Run, Notepad.exe
Return


Calculator:
	Run, Calc
Return


Section3:
	msgbox, You selected 3
Return


Section4:
	msgbox, You selected 4
Return


Section5:
	msgbox, You selected 5
Return

MSWord:
	msgbox, wow! seems like you're working!
Return

NotepadII:
	msgbox, this is a dynamic entry
Return




;___________________________________________
;_____Hotkey Section________________________


~MButton::
	HowLong = 0
	Loop
	{
		HowLong ++
		Sleep, 10
		GetKeyState, MButton, MButton, P
		IfEqual, MButton, U, Break
	}
	IfLess, HowLong, %UMDelay%, Return
	
	
	;prepares dynamic menu
	DynMenu =
	Loop
	{
		IfEqual, Dyn%a_index%,, Break
		
		StringGetPos, ppos, dyn%a_index%, |
		StringLeft, item, dyn%a_index%, %ppos%
		ppos += 2
		StringMid, win, dyn%a_index%, %ppos%, 1000
		
		IfWinActive, %win%,
			DynMenu = %DynMenu%/%item%
	}
	
	
	;Joins sorted main menu and dynamic menu
	Sort, MenuItems, D/
	TempMenu = %MenuItems%%DynMenu%
	
	
	;clears earlier entries
	Loop
	{
		IfEqual, MenuItem%a_index%,, Break
		MenuItem%a_index% =
	}

	;creates new entries
	Loop, Parse, TempMenu, /
	{
		MenuItem%a_index% = %a_loopfield%
	}

	;creates the menu
	Menu = %MenuTitle%
	Loop
	{
		IfEqual, MenuItem%a_index%,, Break
		numItems ++
		StringTrimLeft, MenuText, MenuItem%a_index%, 0
		Menu = %Menu%`n%MenuText%
	}
	
	MouseGetPos, mX, mY
	HotKey, ~LButton, MenuClick
	HotKey, ~LButton, On
	ToolTip, %Menu%, %mX%, %mY%
	WinActivate, %MenuTitle%
Return




MenuClick:
	HotKey, ~LButton, Off
 	IfWinNotActive, %MenuTitle%
 	{
 		ToolTip
 		Return
 	}
 	
 	CoordMode, Mouse, Relative
 	MouseGetPos, mX, mY
 	ToolTip
	mY -= 3		;space after which first line starts
	mY /= 13	;space taken by each line
	IfLess, mY, 1, Return
	IfGreater, mY, %numItems%, Return
	StringTrimLeft, TargetSection, MenuItem%mY%, 0
	StringReplace, TargetSection, TargetSection, %a_space%,, A
	Gosub, %TargetSection%
Return

who says there are limits?!!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Atomhrt
  • Guests
  • Last active:
  • Joined: --

This script didn't take much time to code, but the effect is really neat!

who says there are limits?!!

8)!

Just what I've been looking for! I have a good use for this. I have been looking to replace keytext (http://www.mjmsoft.com/) with something that I had more control over. Keytext also has a mouse menu option. If I come up with something good, I will share.

Thanks!

beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004
Dynamic INI settings

;___________________________________________
;____User Configurable Menu   - Rajat_______
;___________________________________________


;You can set any title here for the menu

MenuTitle = =========

;Delay after which the menu is shown
UMDelay = 20

SetFormat, float, 0.0
SetBatchLines, 10ms


;___________________________________________
;_____Menu Definitions______________________

; Create / Edit Menu Items here.
; You can't use spaces in keys/values/section names.

Exit

;___________________________________________
;_____Menu Sections_________________________

;Create / Edit Menu Sections here.

Run:
        Run, %option%
Return


MsgBox:
        MsgBox, %option%
Return


;___________________________________________
;_____Hotkey Section________________________


~MButton::
        Loop
        {
          IniRead, name, ToolTipMenu.ini, MenuItem%a_index%, Name, (blank)
          if name = (blank)
            break
          MenuItem%a_index% = %name%
        }
        HowLong = 0
        Loop
        {
                HowLong ++
                Sleep, 10
                GetKeyState, MButton, MButton, P
                IfEqual, MButton, U, Break
        }
        IfLess, HowLong, %UMDelay%, Return

        Menu = %MenuTitle%
        Loop
        {
                IfEqual, MenuItem%a_index%,, Break
                MenuItems ++
                StringTrimLeft, MenuText, MenuItem%a_index%, 0
                Menu = %Menu%`n%MenuText%
        }

        ToolTip, %Menu%
        WinActivate, %MenuTitle%
Return


~LButton::
         IfWinNotActive, %MenuTitle%
         {
                 ToolTip
                 Return
         }

         MouseGetPos, mX, mY
         ToolTip
        mY -= 3                ;space after which first line starts
        mY /= 13        ;space taken by each line
        IfLess, mY, 1, Return
        IfGreater, mY, %MenuItems%, Return
        IniRead, type, ToolTipMenu.ini, MenuItem%mY%, Type
        IniRead, option, ToolTipMenu.ini, MenuItem%mY%, Option
        Gosub, %type%
Return
INI File
[MenuItem1]
Name=Notepad
Type=Run
Option=Notepad.exe

[MenuItem2]
Name=Calculator
Type=Run
Option=Calc.exe

[MenuItem3]
Name=Message 1
Type=MsgBox
Option=Test Message 1

[MenuItem4]
Name=Message 2
Type=MsgBox
Option=Test Message 2
thanks,
beardboy

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
nice!

just waiting till RunAHK is added... then such scripts can become much powerful as they'll get user configurable even in compiled form.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


compuboy_r
  • Members
  • 68 posts
  • Last active: Oct 29 2005 03:17 PM
  • Joined: 04 May 2004
Well, I tried both the scripts but found none to be working , donno why ??

Any Help Please


compuboy_r

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i don't see any reason y the script won't work for anyone... er, maybe u're using a desktop theme & the default font size etc. has been changed of the tooltip?

run the script with no other script running... if it works then some other script is removing the tooltip. if u find this useful to b used regularly (i do) then merge it with the script that runs all the time.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


jamestr
  • Members
  • 98 posts
  • Last active: Jul 03 2008 12:30 AM
  • Joined: 05 Apr 2004
Nice!

I like popup menus :)

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

Microsoft has been granted a patent relating to the use of buttons on hardware devices that form part of a user interface. U.S. patent 6,727,830, granted April 27, is described as a ‘time-based hardware button for application launch.’ The patent abstract goes on to explain that the patent relates to how different functions can be invoked depending on whether a button is clicked once, clicked and held down for a period of time, or double-clicked within a short period of time


HEY!!! THAT WAS MY IDEA!

"I've made it so that if u already use the middle mouse button for some purpose then it won't hinder that... it needs the middle mouse button to be pressed for a li'l while more than a normal click (about half a second) to launch the menu"

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Yep you got 'em: Prior art! :)

Atomhrt
  • Guests
  • Last active:
  • Joined: --

HEY!!! THAT WAS MY IDEA!

GJ! You'll be rich, even if you "settle out of court"! :D

larry
  • Guests
  • Last active:
  • Joined: --
I see a few programs that make use of the middle button. On my supplied system, I have instead a wheel which also depresses. Is there a way to use that or something else? This program looks awsum and I wish to try it.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
If you're using XP/2k/NT, you should be able to assign the wheel button and wheel turning:

MButton::
MsgBox Wheel button.
return

OR: Use the wheel for Alt-Tab:
MButton::AltTabMenu
WheelDown::AltTab
WheelUp::ShiftAltTab

compuboy_r
  • Members
  • 68 posts
  • Last active: Oct 29 2005 03:17 PM
  • Joined: 04 May 2004
I have modified the original script to have Space in the MenuEntries.
The script below is the modified one

For having Space in the Menu Entry just give the entry in this format
MenuItem1 = Fire Notepad||SectionNotepad

Compuboy_r



;___________________________________________ 
;____User Configurable Menu   - Rajat_______ 
;___________________________________________ 


;You can set any title here for the menu 
;***** MAKE SURE THE MENU TAKES 3 LINES *******

MenuTitle = =============`n%a_space%%a_space%%a_space%%a_space%%a_space%%a_space%%a_space%%a_space%%a_space%Quick Menu%a_space%%a_space%%a_space%%a_space%%a_space%`n=============

;Delay after which the menu is shown 
UMDelay = 20 

SetFormat, float, 0.0 
SetBatchLines, 10ms 


;___________________________________________ 
;_____Menu Definitions______________________ 

; Create / Edit Menu Items here. 
; You can use spaces in section names. When it is given in this format

; MenuItem<num> = Menu Entry||EntrySection
; Eg. MenuItem1 = Fire Notepad||Notepad

; Not necessary to double the Entry name if it does not contain spaces
; Eg. MenuItem1 = Notepad

MenuItem1 = Notepad 
MenuItem2 = Calculator 
MenuItem3 = Section 3||Section3
MenuItem4 = Section 4||Section4
MenuItem5 = Section 5||Section5

Exit 



;___________________________________________ 
;_____Menu Sections_________________________ 

;Create / Edit Menu Sections here. 

Notepad: 
   Run, Notepad.exe 
Return 


Calculator: 
   Run, Calc 
Return 


Section3: 
   msgbox, You selected 3 
Return 


Section4: 
   msgbox, You selected 4 
Return 


Section5: 
   msgbox, You selected 5 
Return 






;___________________________________________ 
;_____Hotkey Section________________________ 
~MButton::
HowLong = 0
Loop
{
	HowLong++
	Sleep, 10
	GetKeyState, MButton, MButton, P
	IfEqual, MButton, U, Break
}
IfLess, HowLong, %UMDelay%, Return
Menu = %MenuTitle%
Loop
{
	IfEqual, MenuItem%a_index%,, Break
	MenuItems++
	StringTrimLeft, MenuText, MenuItem%a_index%, 0
	StringGetPos, Place,MenuText,||
	If Place = -1 
	{
		MenuGroup%a_index% = %MenuText%
		MenuText1=%MenuText%
	}
	else
	{
		StringLeft,MenuText1,MenuText,%Place%
		StringReplace, MenuGroup%a_index%,MenuText,%MenuText1%||
		
	
	}
	Menu = %Menu%`n%MenuText1%
}
MouseGetPos, mX, mY
ToolTip, %Menu%, %mX%, %mY%  ; Position it more directly under the cursor.
WinActivate, %MenuTitle%
Return


~LButton::
IfWinNotActive, %MenuTitle%
{
	ToolTip
	Return
}
MouseGetPos, mX, mY
ToolTip
mY -= 29                ;space after which first line starts
mY /= 13        ;space taken by each line
IfLess, mY, 1, Return
IfGreater, mY, %MenuItems%, Return
StringTrimLeft, TargetSection, MenuGroup%mY%, 0
Gosub, %TargetSection%
Return


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
That script works great. It's much nicer than having to move the mouse down to the quick launch bar or the start menu every time.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
nice improvement! ..any specific reason the menu title has to be of 3 lines now?

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat