Jump to content

GuiCtrlCreateMenuItem() for Alt+Space?


jacQues
 Share

Recommended Posts

There are numerous applications that add menu items to Window's Alt+Space menu. Example: AutoIt Help > Jump to URL & About...

Is this possible with AutoIt and how to do this?

jacQues

Hi! Try this:

#include <GuiConstantsEx.au3>
#include <GuiMenu.au3>

Global Enum $id_URL = 1000, $id_About

$hGui = GUICreate("Menu test", 300, 200)

$hMenu = _GUICtrlMenu_GetSystemMenu($hGui)

_GUICtrlMenu_AppendMenu($hMenu, $MF_SEPARATOR, 0, 0)
_GUICtrlMenu_AppendMenu($hMenu, $MF_STRING, $id_URL, "Go to address...")
_GUICtrlMenu_AppendMenu($hMenu, $MF_STRING, $id_About, "About")

GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $idFrom
    
    $idFrom = BitAND($wParam, 0xFFFF)
    
    Switch $idFrom
    Case $id_URL
        ShellExecute("http://www.autoitscript.com/forum")
    Case $id_About
        MsgBox(64, "About", "Autoit v " & @AutoItVersion)
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
:)
Link to comment
Share on other sites

Variable used without being declared.:
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")
GUIRegisterMsg(^ ERROR

Need to include WindowsConstants.au3 for that variable.

And just for clarification, it's not possible to use AutoIt to add menu items to other process's windows, correct? Or perhaps the menu items could be added, but they would not be functional I think.

Link to comment
Share on other sites

Hi Saunders! What the version do you using? I tested this code on v3.2.10.0 and all works fine. :) About to add menu items to other process's... i tryed, i know this wrong, but i are hope, what somebody help me ;)

#include <GuiConstantsEx.au3>
#include <GuiMenu.au3>

Global Enum $id_URL = 1000, $id_About

Run("notepad.exe")

WinWait("[Class:Notepad]")

$hWnd = WinGetHandle("[Class:Notepad]")

$hGui = GUICreate("Menu test", 300, 200, -1, -1, -1, -1, $hWnd)

$hMenu = _GUICtrlMenu_GetSystemMenu($hWnd)

_GUICtrlMenu_AppendMenu($hMenu, $MF_SEPARATOR, 0, 0)
_GUICtrlMenu_AppendMenu($hMenu, $MF_STRING, $id_URL, "Go to address...")
_GUICtrlMenu_AppendMenu($hMenu, $MF_STRING, $id_About, "About")

GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $idFrom
    
    $idFrom = BitAND($wParam, 0xFFFF)
    
    Switch $idFrom
    Case $id_URL
        ShellExecute("http://www.autoitscript.com/forum")
    Case $id_About
        MsgBox(64, "About", "Autoit v " & @AutoItVersion)
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...