litlmike Posted March 14, 2006 Share Posted March 14, 2006 To see the GUI, press Ctrl + 7. I am trying to determine why the default value for my label is 145081.36 (Bottom-Right Hand Corner). I want it to be 0. The Value 0, not the Text 0. I assume it is calculating the value of my Input Boxes (which it should do). If this is true, then I assume my Input Value is not 0, even though it visually 'says' 0. How do I set the data value of my input boxes to 0? expandcollapse popup#include <IE.au3> #include <Date.au3> #include <GUIConstants.au3> ;Making GUI for 'How Many Storefronts?' Global $Paused, $o_IE Global $Paused, $cat_1, $cat_2, $cat_3, $discount, $cat_1A, $cat_2A, $cat_3A, $street, $city, $state, $Province, $Zip, $Country,$o_IE Global $company, $date_e, $date_i, $discountB, $o_Keywords, $contact, $email, $Calc, $total HotKeySet("^7","GUI_Pick_Proposal_Types") HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") #cs HotKeySet("^4","Other") #ce ;;;; Body of program would go here;;;; While 1 Sleep(100) WEnd ;;;;;;;; ; Pause and Escape Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() MsgBox(4096,"","This is a message.") EndFunc Func GUI_Pick_Proposal_Types () ;Make GUI GUICreate("Input Data", 400, 450); ,(@DesktopWidth-640), (@DesktopHeight)/4 GUISetState(@SW_SHOW) ; will display an empty dialog box $a = 30 $y = 40 GUICtrlCreateLabel ("Enter the # of Storefronts @ $2997", 10, $a) GUICtrlCreateLabel ("Enter the # of Storefronts @ $2597", 10, $a + $y) GUICtrlCreateLabel ("Enter the # of Storefronts @ $2200", 10, $a + ($y)*2) GUICtrlCreateLabel ("Enter the # of CIS", 10, $a + ($y)*3) GUICtrlCreateLabel ("Enter the # of DA", 10, $a + ($y)*4) GUICtrlCreateLabel ("Enter the # of FA", 10, $a + ($y)*5) $Z = 325 $zero = 0 $sf_input1 = GUICtrlCreateInput ($zero,$z,$a, 35); right side boxes $sf_input2 = GUICtrlCreateInput ($zero,$z,$a + ($y), 35) $sf_input3 = GUICtrlCreateInput ($zero,$z,$a + ($y)*2, 35) $CIS_input = GUICtrlCreateInput ($zero,$z,$a + ($y)*3, 35) $DA_input = GUICtrlCreateInput ($zero,$z,$a + ($y)*4, 35) $FA_input = GUICtrlCreateInput ($zero,$z,$a + ($y)*5, 35) GUICtrlCreateLabel ("Enter the Discount per SF", $Z,10 ) $v = 250 $sf_input1a = GUICtrlCreateInput ($zero,$v,$a, 35); left side boxes $sf_input2a = GUICtrlCreateInput ($zero,$v,$a + ($y), 35) $sf_input3a = GUICtrlCreateInput ($zero,$v,$a + ($y)*2, 35) $CIS_inputa = GUICtrlCreateInput ($zero,$v,$a + ($y)*3, 35) $DA_inputa = GUICtrlCreateInput ($zero,$v,$a + ($y)*4, 35) $FA_inputa = GUICtrlCreateInput ($zero,$v,$a + ($y)*5, 35) $SF1 = 2997 $SF2 = 2597 $SF3 = 2200 $FA = 97 $DA = .018 $CIS = 597 $b = 310 GUICtrlCreateLabel ("Total Price", $Z,310 ) $TotalLabelUpdatedInRealTime = GUICtrlCreateLabel ("", $Z,$b + 15,50 ); Here is where the 'Real-Time' should happen GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() $tempTotal = ($FA_inputa * $FA) + ($sf_input1a * $SF1) + ($sf_input2a * $SF2) + ($sf_input3a * $SF3) + ($CIS_inputa * $CIS) + ($DA_inputa * $DA) If $tempTotal <> $total Then $total = $tempTotal GuiCtrlSetData($TotalLabelUpdatedInRealTime, $total) EndIf If $msg = $Calc Then ;WriteProposal() GUISetState(@SW_SHOW) EndIf If $msg = $sf_input1 Then $sf_input1 = GUICtrlRead($sf_input1); get the value ;GUICtrlRead($discount); get the value EndIf If $msg = $sf_input2 Then $sf_input2 = GUICtrlRead($sf_input2); get the value ;GUICtrlRead($discount); get the value EndIf If $msg = $sf_input3 Then $sf_input3 = GUICtrlRead($sf_input3); get the value ;GUICtrlRead($discount); get the value EndIf If $msg = $CIS_input Then $CIS_input = GUICtrlRead($CIS_input) EndIf If $msg = $DA_input Then $DA_input = GUICtrlRead($DA_input) EndIf If $msg = $FA_input Then $FA_input = GUICtrlRead($FA_input) EndIf If $msg = $sf_input1a Then $sf_input1a = GUICtrlRead($sf_input1a) EndIf If $msg = $sf_input2a Then $sf_input2a = GUICtrlRead($sf_input2a) EndIf If $msg = $sf_input3a Then $sf_input3a = GUICtrlRead($sf_input3a) EndIf If $msg = $CIS_inputa Then $CIS_inputa = GUICtrlRead($CIS_inputa) EndIf If $msg = $DA_inputa Then $DA_inputa = GUICtrlRead($DA_inputa) EndIf If $msg = $FA_inputa Then $FA_inputa = GUICtrlRead($FA_inputa) EndIf Until $msg = $GUI_EVENT_CLOSE Return EndFunc _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 14, 2006 Moderators Share Posted March 14, 2006 This is confusing... I'm not sure I understand what you mean... can you look at this scaled down gui, and give an example of what your trying to accomplish... because I'm using a string to give the value, and then reading it compared to an integer value, and you still get the correct answer... so I'm lost:#include <guiconstants.au3> Local $blah = '0' $main = GUICreate('MYGUI', 200, 100) $input = GUICtrlCreateInput($blah, 10, 10, 180, 20) $button = GUICtrlCreateButton('Get Values', 10, 40) GUISetState() While 1 $msg = GUIGetMsg() If $msg = - 3 Then Exit If $msg = $button Then If GUICtrlRead($input) = 0 Then; notice using 0 not '0' MsgBox(0, 'test', 'The value is zero') EndIf EndIf WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
litlmike Posted March 14, 2006 Author Share Posted March 14, 2006 This is confusing... I'm not sure I understand what you mean... can you look at this scaled down gui, and give an example of what your trying to accomplish... because I'm using a string to give the value, and then reading it compared to an integer value, and you still get the correct answer... so I'm lost:#include <guiconstants.au3> Local $blah = '0' $main = GUICreate('MYGUI', 200, 100) $input = GUICtrlCreateInput($blah, 10, 10, 180, 20) $button = GUICtrlCreateButton('Get Values', 10, 40) GUISetState() While 1 $msg = GUIGetMsg() If $msg = - 3 Then Exit If $msg = $button Then If GUICtrlRead($input) = 0 Then; notice using 0 not '0' MsgBox(0, 'test', 'The value is zero') EndIf EndIf WEnd I will try to clarify. I do admit that in your script it seems that the 'value' and the 'text' equal the same. My script, however crude the methods are, should do 2 things. 1) when the GUI appears have a value in the bottom-right corner that reads 0. 2) when the user inputs numbers, should use the formulas in the script to change the value in the bottom-right hand corner. The value is a label found here: $TotalLabelUpdatedInRealTime = GUICtrlCreateLabel ("", $Z,$b + 15,50 ); Here is where the 'Real-Time' should happen For some crazy reason, when I open the GUI using Ctrl + 7, it reads '145081.36', instead of 0. Does that happen to you when you run my script? _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 14, 2006 Moderators Share Posted March 14, 2006 (edited) It reads that, because you tell it too$TotalLabelUpdatedInRealTime = GUICtrlCreateLabel ("", $Z,$b + 15,100 ); Here is where the 'Real-Time' should happen GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() $tempTotal = ($FA_inputa * $FA) + ($sf_input1a * $SF1) + ($sf_input2a * $SF2) + ($sf_input3a * $SF3) + ($CIS_inputa * $CIS) + ($DA_inputa * $DA) If $tempTotal <> $total Then $total = $tempTotal GuiCtrlSetData($TotalLabelUpdatedInRealTime, $total) EndIf Edit: Let me reitterate... your not reading the values of the input boxes and multipling those values with the above set up... your multiplying it by the Control ID's... You have to "Read" (GUICtrlRead()) the input boxes to get the values to use them:$tempTotal = (GUICtrlRead($FA_inputa) * $FA) + (GUICtrlRead($sf_input1a) * $SF1) + _ (GUICtrlRead($sf_input2a) * $SF3) + (GUICtrlRead($CIS_inputa) * $CIS) + (GUICtrlRead($DA_inputa) * $DA) If $tempTotal <> $total Then $total = $tempTotal GuiCtrlSetData($TotalLabelUpdatedInRealTime, $total) ElseIf $tempTotal == 0 Then GuiCtrlSetData($TotalLabelUpdatedInRealTime, $tempTotal) EndIfNotice I did an ElseIf statement also. Edited March 14, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
litlmike Posted March 14, 2006 Author Share Posted March 14, 2006 It reads that, because you tell it too Edit: Let me reitterate... your not reading the values of the input boxes and multipling those values with the above set up... your multiplying it by the Control ID's... You have to "Read" (GUICtrlRead()) the input boxes to get the values to use them:$tempTotal = (GUICtrlRead($FA_inputa) * $FA) + (GUICtrlRead($sf_input1a) * $SF1) + _ (GUICtrlRead($sf_input2a) * $SF3) + (GUICtrlRead($CIS_inputa) * $CIS) + (GUICtrlRead($DA_inputa) * $DA) If $tempTotal <> $total Then $total = $tempTotal GuiCtrlSetData($TotalLabelUpdatedInRealTime, $total) ElseIf $tempTotal == 0 Then GuiCtrlSetData($TotalLabelUpdatedInRealTime, $tempTotal) EndIfNotice I did an ElseIf statement also.OOOOOH! Yes you are correct! One more question if you don't mind. How do I make the script keep a running total? Instead of resetting to 0 when moving to the next InputBox? _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2006 Moderators Share Posted March 15, 2006 OOOOOH! Yes you are correct!One more question if you don't mind. How do I make the script keep a running total? Instead of resetting to 0 when moving to the next InputBox?GUICtrlSetData() Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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