topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday December 15, 2024, 1:02 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Dynamic context menu for any application  (Read 5251 times)

bgjensen

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
IDEA: Dynamic context menu for any application
« on: January 10, 2012, 03:05 PM »
Are there a program that can create custom context menus for any program, that can send command to the program.

Example: Press a hotkey in your browser, notepad or windows explorer, and a context menu with commands (you have specified in an ini file) pops up and then sends the selected command to the program (CTRL+J, ALT+K and so on).

Like Skrommel's Barnacle but with a context menu instead of buttons.
« Last Edit: January 10, 2012, 03:12 PM by bgjensen »

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic context menu for any application
« Reply #1 on: January 10, 2012, 03:31 PM »
Hm, not exactly right, but could be a start:
WinButtons can present buttons on screen, Application-context sensitive if you want, and can use WinSendKeys to send keystrokes, mouseclicks and clipboard (text) contents to a specific or the currently active application.
Now just a (system-wide?) hotkey to load WinButtons, and you'd be fine :D

I could add that as a feature, I guess, if WinButtons is anything near what you'd like?

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic context menu for any application
« Reply #2 on: January 10, 2012, 03:58 PM »
Are there a program that can create custom context menus for any program, that can send command to the program.

I don't know of any but here's a basic AutoHotkey framework that you can extend:

Code: Autohotkey [Select]
  1.  
  2. ; Create dummy menu so we can delete it and
  3. ; create the context-sensitive one later.
  4. Menu, cMenu, Add, Dummy, Dummy
  5. Dummy: ; Dummy label
  6. Return
  7.  
  8. Return ; End of auto-execute section.
  9.  
  10.  
  11. #IfWinActive, Firefox
  12. {
  13.     #v:: ; Win+v hotkey.
  14.     {
  15.         ; Delete current menu.
  16.         Menu, cMenu, Delete
  17.         ; Build app-specific menu.
  18.         Menu, cMenu, Add, Show downloads, menuFirefox
  19.         Menu, cMenu, Add, Organize bookmarks, menuFirefox        
  20.         ; Show the menu at the mouse pointer.
  21.         Menu, cMenu, Show
  22.     }
  23.     Return
  24. }
  25.  
  26.  
  27. #IfWinActive, Notepad
  28. {
  29.     #v:: ; Win+v hotkey.
  30.     {
  31.         ; Delete current menu.
  32.         Menu, cMenu, Delete
  33.         ; Build app-specific menu.
  34.         Menu, cMenu, Add, Find, menuNotepad
  35.         Menu, cMenu, Add, Select all, menuNotepad        
  36.         ; Show the menu at the mouse pointer.
  37.         Menu, cMenu, Show
  38.     }
  39.     Return
  40. }
  41.  
  42.  
  43. menuFirefox:
  44. {
  45.     If ( A_ThisMenuItem = "Show downloads" )
  46.     {
  47.         SendInput, ^j
  48.     }
  49.     Else If ( A_ThisMenuItem = "Organize bookmarks" )
  50.     {
  51.         SendInput, ^+b
  52.     }
  53. }
  54. Return
  55.  
  56.  
  57. menuNotepad:
  58. {
  59.     If ( A_ThisMenuItem = "Find" )
  60.     {
  61.         SendInput, {F3}
  62.     }
  63.     Else If ( A_ThisMenuItem = "Select all" )
  64.     {
  65.         SendInput, ^a
  66.     }
  67. }
  68. Return


Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic context menu for any application
« Reply #3 on: January 10, 2012, 04:28 PM »
Nice, skwire, I expected something like that :D

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic context menu for any application
« Reply #4 on: January 10, 2012, 04:47 PM »
Nice, skwire, I expected something like that :D

Thanks.  Stuff like this is easy in AHK.  However, creating a GUI for something like this would be much more work than the actual guts of the code.  I hope the original poster can get some use of that framework; I tried to make it logical and easy to follow.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic context menu for any application
« Reply #5 on: January 10, 2012, 05:09 PM »
I hope the original poster can get some use of that framework; I tried to make it logical and easy to follow.
It's looking good, but requires a bit of manual labor by the OP, and that could be a non-coder (first post, but a Participant since 2008, who knows).

That's why I suggested my WinButtons and WinSendKeys tools. Running that with a user-created configuration (using WinButtonEdit) from a desktop shortcut with a system-wide hotkey, is more hassle to set up initially, but could be more non-coder friendly when changes should be made to the set of keys and supported applications.

I do see a 'feature-request' for WB to pop-up at the current mouse-cursor location, though :-\

bgjensen

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic context menu for any application
« Reply #6 on: January 10, 2012, 11:32 PM »
skwire: yes, something like that. I will see if i can extend it more (have basic Autoit knowledge)

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic context menu for any application
« Reply #7 on: January 11, 2012, 12:03 AM »
skwire: yes, something like that. I will see if i can extend it more (have basic Autoit knowledge)

Awesome.   :up:  Holler if you have any questions.