bstewart Posted September 14, 2009 Posted September 14, 2009 I usually don't post, most questions are answered somewhere in the forums. I don't usually do GUI stuff in AutoIT3 and it probably something stupid, but.... can someone tell me why my buttons will not work? I have taken my functions out and added simple message boxes and even they don't work. Onceit is pointed out I will bang my head onthe table I am sure, but I am not seeing the problem. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <File.au3> dim $aRecords dim $tank1 dim $tank2 dim $tank3 dim $tank4 dim $tanks dim $price1 dim $price2 dim $price3 dim $price4 $tank1 = IniRead("C:\resources\store.ini", "Fuel", "Tank1", "NotFound") $tank2 = IniRead("C:\resources\store.ini", "Fuel", "Tank2", "NotFound") $tank3 = IniRead("C:\resources\store.ini", "Fuel", "Tank3", "NotFound") $tank4 = IniRead("C:\resources\store.ini", "Fuel", "Tank4", "NotFound") $tanks = IniRead("C:\resources\store.ini", "Fuel", "Tanks", "NotFound") #Region ### START Koda GUI section ### Form=C:\Documents and Settings\All Users\Start Menu\Programs\AutoIt v3\Forms\fuelform.kxf $Form1 = GUICreate("Fuel Price Change", 657, 447, 219, 124) $grpCurrent = GUICtrlCreateGroup("Current Prices", 32, 33, 161, 177) $lblCurrentFuel1 = GUICtrlCreateLabel($tank1, 48, 64, 38, 17) $lblCurrentFuel2 = GUICtrlCreateLabel($tank2, 48, 94, 24, 17) $lblCurrentFuel3 = GUICtrlCreateLabel($tank3, 48, 125, 32, 17) $lblCurrentFuel4 = GUICtrlCreateLabel($tank4, 48, 162, 23, 17) $txtCurrentFuel1 = GUICtrlCreateInput("", 120, 64, 65, 21) $txtCurrentFuel2 = GUICtrlCreateInput("", 120, 97, 65, 21) $txtCurrentFuel3 = GUICtrlCreateInput("", 120, 130, 65, 21) $txtCurrentFuel4 = GUICtrlCreateInput("", 120, 165, 65, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpNew = GUICtrlCreateGroup("New Prices", 208, 34, 169, 177) $lblNewFuel1 = GUICtrlCreateLabel($tank1, 217, 69, 38, 17) $lblNewFuel2 = GUICtrlCreateLabel($tank2, 217, 99, 24, 17) $lblNewFuel3 = GUICtrlCreateLabel($tank3, 217, 130, 32, 17) $lblNewFuel4 = GUICtrlCreateLabel($tank4, 217, 167, 23, 17) $txtNewFuel1 = GUICtrlCreateInput("", 273, 61, 65, 21) GUICtrlSetTip(-1, "Put New Price In This Field") $txtNewFuel2 = GUICtrlCreateInput("", 273, 94, 65, 21) $txtNewFuel3 = GUICtrlCreateInput("", 273, 127, 65, 21) $txtNewFuel4 = GUICtrlCreateInput("", 273, 162, 65, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpComp = GUICtrlCreateGroup("Competition", 385, 35, 161, 177) $lblCompFuel1 = GUICtrlCreateLabel($tank1, 400, 71, 38, 17) $lblCompFuel2 = GUICtrlCreateLabel($tank2, 400, 101, 24, 17) $lblCompFuel3 = GUICtrlCreateLabel($tank3, 400, 132, 32, 17) $lblCompFuel4 = GUICtrlCreateLabel($tank4, 400, 169, 23, 17) $txtCompFuel1 = GUICtrlCreateInput("", 456, 63, 65, 21) $txtCompFuel2 = GUICtrlCreateInput("", 456, 96, 65, 21) $txtCompFuel3 = GUICtrlCreateInput("", 456, 129, 65, 21) $txtCompFuel4 = GUICtrlCreateInput("", 456, 164, 65, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $btnGetCurrent = GUICtrlCreateButton("Get Current Prices", 32, 224, 100, 30, $BS_FLAT) GUICtrlSetOnEvent($btnGetCurrent, "btnGetCurrentClick") $btnSendNew = GUICtrlCreateButton("Send New Prices", 208, 224, 100, 30, $BS_FLAT) GUICtrlSetOnEvent($btnSendNew, "btnSendNewClick") $btnPostChange = GUICtrlCreateButton("Not Used", 384, 224, 100, 30, $BS_FLAT) GUICtrlSetOnEvent($btnPostChange, "btnPostChangeClick") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;Runs getprice.bat and waits to finish ;RunWait(@ComSpec & " /c " & "c:\gemcom\config\getprice.bat") ; If Not _FileReadToArray("c:\gemcom\config\fprice1.cfg",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf ;reads ftank. For $x = 1 to $tanks $aRecords[$x] = StringMid($aRecords[$x], 18, 5) $price1 = $aRecords[1] $price2 = $aRecords[2] $price3 = $aRecords[3] $price4 = $aRecords[4] Next $txtCurrentFuel1 = GUICtrlSetData ( $txtCurrentFuel1, $price1 , "n/a" ) $txtCurrentFuel2 = GUICtrlSetData ( $txtCurrentFuel2, $price2 , "n/a" ) $txtCurrentFuel3 = GUICtrlSetData ( $txtCurrentFuel3, $price3 , "n/a" ) $txtCurrentFuel4 = GUICtrlSetData ( $txtCurrentFuel4, $price4 , "n/a" ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func btnGetCurrentClick() MsgBox(0, "GUI Event", "You pressed OK!") EndFunc Func btnPostChangeClick() MsgBox(0, "GUI Event", "You pressed OK!") EndFunc Func btnSendNewClick() MsgBox(0, "GUI Event", "You pressed OK!") EndFunc
water Posted September 14, 2009 Posted September 14, 2009 (edited) Insert Opt("GUIOnEventMode", 1)at the beginning of your script. But now you can't exit your script anymore. You have to decide how to build your GUI - event mode or message loop mode. Please see GUI Reference -> GUI concepts in the help file. Edited September 14, 2009 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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