AutoHotkey Community

It is currently May 25th, 2012, 5:24 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: May 14th, 2004, 6:48 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
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).

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.

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?!!

_________________
Image


Last edited by Rajat on June 21st, 2004, 5:07 pm, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 14th, 2004, 9:11 pm 
Rajat wrote:
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!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2004, 10:31 pm 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2004, 11:03 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
nice!

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

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2004, 8:19 am 
Offline

Joined: May 4th, 2004, 6:15 pm
Posts: 68
Well, I tried both the scripts but found none to be working , donno why ??

Any Help Please


compuboy_r


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2004, 12:09 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 17th, 2004, 12:31 am 
Offline

Joined: April 5th, 2004, 7:24 pm
Posts: 98
Location: Connecticut USA
Nice!

I like popup menus :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2004, 7:20 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
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"

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2004, 9:21 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Yep you got 'em: Prior art! :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2004, 12:01 am 
Rajat wrote:
HEY!!! THAT WAS MY IDEA!

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


Report this post
Top
  
Reply with quote  
 Post subject: Wheel
PostPosted: June 7th, 2004, 5:32 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2004, 6:42 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2004, 9:04 am 
Offline

Joined: May 4th, 2004, 6:15 pm
Posts: 68
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2004, 1:08 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2004, 8:28 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
nice improvement! ..any specific reason the menu title has to be of 3 lines now?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, nothing and 27 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group