At this point when I select any drop down menu item it goes to the same "Close" option. I assume that is because all my options use the same object... so that is why I want to build and erase objects at menu selection.... or is there a much simpler way to do this...
AutoIt
#include <IE.au3> #include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $oIE, $obj, $test, $hGeneral, $hOther, $hMain Global $idClose, $idMinimize, $idActivate, $idExit ; Global Enum $idClose = 1000, $idMinimize HotKeySet("{ESC}", 'Terminate') _Main() GUISetState() ;Show GUI While 1 GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") WEnd Func Close() ; Erase the obj then write the new one ???? $obj = GUICtrlCreateObj ($oIE, 10, 40, 600, 360) $test = GUICtrlCreateButton("Close",20,20,100,20) GUISetState() ;Show GUI EndFunc Func Minimize() ; Erase the obj then write the new one ???? $obj = GUICtrlCreateObj ($oIE, 10, 40, 600, 360) $test = GUICtrlCreateButton("Minimize",20,20,100,20) GUISetState() ;Show GUI EndFunc Func Activate() ; Erase the obj then write the new one ???? $obj = GUICtrlCreateObj ($oIE, 10, 40, 600, 360) $test = GUICtrlCreateButton("Activate",20,20,100,20) GUISetState() ;Show GUI EndFunc Func _Main() Local $hGUI, $hGeneral, $hOther ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create menu 1 $hGeneral = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hGeneral, 0, "&Close", $idClose) _GUICtrlMenu_InsertMenuItem ($hGeneral, 1, "&Minimize", $idMinimize) _GUICtrlMenu_InsertMenuItem ($hGeneral, 2, "&Exit", $idExit) ; Create menu 2 $hOther = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hOther, 0, "&Activate", $idActivate) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hMain, 0, "&General", 0, $hGeneral) _GUICtrlMenu_InsertMenuItem ($hMain, 1, "&Other", 0, $hOther) ; Set window menu _GUICtrlMenu_SetMenu ($hGUI, $hMain) EndFunc ; Handle menu commands Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch _WinAPI_LoWord ($iwParam) Case $idClose Close() Case $idMinimize Minimize() Case $idActivate Activate() Case $idExit Terminate() EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func Terminate() Exit EndFunc
AutoIt
Edited by tommytx, 08 April 2012 - 04:31 PM.






