LYRRAD Posted June 15, 2010 Share Posted June 15, 2010 I am trying to create a small mapping program where the user can put marks on a picture/map by right clicking on it and choosing from the menu. I can get it to bring up the context menu but I cannot select anything...please help. The code I got so far is as follows: #include <GUIConstantsEx.au3> GUICreate("Site Check",800,600) GUICtrlCreatePic("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\blue hills.jpg",-1,-1,0,0) GUICtrlSetState(-1,$GUI_DISABLE) $input=GUICtrlCreateInput("",50,200,200,20) $button=GUICtrlCreateButton("Test",100,250,100,30) $contextmenu=GuiCtrlCreateContextMenu() $aboutitem=GuiCtrlCreateMenuitem("About",$contextmenu) $testitem=GUICtrlCreateMenuItem("Test",$contextmenu) GuiCtrlCreateMenuitem("",$contextmenu) $exititem=GuiCtrlCreateMenuitem("Exit",$contextmenu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $button MsgBox(64,"Test","You typed..."&GUICtrlRead($input),3) Case $contextmenu While 1 Switch $msg=GuiGetMsg() Case $msg=$exititem ExitLoop Case $msg=$aboutitem Msgbox(0,"About","A simple example with a context menu!") EndSwitch WEnd EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 15, 2010 Moderators Share Posted June 15, 2010 (edited) LYRRAD,Welcome to the AutoIt forum. You were getting too complicated! #include <GUIConstantsEx.au3> GUICreate("Site Check", 800, 600) GUICtrlCreatePic("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\blue hills.jpg", -1, -1, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) $input = GUICtrlCreateInput("", 50, 200, 200, 20) $button = GUICtrlCreateButton("Test", 100, 250, 100, 30) $contextmenu = GUICtrlCreateContextMenu() $aboutitem = GUICtrlCreateMenuItem("About", $contextmenu) $testitem = GUICtrlCreateMenuItem("Test", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) $exititem = GUICtrlCreateMenuItem("Exit", $contextmenu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $button MsgBox(64, "Test", "You typed..." & GUICtrlRead($input), 3) Case $exititem ExitLoop Case $aboutitem MsgBox(0, "About", "A simple example with a context menu!") EndSwitch WEndM23Edit: When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. Edited June 15, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LYRRAD Posted June 16, 2010 Author Share Posted June 16, 2010 Thank you very much for the correction. The next time I will do as you stated when posting code. Link to comment Share on other sites More sharing options...
LYRRAD Posted June 16, 2010 Author Share Posted June 16, 2010 I am now trying to record the coordinates of the mouse position where the context menu was brought up. I have it when 'TEST' is clicked in the context menu the coordinates of the mouse is shown but only depending on where you clicked on the 'TEST' context menu item. Again...help is greatly appreciated. Thank you in advance. #include <GUIConstantsEx.au3> Opt("MouseCoordMode",0) GUICreate("Site Check",800,600) GUICtrlCreatePic("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\blue hills.jpg",-1,-1,0,0) GUICtrlSetState(-1,$GUI_DISABLE) $input=GUICtrlCreateInput("",50,200,200,20) $button=GUICtrlCreateButton("Test",100,250,100,30) $contextmenu=GuiCtrlCreateContextMenu() $aboutitem=GuiCtrlCreateMenuitem("About",$contextmenu) $testitem=GUICtrlCreateMenuItem("Test",$contextmenu) GuiCtrlCreateMenuitem("",$contextmenu) $exititem=GuiCtrlCreateMenuitem("Exit",$contextmenu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $button MsgBox(64,"Test","You typed..."&GUICtrlRead($input),3) Case $aboutitem Msgbox(0,"About","A simple example with a context menu!") Case $testitem $mousepos=MouseGetPos() MsgBox(0,"Mouse x,y:",$mousepos[0]&","&$mousepos[1]) Case $exititem ExitLoop EndSwitch WEnd Link to comment Share on other sites More sharing options...
LYRRAD Posted June 17, 2010 Author Share Posted June 17, 2010 I solved my problem. I used the '_IsPressed' command and checked for the right click. Later I will modify it to change the clicking method to accomodate people that have there mouse buttons switched within Windows. Again thank you all. I have posted my code to so others can see what I did and possibly assist others. I am still open to any other suggestions on how to do this...its just that this is working so I will stick with this solution for now. #include <GUIConstantsEx.au3> #Include <Misc.au3> Opt("MouseCoordMode",0) GUICreate("Site Check",800,600) GUICtrlCreatePic("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\blue hills.jpg",-1,-1,0,0) GUICtrlSetState(-1,$GUI_DISABLE) $input=GUICtrlCreateInput("",50,200,200,20) $button=GUICtrlCreateButton("Test",100,250,100,30) $contextmenu=GuiCtrlCreateContextMenu() $aboutitem=GuiCtrlCreateMenuitem("About",$contextmenu) $testitem=GUICtrlCreateMenuItem("Test",$contextmenu) GuiCtrlCreateMenuitem("",$contextmenu) $exititem=GuiCtrlCreateMenuitem("Exit",$contextmenu) GUISetState() While 1 If _IsPressed("02") Then $mousepos=GUIGetCursorInfo() EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $button MsgBox(64,"Test","You typed..."&GUICtrlRead($input),3) Case $aboutitem Msgbox(0,"About","A simple example with a context menu!") Case $testitem MsgBox(0,"Mouse x,y:",$mousepos[0]&","&$mousepos[1]) Case $exititem ExitLoop EndSwitch WEnd 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