robj Posted March 21, 2005 Posted March 21, 2005 I'm pretty new to AutoIt (been coding now for about 4 1/2 hours), and I can't seem to get my gui to respond to clicking buttons. Am I being stupid? Most of this code just draws out a fullscreen gui with a few buttons, and I just want to confirm that the mouseclicks are registering on the buttons before I try and do anything clever with my code. Can annybody spot any stupid mistakes? #include <GuiConstants.au3> If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 ; Picture files used $farapack = "F:\My Documents\PhD\Data Collection Front End\AutoIt\farapackengineering.bmp" ; create window GuiCreate("Human Strength Testing - Data Collection", @DesktopWidth , @DesktopHeight, 0 , 0 , $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_MAXIMIZE , $WS_EX_TOPMOST) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode for gui operation ; Opt("TrayIconDebug",1) ; debug mode ; Find middle point of screen $mid_x = @DesktopWidth / 2 $mid_y = @DesktopHeight / 2 ; first set up layout of gui ; Gender selection buttons, age box & label GuiSetFont( 18 , 400 , 0 , "ariel" ) GuiCtrlCreateGroup("" , $mid_x - 225 , 3 * @DesktopHeight / 4 - 110 , 450, 85) $male = GuiCtrlCreateRadio("Male" , $mid_x + 50 + 25, 3 * @DesktopHeight / 4 - 85 , 100, 20) $female = GuiCtrlCreateRadio("Female", $mid_x + 50 + 25, 3 * @DesktopHeight / 4 - 55 , 100, 20) GuiCtrlCreateLabel("Age", $mid_x - 195, 3 * @DesktopHeight / 4 - 73 , 85, 35) $age = GuiCtrlCreateInput("", $mid_x - 140, 3 * @DesktopHeight / 4 - 78 , 85, 35 , $ES_CENTER) GUICtrlSetState(-1,$GUI_FOCUS) GuiCtrlCreateLabel("Please enter your age and gender", $mid_x - 200, 3 * @DesktopHeight / 4 - 135, 400, 30, $SS_CENTER) ; Start button, process button and progress bar GuiSetFont( 18 , 400 , 0 , "ariel" ) $button_width = 200 $button_height = 75 $start = GuiCtrlCreateButton("Start Test", $mid_x - $button_width - 25 , 3 * @DesktopHeight / 4, $button_width , $button_height) $process = GUICtrlCreateButton("Process Data", $mid_x + 25 , 3 * @DesktopHeight / 4, $button_width , $button_height) $progress = GuiCtrlCreateProgress( $mid_x - $button_width - 25 , 3 * @DesktopHeight / 4 + $button_height + 25 , 2 * $button_width + 50 , 25 ) ; Adds pictues (uses paths/names from start of file) GuiCtrlCreatePic($farapack, @DesktopWidth - 101, @DesktopHeight - 184 , 101 , 166 ) ; $Pic_7 = GuiCtrlCreatePic("Pic7", 610, 350, 280, 260) GUICtrlSetOnEvent($process, "ProcessButton") GUICtrlSetOnEvent($start, "StartButton") While 1 Sleep(100) Wend Func ProcessButton() MsgBox(0x40000, "GUI Event", "You clicked PROCESS") EndFunc Func StartButton() MsgBox(262144, "GUI Event", "You clicked START") EndFunc
Developers Jos Posted March 21, 2005 Developers Posted March 21, 2005 Add GUISetState(@SW_SHOW) like: GUICtrlSetOnEvent($process, "ProcessButton") GUICtrlSetOnEvent($start, "StartButton") GUISetState(@SW_SHOW) While 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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