fmen Posted September 21, 2005 Share Posted September 21, 2005 OK, I've been working on a desktop popup menu and learning along the way. When you click the right side of the desktop a menu with buttons pops up. I also want to add context menus to the buttons but am having problems. They will not not respond. I added a simple right click context menu ("Exit") to the button "More". It won'trespond. I believe I am having problems with the loop as well as the Opt("GuiOnEventMode", 1). Any help will be appreciated. (Sorry about the poor formatting) ;_________________________________________Initial Set Up_____________________________ AutoItSetOption ( "SendKeyDelay", '.01' ) AutoItSetOption ( "WinTitleMatchMode", 2 ) ;#NoTrayIcon #include <GUIConstants.au3> #include <_IsPressed.au3> Opt("GuiOnEventMode", 1) ;_________________________________________MAIN GUI And Buttons_______________________ $GuiWidth = 100 $GuiHeight = 500 $xPos = (@DesktopWidth-105) $yPos = (@DesktopHeight - $GuiHeight) / 2 $Gui = GUICreate("GuiRight", 100, 500,$xpos, $yPos, $WS_POPUP,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW) ;GUISetBkColor (0) GUISetState(@SW_HIDE) ;ButtonA $ButtonA = GUICtrlCreateButton ( "ButtonA", 15, 20 ,75 ,15) GUICtrlSetOnEvent($ButtonA, "ButtonA_Pressed") GUISetState(@SW_HIDE) ;ButtonB $ButtonB = GUICtrlCreateButton ( "ButtonB", 15, 40 ,75 ,15) GUICtrlSetOnEvent($ButtonB, "ButtonB_Pressed") GUISetState(@SW_HIDE) ;ButtonC $ButtonC = GUICtrlCreateButton ( "Terminate", 15, 460 ,75 ,15) GUICtrlSetOnEvent($ButtonC, "Terminate") GUISetState(@SW_HIDE) ;________________________________"More" Button & Right Click MoreButton___________________________ ;MoreButton $MoreButton = GUICtrlCreateButton ( "More", 15, 480 ,75 ,15) $bcontext = GUICtrlCreateContextMenu($MoreButton) $bexit = GUICtrlCreateMenuitem("Exit",$bcontext) ;_________________________________________Hotkeys_____________________________________ ;_____________________________________________________________________________________ ;______________________________LOOP Mouse click trapper(01=rt 02=rt 04=mid)__________ While 1 $msg = GUIGetMsg() If $msg = $MoreButton Then Call ("Terminate") If $msg = $bexit Then MsgBox(4096,"control", "Button_Go pressed") $i = MouseGetPos() If _IsPressed('04') = 1 Then Call ("Calig") If _IsPressed('02') = 1 AND $i[0] = @DesktopWidth -1 Then Call ("Show_Gui") If _IsPressed('01') = 1 AND $i[0] = @DesktopWidth -1 Then Call ("Bang") If _IsPressed('01') = 1 AND $i[0] < @DesktopWidth -100 Then GUISetState(@SW_HIDE, "GuiRight") Sleep(10) Wend ;__________________________________________________________________________________________ ;______________________________Button Functions____________________________________________ Func ButtonA_Pressed() MsgBox(4096,"control", "Button_Go pressed") GUISetState(@SW_HIDE, "GuiRight") EndFunc Func ButtonB_Pressed() GUISetState(@SW_HIDE, "GuiRight") GUISetState(@SW_HIDE, "More") EndFunc Func Terminate () Exit 0 EndFunc Func More () MsgBox(4096,"control", "Button_Go pressed") EndFunc Func Show_Gui () Sleep (200) Send ("{ESC}") GUISetState(@SW_SHOW, "GuiRight") EndFunc ;________________________________Next Left Click Functions________________________________ Func Bang() MsgBox(4096,"control", "Bang! Bang! Bang!") EndFunc ;_______________________________________Hotkey Functions___________________________________ ;_______________________________________________The End______________________________________ GUIDelete() Link to comment Share on other sites More sharing options...
Valuater Posted September 21, 2005 Share Posted September 21, 2005 ;MoreButton $MoreButton = GUICtrlCreateButton ( "More", 15, 480 ,75 ,15) needs to be ;MoreButton $MoreButton = GUICtrlCreateButton ( "More", 15, 480 ,75 ,15) GUICtrlSetOnEvent($MoreButton, "More") 8) Link to comment Share on other sites More sharing options...
Uten Posted September 21, 2005 Share Posted September 21, 2005 Did you get this code to run at all? No warnings? Modifying ;#include <_IsPressed.au3> #include <misc.au3> And adding missing functions did it on my system. (Version 3.1.1.75) Regards Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Valuater Posted September 22, 2005 Share Posted September 22, 2005 just realized... with this Opt("GuiOnEventMode", 1) you cant use this $msg = GUIGetMsg() If $msg = $MoreButton Then Call ("Terminate") from help If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1. use one or the other 8) this wont work because $moreButton is a button $bcontext = GUICtrlCreateContextMenu($MoreButton) so remove that line... and alos remove If $msg = $bexit Then MsgBox(4096,"control", "Button_Go pressed") you need to look at that context menu in help 8) Link to comment Share on other sites More sharing options...
fmen Posted September 22, 2005 Author Share Posted September 22, 2005 I had a strong feeling that was the problem, but if I don't use Opt("GuiOnEventMode", 1) then the rest of the script doesn't work. I suppose that GuiSwitch etc needs to be used. Link to comment Share on other sites More sharing options...
Valuater Posted September 22, 2005 Share Posted September 22, 2005 ok... i am board... i will clean it up for you i will post it in a few 8) Link to comment Share on other sites More sharing options...
Valuater Posted September 22, 2005 Share Posted September 22, 2005 ok here we go expandcollapse popup;_________________________________________Initial Set Up_____________________________ AutoItSetOption ( "SendKeyDelay", '.01' ) AutoItSetOption ( "WinTitleMatchMode", 2 ) ;#NoTrayIcon #include <GUIConstants.au3> ;#include <_IsPressed.au3> #include <misc.au3> Opt("GuiOnEventMode", 1) ;_________________________________________MAIN GUI And Buttons_______________________ $GuiWidth = 100 $GuiHeight = 500 $xPos = (@DesktopWidth-105) $yPos = (@DesktopHeight - $GuiHeight) / 2 $Gui = GUICreate("GuiRight", 100, 500,$xpos, $yPos, $WS_POPUP,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW) ;GUISetBkColor (0) ;ButtonA $ButtonA = GUICtrlCreateButton ( "ButtonA", 15, 20 ,75 ,15) GUICtrlSetOnEvent($ButtonA, "ButtonA_Pressed") ;ButtonB $ButtonB = GUICtrlCreateButton ( "ButtonB", 15, 40 ,75 ,15) GUICtrlSetOnEvent($ButtonB, "ButtonB_Pressed") ;ButtonC $ButtonC = GUICtrlCreateButton ( "Terminate", 15, 460 ,75 ,15) GUICtrlSetOnEvent($ButtonC, "Terminate") ;________________________________"More" Button & Right Click MoreButton___________________________ ;MoreButton $MoreButton = GUICtrlCreateButton ( "More", 15, 480 ,75 ,15) GUICtrlSetOnEvent($MoreButton, "More") $bcontext = GUICtrlCreateContextMenu($MoreButton) $bexit = GUICtrlCreateMenuitem("Exit",$bcontext) GUICtrlSetOnEvent(-1, "Terminate") $b_new_to_me = GUICtrlCreateMenuitem("New to me",$bcontext) GUICtrlSetOnEvent(-1, "New_to_me") ;set this to hide if you want GUISetState() ;_________________________________________Hotkeys_____________________________________ ;_____________________________________________________________________________________ ;______________________________LOOP Mouse click trapper(01=rt 02=rt 04=mid)__________ While 1 ;$msg = GUIGetMsg() $i = MouseGetPos() If _IsPressed('04') = 1 Then Call ("Calig") If _IsPressed('02') = 1 AND $i[0] = @DesktopWidth -1 Then Call ("Show_Gui") If _IsPressed('01') = 1 AND $i[0] = @DesktopWidth -1 Then Call ("Bang") If _IsPressed('01') = 1 AND $i[0] < @DesktopWidth -100 Then GUISetState(@SW_HIDE, "GuiRight") Wend ;__________________________________________________________________________________________ ;______________________________Button Functions____________________________________________ Func ButtonA_Pressed() MsgBox(4096,"control", "Button_A pressed") GUISetState(@SW_HIDE, "GuiRight") EndFunc Func ButtonB_Pressed() MsgBox(4096,"control", "Button_B pressed") GUISetState(@SW_HIDE, "GuiRight") GUISetState(@SW_HIDE, "More") EndFunc Func Terminate() Exit 0 EndFunc Func More() MsgBox(4096,"control", "Button_Go pressed") GUISetState(@SW_HIDE, "GuiRight") GUISetState(@SW_HIDE, "More") EndFunc Func Show_Gui() Sleep (200) Send ("{ESC}") GUISetState(@SW_SHOW, "GuiRight") EndFunc ;________________________________Next Left Click Functions________________________________ Func Bang() MsgBox(4096,"control", "Bang! Bang! Bang!") EndFunc Func Calig() ; dont know what this one does ???? MsgBox(4096,"control", "Calig! Calig! Calig!") EndFunc Func New_to_me() MsgBox(4096,"control", "This right click menu inside of a button is new to me "& @CRLF & @CRLF & "Bang! Bang! Bang!") EndFunc ;_______________________________________Hotkey Functions___________________________________ ;_______________________________________________The End______________________________________ GUIDelete() it all works... but maybe you need the beta version 8) Link to comment Share on other sites More sharing options...
fmen Posted September 22, 2005 Author Share Posted September 22, 2005 Valuater, I can't thank you enough. It's exacly what I wanted. You are correct about the beta, but it works fine if _Ispressed.au3 is included. Thanks again. Link to comment Share on other sites More sharing options...
Valuater Posted September 22, 2005 Share Posted September 22, 2005 Glad i could help ...also i tried to demonstrate how to add more menu's to the more button hope you understand what i did 8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now