chachew Posted August 25, 2011 Share Posted August 25, 2011 Can i use GUICtrlSetOnEvent to call a function upon the loading of the GUI? Im trying to run Func Check() upon the GUI loading but it doesnt seem to be working correctly, any thoughts? ....... ..... GUISetState(@SW_SHOW) GUICtrlSetOnEvent($Form1, "Check") Func Check() If FileExists("C:\cssnlogdir") = 1 Then $onCheck = 1 GUICtrlSetData($lblStatus, "Running") Else $onCheck = 0 GUICtrlSetData($lblStatus, "Off") EndIf EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnStart DirCreate("C:\cssnlogdir") GUICtrlSetData($lblStatus, "Running") GUICtrlSetFont($lblStatus, 11, 400, 0) GUICtrlSetColor($lblStatus, 0xC82536) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2011 Moderators Share Posted August 25, 2011 mkirkland,Ther is no suitable "event" when the GUI is created, so you cannot do it that way. As you are determining when the GUI is loaded, why not just call the function directly once you have created it? ....... ..... GUISetState(@SW_SHOW) Check() While [...] WEnd Func Check() [...] EndFuncYou could always use WinWaitActive to ensure it is visible first if you so desired - although as it appears that you are setting a label within the GUI, I would run the function before the GUISetState so the GUI appeared with the label already set. M23 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...
chachew Posted August 25, 2011 Author Share Posted August 25, 2011 ...why not just call the function directly once you have created it? This worked just fine, thanks for the info, im a newb at Autoit so i didnt figure that out yet 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