Jump to content

Help with function and GUI


hosec
 Share

Recommended Posts

hello i seem to be having a problem with a gui that is affecting my functions somehow wondering if someone could help been scratching my head for hours trying to figure it out as im fairly new to autoit but picking it up as i go, i have tried to create a gui with a editbox that im using as a live console that my script can return data to.

 

this code works fine and does what you'd expect it to do

Global $var1 = 'False'


test()

Func test()
    If $var1 = 'False' then
    msgbox(0, 'test', 'detected false')

Else

    msgbox(0, 'test', 'detected false')

endif
endfunc

 

however when i add the gui above this the test() function does not want to play ball

 

 

#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MouseCoordMode', 0)
Opt("GUIOnEventMode", 1)

$data = ""
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 294, 334, 476)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")



$Button1 = GUICtrlCreateButton("Button1", 24, 184, 73, 41)
GUICtrlSetOnEvent(-1, "Button1Click")
$BoxID = GUICtrlCreateEdit("", 48, 24, 321, 145)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    GUICtrlSetData($BoxID, "Starting Bot" & @CRLF, "1")
test()
EndFunc

Func Form2Close()
    Exit
EndFunc

i have added a piece of code under the test() funtion that returns code to the edit box and it works fine like so

however anything else under the GuiCtrlSetData is not working and the script ends there

Func test()
GUICtrlSetData($BoxID, "This is a test" & @CRLF, "1")
EndFunc

so the GUI is working and returning data to the edit box as i want it too,

and the funtion is working fine independently however when i put the two together the funtion does not want to play ball
any help would be appreciated

Link to comment
Share on other sites

...it looks fine to me

#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;~ Opt('MouseCoordMode', 0)
Opt("GUIOnEventMode", 1)

Global $data = ""
#Region ### START Koda GUI section ### Form=
Global $Form2 = GUICreate("Form2", 405, 294, 334, 476)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")



Global $Button1 = GUICtrlCreateButton("Button1", 24, 184, 73, 41)
GUICtrlSetOnEvent(-1, "Button1Click")
Global $BoxID = GUICtrlCreateEdit("", 48, 24, 321, 145)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    GUICtrlSetData($BoxID, "Starting Bot" & @CRLF, "1")
    test()
    GUICtrlSetData($BoxID, "-----------" & @CRLF, "1")
EndFunc   ;==>Button1Click

Func test()
    GUICtrlSetData($BoxID, "This is a test" & @CRLF, "1")
EndFunc   ;==>test

Func Form2Close()
    Exit
EndFunc   ;==>Form2Close

Edit: ...just saw the "Starting Bot" and there is no aid to bots/game related in the forum, so, I just got me in trouble.
Anyway, welcome to the forum :)

Edited by argumentum
oops

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Why add as a standalone function when a function can simply be added to an existing one?

Maybe this?

#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MouseCoordMode', 0)
Opt("GUIOnEventMode", 1)

$data = ""
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 294, 334, 476)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")

Global $var1 = 'False'

$Button1 = GUICtrlCreateButton("Button1", 24, 184, 73, 41)
GUICtrlSetOnEvent(-1, "Button1Click")
$BoxID = GUICtrlCreateEdit("", 48, 24, 321, 145)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    GUICtrlSetData($BoxID, "Starting Bot" & @CRLF, "1")
    If $var1 = 'False' then
        msgbox(0, 'test', 'detected false')
    Else
        msgbox(0, 'test', 'detected false')

endif
EndFunc

Func Form2Close()
    Exit
EndFunc

 

Link to comment
Share on other sites

4 hours ago, UE_morf_boon said:

Maybe this?

#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MouseCoordMode', 0)
Opt("GUIOnEventMode", 1)

$data = ""
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 294, 334, 476)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")

Global $var1 = False

$Button1 = GUICtrlCreateButton("Button1", 24, 184, 73, 41)
GUICtrlSetOnEvent(-1, "Button1Click")
$BoxID = GUICtrlCreateEdit("", 48, 24, 321, 145)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    $var1 = Not $var1
    GUICtrlSetData($BoxID, "click = " & $var1 & @CRLF, "1")
    If $var1 = False Then
        MsgBox(0, 'test', 'detected  false')
    Else
        MsgBox(0, 'test', 'detected  true')
    EndIf
EndFunc   ;==>Button1Click

Func Form2Close()
    Exit
EndFunc   ;==>Form2Close

:P

anyway, this is my last post on this thread. Stay away from bot coding in this forum.

 

 

Edited by argumentum
added forum rules

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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...