Jump to content



Photo

Problem with gui ctrl set data


  • Please log in to reply
3 replies to this topic

#1 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 17 March 2012 - 02:51 AM

AutoIt         
#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example()     Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m     GUICreate("My GUI Progressbar", 220, 100, 100, 200)     $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)     $button = GUICtrlCreateButton("Start", 75, 70, 70, 20)     GUISetState()     Local $i = 0     Do         $msg = GUIGetMsg()         If $msg = $button Then                     GUICtrlSetData($progressbar1, $i += 10)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i += 10)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i += 10)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i += 10)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i += 10)                     Sleep(300)         EndIf     Until $msg = $GUI_EVENT_CLOSE EndFunc   ;==>Example

Modified sample script from the GuiCtrlCreateProgress
When I try and run I get an error parsing function call with the $i += 10
I'm not sure why I can't preform this operation.





#2 JLogan3o13

JLogan3o13

    Down to 98

  • MVPs
  • 2,070 posts

Posted 17 March 2012 - 03:36 AM

Hi, kor. A couple of ways you can do it, as GUICtrlSetData does not like the += attempt at incrementing. From your example, this is the simplest:


Plain Text         
#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example()     Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m     GUICreate("My GUI Progressbar", 220, 100, 100, 200)     $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)     $button = GUICtrlCreateButton("Start", 75, 70, 70, 20)     GUISetState()     Local $i = 0     Do         $msg = GUIGetMsg()         If $msg = $button Then                     GUICtrlSetData($progressbar1, $i + 10)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i + 20)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i + 30)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i + 40)                     Sleep(300)                     GUICtrlSetData($progressbar1, $i + 50)                     Sleep(300)         EndIf     Until $msg = $GUI_EVENT_CLOSE EndFunc   ;==>Example  

J.I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, SCCM 2007 Front End, Windows Firewall UDF

#3 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 17 March 2012 - 03:38 AM

I cheated and took the easy way out.
     $iBarCount += 5 ; step the precentage         GUICtrlSetData($hBar, $iBarCount) ; set the progress bar percentage         Sleep(200) ; sleep to allow time to see progress step and read messages


#4 JLogan3o13

JLogan3o13

    Down to 98

  • MVPs
  • 2,070 posts

Posted 17 March 2012 - 03:56 AM

Easy is what we're aiming for. Glad you worked it out :oops:
J.I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, SCCM 2007 Front End, Windows Firewall UDF




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users