litlmike Posted March 14, 2006 Posted March 14, 2006 I have a GUI that I want to add the numbers that I input, as I input them. For instance, if I enter 5, 5, 5, I want the GUI to show me 15. I would like to have this happen in 'real-time' as I input the numbers. A stripped down version of the code is below. So below the label 'Total Price', I want a running count of the number I type in the input boxes. How do I accomplish this? 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, $sf_input2, $sf_input3, $CIS_input, $DA_input, $FA_input Global $DA_input HotKeySet("^7","GUI_Pick_Proposal_Types") HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;;;; 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 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) $v = 250 $Z = 325 $sf_input1 = GUICtrlCreateInput ("",$z,$a, 35) $sf_input2 = GUICtrlCreateInput ("",$z,$a + ($y), 35) $sf_input3 = GUICtrlCreateInput ("",$z,$a + ($y)*2, 35) GUICtrlCreateLabel ("Enter the Discount per SF", $Z-50 ,10 ) $b = 310 GUICtrlCreateLabel ("Total Price", $Z,310 ) GUICtrlCreateLabel (GUICtrlRead($sf_input1), $Z,$b + 15 ); Here is where the 'Real-Time' should happen GUISetState() ; will display an empty dialog box ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() ;If $msg = $done Then Exit If $msg = $Calc Then ;WriteProposal() GUISetState(@SW_SHOW) EndIf If $msg = $sf_input1 Then GUICtrlRead($sf_input1); get the value ;GUICtrlRead($discount); get the value EndIf If $msg = $sf_input2 Then GUICtrlRead($sf_input2); get the value ;GUICtrlRead($discount); get the value EndIf If $msg = $sf_input3 Then GUICtrlRead($sf_input3); get the value ;GUICtrlRead($discount); get the value EndIf If $msg = $CIS_input Then GUICtrlRead($CIS_input) EndIf If $msg = $DA_input Then GUICtrlRead($DA_input) EndIf If $msg = $FA_input Then GUICtrlRead($FA_input) EndIf Until $msg = $GUI_EVENT_CLOSE Return EndFunc _ArrayPermute()_ArrayUnique()Excel.au3 UDF
CyberSlug Posted March 14, 2006 Posted March 14, 2006 One way: Put the following inside your main message loop. $tempTotal = GUICtrlRead($sf_input1) + GUICtrlRead($sf_input2) + GUICtrlRead($sf_input3) ToolTip($tempTotal) If $tempTotal <> $total Then $total = $tempTotal GuiCtrlSetData($TotalLabelUpdatedInRealTim, $total) EndIf P.S. It might help if you told us that we must press Ctrl+7 in order for any GUI to apper! Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
litlmike Posted March 14, 2006 Author Posted March 14, 2006 One way: Put the following inside your main message loop. $tempTotal = GUICtrlRead($sf_input1) + GUICtrlRead($sf_input2) + GUICtrlRead($sf_input3) ToolTip($tempTotal) If $tempTotal <> $total Then $total = $tempTotal GuiCtrlSetData($TotalLabelUpdatedInRealTim, $total) EndIf P.S. It might help if you told us that we must press Ctrl+7 in order for any GUI to apper! Yea I guess you are right, I shoulda told you about the hot key. Lol. Thanks for the feedback. I notice you are a big fan of the ToolTip Option. Though this is a viable option, I would prefer to make a GUICtrlCreateLabel that adds up the total (the GUI will have lots more info in there, and it would look better in the final version). Is there a way to make a GUICtrlCreateLabel add in real-time. $b = 310 GUICtrlCreateLabel ("Total Price", $Z,310 ) GUICtrlCreateLabel (GUICtrlRead($sf_input1), $Z,$b + 15 ); Here is where the 'Real-Time' should happen _ArrayPermute()_ArrayUnique()Excel.au3 UDF
CyberSlug Posted March 14, 2006 Posted March 14, 2006 (edited) Is there a way to make a GUICtrlCreateLabel add in real-time. ToolTip was only for debugging. You have to have a reference to the label $TotalLabelUpdatedInRealTim (oops, missing the last letter e) $b = 310 GUICtrlCreateLabel ("Total Price", $Z,310 ) $TotalLabelUpdatedInRealTime = GUICtrlCreateLabel (GUICtrlRead($sf_input1), $Z,$b + 15 ); Here is where the 'Real-Time' should happen Edit: typos fixed Edited March 14, 2006 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
litlmike Posted March 14, 2006 Author Posted March 14, 2006 (edited) ToolTip was only for debugging. You have to have a reference to the label $TotalLabelUpdatedInRealTim (oops, missing the last letter e) $b = 310 GUICtrlCreateLabel ("Total Price", $Z,310 ) $TotalLabelUpdatedInRealTime = GUICtrlCreateLabel (GUICtrlRead($sf_input1), $Z,$b + 15 ); Here is where the 'Real-Time' should happen Edit: typos fixed Ahh, I think I understand now. Now, what if I wanted to multiply these seperate variables by some number? For instance I want to multiply $sf_input1 by $var (another input from GUI). This should affect the $TotalLabelUpdatedInRealTime, but what is the syntax for something like this. Thanks again. **EDIT** I think I know the psuedocode for this. GUICtrlREAD $var, create new variable that multiplies $var by $sf_input1, then somehow add that to $TotalLabelUpdatedInRealTime. But, I am not quite sure how to do this yet. Edited March 14, 2006 by litlmike _ArrayPermute()_ArrayUnique()Excel.au3 UDF
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