Sign in to follow this  
Followers 0
bstewart

My Buttons dont work...why?

2 posts in this topic

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.

#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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0