AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

User Configurable Mouse Menu
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Fri May 14, 2004 5:48 pm    Post subject: User Configurable Mouse Menu Reply with quote

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).



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.

Code:

;___________________________________________
;____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?!!
_________________


Last edited by Rajat on Mon Jun 21, 2004 4:07 pm; edited 4 times in total
Back to top
View user's profile Send private message
Atomhrt
Guest





PostPosted: Fri May 14, 2004 8:11 pm    Post subject: Re: User Configurable Mouse Menu Reply with quote

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

who says there are limits?!!

Cool!

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!
Back to top
beardboy



Joined: 02 Mar 2004
Posts: 443
Location: SLC, Utah

PostPosted: Fri May 14, 2004 9:31 pm    Post subject: Reply with quote

Dynamic INI settings

Code:
;___________________________________________
;____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
Code:
[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
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Fri May 14, 2004 10:03 pm    Post subject: Reply with quote

nice!

just waiting till RunAHK is added... then such scripts can become much powerful as they'll get user configurable even in compiled form.
_________________
Back to top
View user's profile Send private message
compuboy_r



Joined: 04 May 2004
Posts: 68

PostPosted: Sat May 15, 2004 7:19 am    Post subject: Reply with quote

Well, I tried both the scripts but found none to be working , donno why ??

Any Help Please


compuboy_r
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Sat May 15, 2004 11:09 am    Post subject: Reply with quote

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.
_________________
Back to top
View user's profile Send private message
jamestr



Joined: 05 Apr 2004
Posts: 98
Location: Connecticut USA

PostPosted: Sun May 16, 2004 11:31 pm    Post subject: Reply with quote

Nice!

I like popup menus Smile
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Thu Jun 03, 2004 6:20 pm    Post subject: Reply with quote

Quote:
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"
_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Thu Jun 03, 2004 8:21 pm    Post subject: Reply with quote

Yep you got 'em: Prior art! Smile
Back to top
View user's profile Send private message Send e-mail
Atomhrt
Guest





PostPosted: Thu Jun 03, 2004 11:01 pm    Post subject: Reply with quote

Rajat wrote:
HEY!!! THAT WAS MY IDEA!

GJ! You'll be rich, even if you "settle out of court"! Very Happy
Back to top
larry
Guest





PostPosted: Mon Jun 07, 2004 4:32 pm    Post subject: Wheel Reply with quote

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.
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Mon Jun 07, 2004 5:42 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
compuboy_r



Joined: 04 May 2004
Posts: 68

PostPosted: Fri Jun 11, 2004 8:04 am    Post subject: Reply with quote

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



Code:
;___________________________________________
;____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
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Fri Jun 11, 2004 12:08 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Fri Jun 11, 2004 7:28 pm    Post subject: Reply with quote

nice improvement! ..any specific reason the menu title has to be of 3 lines now?
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group