multiloser Posted May 9, 2008 Share Posted May 9, 2008 Hey guys, so below what I have is a code that I'm trying to put together to make a cool little application, but I can't seem to get a button to work. Essentially what the program does is plot a graph with three points, and then when I press a button, I want it to plot another point. You will see below in the coding that the button is named "$Red." The "If $msg = $Red Then" has a MsgBox after it, so if it successfully satisfies $msg=$red, a msgbox will appear. This isnt happening for me, though. I tried various things, and I'm not sure what I should do now. Can anyone shed some light on my dilemna? Sorry for the messy code. If you need help understanding anything, please ask. CODE#include <GUIConstants.au3> #include <Misc.au3> Opt("GUIOnEventMode", 1) Opt("MouseCoordMode",0) $width = 700 ;default 345 $height = 700 ;default 330 GUICreate("Chaos Game", $width, $height) GUISetOnEvent($GUI_EVENT_CLOSE,"close") $GraphWidth = 650 $GraphHeight = 650 $graph = GUICtrlCreateGraphic(25, 25, $GraphWidth, $GraphHeight) GUICtrlSetBkColor(-1,0xFFFFFF) ;graph background colour GUICtrlSetColor(-1,0x000000) ;graph border colour GUICtrlSetGraphic(-1,$GUI_GR_HINT,0) ;turn off hints ;$coord = GUICtrlCreateLabel("mouse co-ord: ",80,300,200,15,$SS_CENTER) Global $coord1x = 325 Global $coord1y = 75 GUICtrlSetGraphic($graph,$GUI_GR_COLOR, 0xec1a23) GUICtrlSetGraphic($graph,$GUI_GR_Pixel,$coord1x,$coord1y) ;;;;;;;; RED DOT GUICtrlSetGraphic($graph,$GUI_GR_Rect,$coord1x-1,$coord1y-1,3,3) GUICtrlSetGraphic($graph,$GUI_GR_Rect,$coord1x-2,$coord1y-2,5,5) Global $coord2x = 25 Global $coord2y = 570 GUICtrlSetGraphic($graph,$GUI_GR_COLOR, 0x0000fe) GUICtrlSetGraphic($graph,$GUI_GR_Pixel,$coord2x,$coord2y) ;;;;;;;; BLUE DOT GUICtrlSetGraphic($graph,$GUI_GR_Rect,$coord2x-1,$coord2y-1,3,3) GUICtrlSetGraphic($graph,$GUI_GR_Rect,$coord2x-2,$coord2y-2,5,5) Global $coord3x = 625 Global $coord3y = 570 GUICtrlSetGraphic($graph,$GUI_GR_COLOR, 0x00fe00) GUICtrlSetGraphic($graph,$GUI_GR_Pixel,$coord3x,$coord3y) ;;;;;;;; GREEN DOT GUICtrlSetGraphic($graph,$GUI_GR_Rect,$coord3x-1,$coord3y-1,3,3) GUICtrlSetGraphic($graph,$GUI_GR_Rect,$coord3x-2,$coord3y-2,5,5) Global $currentx = 300 Global $currenty = 300 Global $Red = GuiCtrlCreateButton("Red", 5, 675, 129, 28) GUISetState() Do $msg = GuiGetMsg() If $msg = $red Then MsgBox (0, "2", "2") $newx = ($currentx + $coord1x)/2 $newy = ($currenty + $coord1y)/2 GUICtrlSetGraphic($graph,$GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic($graph,$GUI_GR_pixel,$newx,$newy) $currentx = $newx $currenty = $newy GUICtrlSetGraphic($graph,$GUI_GR_REFRESH) EndIf Sleep(1) Until $msg = $GUI_EVENT_CLOSE func close() Exit EndFunc Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 9, 2008 Share Posted May 9, 2008 Hey guys, so below what I have is a code that I'm trying to put together to make a cool little application, but I can't seem to get a button to work.Essentially what the program does is plot a graph with three points, and then when I press a button, I want it to plot another point.You will see below in the coding that the button is named "$Red." The "If $msg = $Red Then" has a MsgBox after it, so if it successfully satisfies $msg=$red, a msgbox will appear. This isnt happening for me, though. I tried various things, and I'm not sure what I should do now. Can anyone shed some light on my dilemna? Sorry for the messy code.If you need help understanding anything, please ask.CODE#include <GUIConstants.au3>#include <Misc.au3>Opt("GUIOnEventMode", 1);...Do $msg = GuiGetMsg() If $msg = $red Then MsgBox (0, "2", "2") ; ...Until $msg = $GUI_EVENT_CLOSEYou can't mix GuiOnEventMode and a GuiGetMsg() loop. Pick one or the other. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
multiloser Posted May 9, 2008 Author Share Posted May 9, 2008 Sweet, that was the issue. Thanks a bunch! 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