Jump to content
Sign in to follow this  
dickep

Please help me figure this out

Recommended Posts

dickep

Hi,

Now I m new to GUI stuff, so please be kind. I also know that possibly my lgic is not on track.

I have an application in Autoit that I want to log/show some data (in this case, just incrementing a counter). I want it to start with a click of Button1 and stop with a click of Button2.

1- I can't get that to happen.

Now, if the process is stopped, I then want it to start again from where it left off, clearing the edit box window of data and dislpaying new data.

2- not working because of #1 above not yet working.

Any help, hints, tips, tricks, etc., are greatly appreciated.

Code attached for my example.

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

Global $s = 1
global $something

Global Const $SB_SCROLLCARET = 0xB7

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 301, 301, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Button1", 32, 216, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 160, 216, 75, 25, 0)
GUICtrlSetOnEvent($Button2, "Button2Click")
$Edit1 = GUICtrlCreateEdit("", 176, 40, 97, 137)
GUICtrlSetData($Edit1, "Edit1")
GUICtrlSetOnEvent($Edit1, "Edit1Change")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    $something = 1
    _DoSomething()
EndFunc

Func Button2Click()
    MsgBox(0,"MESSAGE","$something = " & $something)
    $something = 0
EndFunc


Func _DoSomething()
    while $something = 1
        GUICtrlSetData($Edit1, $s & " loop" & @CRLF, 1)
    ;GUICtrlSendMsg($Edit1, $SB_SCROLLCARET, 0, 0)
    ;ControlFocus($Form1, "", $Edit1)
        sleep(50)
        $s = $s +1

    WEnd
EndFunc

Share this post


Link to post
Share on other sites
Valuater

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

Global $s = 0
Global $something

Global Const $SB_SCROLLCARET = 0xB7

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 301, 301, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Button1", 32, 216, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 160, 216, 75, 25, 0)
GUICtrlSetOnEvent($Button2, "Button2Click")
$Edit1 = GUICtrlCreateEdit("", 176, 40, 97, 137)
GUICtrlSetData($Edit1, "Edit1")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    While $something = 1
        $s = $s + 1
        
        ; clear edit1
        GUICtrlSetData($Edit1, "")
        
        ; get the info...
        
        ; set the info
        GUICtrlSetData($Edit1, $s & " loop" & @CRLF, 1)
        
        Sleep(1000)

    WEnd
    Sleep(100)
WEnd

Func Button1Click()
    $something = 1
EndFunc   ;==>Button1Click

Func Button2Click()
    MsgBox(0, "MESSAGE", "$something = " & $something)
    $something = 0
    ;$s = 0 ;????
EndFunc   ;==>Button2Click


Func Form1Close()
    Exit
EndFunc   ;==>Form1Close

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
dickep

THANK YOU! I now see what I was "missing".

Made a little tweak for clearing and now will work towards integration in my script

Code updated:

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

Global $s = 0
Global $something

Global Const $SB_SCROLLCARET = 0xB7

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 301, 301, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Button1", 32, 216, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 160, 216, 75, 25, 0)
GUICtrlSetOnEvent($Button2, "Button2Click")
$Edit1 = GUICtrlCreateEdit("", 176, 40, 97, 137)
GUICtrlSetData($Edit1, "Edit1")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    While $something = 1
        $s = $s + 1
        
       ; clear edit1
       ;GUICtrlSetData($Edit1, "")
        
       ; get the info...
        
       ; set the info
        GUICtrlSetData($Edit1, $s & " loop" & @CRLF, 1)
        
        Sleep(1000)

    WEnd
    Sleep(100)
WEnd

Func Button1Click()
    $something = 1
    GUICtrlSetData($Edit1, "")
EndFunc  ;==>Button1Click

Func Button2Click()
    $something = 0
EndFunc  ;==>Button2Click


Func Form1Close()
    Exit
EndFunc  ;==>Form1Close

Share this post


Link to post
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
Sign in to follow this  

×