Jump to content

Help In Incriment Code


Recommended Posts

I wonder How to Make An Incriment Code

 

Each Time The Button Is Pressed It Adds 1 to A Label A tried This Code But it Didnot Do The Job !

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 520, 247, 287, 270)
$Input1 = GUICtrlCreateInput("Input1", 104, 48, 305, 21)

$Button1 = GUICtrlCreateButton("Button1", 144, 144, 121, 33)
GUICtrlSetOnEvent (-1 , 'Add')
GUISetState(@SW_SHOW)
HotKeySet("x", "add")
#EndRegion ### END Koda GUI section ###



Func Add () 
$Label1 = GUICtrlCreateLabel("0", 192, 96, 36, 17)
$HLabel1 = GUICtrlRead($Label1)

$hLabel1 += 1
GUICtrlSetData($Label1, $hlabel1 )

EndFunc 
While 1
    Sleep(500)
Wend
Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
$x = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 520, 247, 287, 270)
$Input1 = GUICtrlCreateInput("Input1", 104, 48, 305, 21)

$Button1 = GUICtrlCreateButton("Button1", 144, 144, 121, 33)
GUICtrlSetOnEvent (-1 , 'Add')
GUISetState(@SW_SHOW)
HotKeySet("x", "add")
#EndRegion ### END Koda GUI section ###

Func Add ()
$Label1 = GUICtrlCreateLabel("0", 192, 96, 36, 17)
$HLabel1 = GUICtrlRead($Label1)

GUICtrlSetData($Label1, $x)
$x = $x + 1
EndFunc
While 1
    Sleep(500)
Wend

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
$x = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 520, 247, 287, 270)
$Input1 = GUICtrlCreateInput("Input1", 104, 48, 305, 21)

$Button1 = GUICtrlCreateButton("Button1", 144, 144, 121, 33)
GUICtrlSetOnEvent (-1 , 'Add')
GUISetState(@SW_SHOW)
HotKeySet("x", "add")
#EndRegion ### END Koda GUI section ###

Func Add ()
$Label1 = GUICtrlCreateLabel("0", 192, 96, 36, 17)
$HLabel1 = GUICtrlRead($Label1)

GUICtrlSetData($Label1, $x)
$x = $x + 1
EndFunc
While 1
    Sleep(500)
Wend

 

Thats It :D .... Damn I Need A cup of a Coffee or Get some Sleep :D (iTs 3.30 Am )

Link to comment
Share on other sites

Nah, your code works fine if you place the label creation further up, out of the func, so you dont create it every time the function is called, but only updates.

Here

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 520, 247, 287, 270)
$Input1 = GUICtrlCreateInput("Input1", 104, 48, 305, 21)
$Label1 = GUICtrlCreateLabel("0", 192, 96, 36, 17)
$Button1 = GUICtrlCreateButton("Button1", 144, 144, 121, 33)
GUICtrlSetOnEvent (-1 , 'Add')
GUISetState(@SW_SHOW)
HotKeySet("x", "add")
#EndRegion ### END Koda GUI section ###



Func Add ()

$HLabel1 = GUICtrlRead($Label1)

$hLabel1 += 1
GUICtrlSetData($Label1, $hlabel1 )

EndFunc
While 1
    Sleep(500)
Wend

Some guy's script + some other guy's script = my script!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...