Kohr Posted November 15, 2006 Share Posted November 15, 2006 I am trying to use GUICtrlCreateUpdown in several Inputs that will adjust another label. I have about 30 Input controls that this would be used on and I was hoping there is an easier way to accomplish this task. This will eventually be used to simulate betting where you increase different bet type fields and for each bet placed it will take your money away (one label used to indicate this). Kohr Attached example expandcollapse popup#include "GUIConstants.au3" Opt("GUIOnEventMode", 1) GUICreate("", 200, 200) $input = GUICtrlCreateInput("0", 10, 10, 50, 20, $ES_NUMBER) $updown = GUICtrlCreateUpdown($input) GUICtrlSetLimit($updown, 100, 0) GUICtrlSetOnEvent($updown, "test") Global $old = 0 $input2 = GUICtrlCreateInput("0", 70, 10, 50, 20, $ES_NUMBER) $updown2 = GUICtrlCreateUpdown($input2) GUICtrlSetLimit($updown2, 100, 0) GUICtrlSetOnEvent($updown2, "test") Global $old2 = 0 $labelPlayerMoney = GUICtrlCreateLabel("0", 100, 100, 50, 20) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked") While 1 Sleep(200) WEnd Func test() $bumpValue = 10 If $old <> Int(GUICtrlRead($input)) Then If $old < Int(GUICtrlRead($input)) Then; up $old = ((Int(GUICtrlRead($input)) - $old) * $bumpValue) + $old If $old > 100 Then $old = 100 GUICtrlSetData($input, $old) $ret = GUICtrlRead($labelPlayerMoney) GUICtrlSetData($labelPlayerMoney, $ret + $bumpValue) Else $old = (($old - Int(GUICtrlRead($input))) * - $bumpValue) + $old If $old < 0 Then $old = 0 GUICtrlSetData($input, $old) $ret = GUICtrlRead($labelPlayerMoney) GUICtrlSetData($labelPlayerMoney, $ret - $bumpValue) EndIf EndIf If $old2 <> Int(GUICtrlRead($input2)) Then If $old2 < Int(GUICtrlRead($input2)) Then; up $old2 = ((Int(GUICtrlRead($input2)) - $old2) * $bumpValue) + $old2 If $old2 > 100 Then $old2 = 100 GUICtrlSetData($input2, $old2) $ret = GUICtrlRead($labelPlayerMoney) GUICtrlSetData($labelPlayerMoney, $ret + $bumpValue) Else $old2 = (($old2 - Int(GUICtrlRead($input2))) * - $bumpValue) + $old2 If $old2 < 0 Then $old2 = 0 GUICtrlSetData($input2, $old2) $ret = GUICtrlRead($labelPlayerMoney) GUICtrlSetData($labelPlayerMoney, $ret - $bumpValue) EndIf EndIf EndFunc ;==>test Func CloseClicked() Exit EndFunc ;==>CloseClicked AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Valuater Posted November 15, 2006 Share Posted November 15, 2006 (edited) maybe... expandcollapse popup#include "GUIConstants.au3" Opt("GUIOnEventMode", 1) Dim $Input[3], $old[3] For $x = 1 To UBound($old) - 1 $old[$x] = 0 Next GUICreate("", 200, 200) $Input[1] = GUICtrlCreateInput("0", 10, 10, 50, 20, $ES_NUMBER) $updown = GUICtrlCreateUpdown($Input[1]) GUICtrlSetLimit($updown, 100, 0) GUICtrlSetOnEvent($updown, "test") $Input[2] = GUICtrlCreateInput("0", 70, 10, 50, 20, $ES_NUMBER) $updown2 = GUICtrlCreateUpdown($Input[2]) GUICtrlSetLimit($updown2, 100, 0) GUICtrlSetOnEvent($updown2, "test") $labelPlayerMoney = GUICtrlCreateLabel("0", 100, 100, 50, 20) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked") While 1 Sleep(20) WEnd Func test() $bumpValue = 10 For $i = 1 To UBound($Input) - 1 If $old[$i] <> Int(GUICtrlRead($Input[$i])) Then If $old[$i] < Int(GUICtrlRead($Input[$i])) Then; up $old[$i]= ((Int(GUICtrlRead($Input[$i])) - $old[$i]) * $bumpValue) + $old[$i] If $old[$i] > 100 Then $old[$i] = 100 GUICtrlSetData($Input[$i], $old[$i]) $ret = GUICtrlRead($labelPlayerMoney) GUICtrlSetData($labelPlayerMoney, $ret + $bumpValue) Else $old[$i]= (($old[$i] - Int(GUICtrlRead($Input[$i]))) * - $bumpValue) + $old[$i] If $old[$i] < 0 Then $old[$i] = 0 GUICtrlSetData($Input[$i], $old[$i]) $ret = GUICtrlRead($labelPlayerMoney) GUICtrlSetData($labelPlayerMoney, $ret - $bumpValue) EndIf EndIf Next EndFunc ;==>test Func CloseClicked() Exit EndFunc ;==>CloseClicked 8) Edited November 15, 2006 by Valuater Link to comment Share on other sites More sharing options...
Kohr Posted November 15, 2006 Author Share Posted November 15, 2006 Thanks for the help. That should do the trick. I wanted to avoid having 30 If..Then statements and I forgot about the array approach. Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Valuater Posted November 15, 2006 Share Posted November 15, 2006 Welcome 8) 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