DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: IDEA: Dynamic context menu for any application  (Read 6,862 times)

bgjensen

  • Participant
  • Joined in 2008
  • *
  • Posts: 2
IDEA: Dynamic context menu for any application
« on: January 10, 2012, 09: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, 09:12 PM by bgjensen »

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: IDEA: Dynamic context menu for any application
« Reply #1 on: January 10, 2012, 09: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?
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: IDEA: Dynamic context menu for any application
« Reply #2 on: January 10, 2012, 09: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)
SetTitleMatchMode, 2

; Create dummy menu so we can delete it and
; create the context-sensitive one later.
Menu, cMenu, Add, Dummy, Dummy
Dummy: ; Dummy label
Return

Return ; End of auto-execute section.


#IfWinActive, Firefox
{
    #v:: ; Win+v hotkey.
    {
        ; Delete current menu.
        Menu, cMenu, Delete
        ; Build app-specific menu.
        Menu, cMenu, Add, Show downloads, menuFirefox
        Menu, cMenu, Add, Organize bookmarks, menuFirefox        
        ; Show the menu at the mouse pointer.
        Menu, cMenu, Show
    }
    Return
}
#IfWinActive


#IfWinActive, Notepad
{
    #v:: ; Win+v hotkey.
    {
        ; Delete current menu.
        Menu, cMenu, Delete
        ; Build app-specific menu.
        Menu, cMenu, Add, Find, menuNotepad
        Menu, cMenu, Add, Select all, menuNotepad        
        ; Show the menu at the mouse pointer.
        Menu, cMenu, Show
    }
    Return
}
#IfWinActive


menuFirefox:
{
    If ( A_ThisMenuItem = "Show downloads" )
    {
        SendInput, ^j
    }
    Else If ( A_ThisMenuItem = "Organize bookmarks" )
    {
        SendInput, ^+b
    }
}
Return


menuNotepad:
{
    If ( A_ThisMenuItem = "Find" )
    {
        SendInput, {F3}
    }
    Else If ( A_ThisMenuItem = "Select all" )
    {
        SendInput, ^a
    }
}
Return

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: IDEA: Dynamic context menu for any application
« Reply #3 on: January 10, 2012, 10:28 PM »
Nice, skwire, I expected something like that :D
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: IDEA: Dynamic context menu for any application
« Reply #4 on: January 10, 2012, 10: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,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: IDEA: Dynamic context menu for any application
« Reply #5 on: January 10, 2012, 11: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 :-\
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

bgjensen

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

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: IDEA: Dynamic context menu for any application
« Reply #7 on: January 11, 2012, 06: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.

Original address: https://www.donationcoder.com/forum/index.php?topic=29569.0