Sign in to follow this  
Followers 0
Chobyhy

Basic GUI Help

6 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstants.au3>
#include <Date.au3>
#include <misc.au3>
Opt('SendKeyDelay', 1)

;Misc Variable
$Ver = "v0.1b" ;Application Version
$ConfigDir = @ScriptDir & "\etc\config.ini" ;Configuration Directory
$Icon = @ScriptDir & "\etc\logo.ico" ;Icon Directory

;Terms of Use
$ToU = IniRead($ConfigDir, "Basic" , "ToU", "0") ;Read if the user has already agreed to the ToU

Do
    $Msg = GUIGetMsg()
Until $Msg = $GUI_EVENT_CLOSE

If $ToU = 0 Then ;Term has not been agreed to
    GUICreate($Ver & " Terms of Use", 400, 300)
    GUISetState()
    GUISetIcon($Icon, 0)
    GUICtrlCreateLabel("You must agree to the Terms of Use before being able to use this program.", 10, 10)
    GUICtrlCreateEdit("Terms of Use - Test", 25, 30, 350, 175, $ES_READONLY)
    $ToUAgree = GUICtrlCreateCheckbox("I agree to the Terms of Use", 25, 210)
    $ToUContinue = GUICtrlCreateButton("Continue", 75, 240, 100, 50)
    $ToUExit = GUICtrlCreateButton("Exit", 225, 240, 100, 50)
    GUICtrlSetState($ToUContinue, $GUI_DISABLE)
    If $Msg = $ToUAgree Then
        GUICtrlSetState($ToUContinue, $GUI_ENABLE)
    ElseIf $Msg = $ToUContinue Then
        IniWrite($ConfigDir, "Basic", "ToU", "1")
    ElseIf $Msg = $ToUExit Then
        Exit 0
    EndIf
EndIf

This is my script so far and for some reason the GUI wont show up but the script is running in the system tray. Any ideas on this problem?

Edited by Chobyhy

Share this post


Link to post
Share on other sites



Change

$ToU = Int(IniRead($ConfigDir, "Basic" , "ToU", 0));Read if the user has already agreed to the ToU

or change

If $ToU = "0" Then;Term has not been agreed to

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <GUIConstants.au3>
#include <Date.au3>
#include <misc.au3>
Opt('SendKeyDelay', 1)

;Misc Variable
$Ver = "v0.1b" ;Application Version
$ConfigDir = @ScriptDir & "\etc\config.ini" ;Configuration Directory
$Icon = @ScriptDir & "\etc\logo.ico" ;Icon Directory

;Terms of Use
$ToU = IniRead($ConfigDir, "Basic" , "ToU", "0") ;Read if the user has already agreed to the ToU

Do
    $Msg = GUIGetMsg()
Until $Msg = $GUI_EVENT_CLOSE

If $ToU = 0 Then ;Term has not been agreed to
    GUICreate($Ver & " Terms of Use", 400, 300)
    GUISetIcon($Icon, 0)
    GUICtrlCreateLabel("You must agree to the Terms of Use before being able to use this program.", 10, 10)
    GUICtrlCreateEdit("Terms of Use - Test", 25, 30, 350, 175, $ES_READONLY)
    $ToUAgree = GUICtrlCreateCheckbox("I agree to the Terms of Use", 25, 210)
    $ToUContinue = GUICtrlCreateButton("Continue", 75, 240, 100, 50)
    $ToUExit = GUICtrlCreateButton("Exit", 225, 240, 100, 50)
    GUICtrlSetState($ToUContinue, $GUI_DISABLE)
    GUISetState()
    If $Msg = $ToUAgree Then
        GUICtrlSetState($ToUContinue, $GUI_ENABLE)
    ElseIf $Msg = $ToUContinue Then
        IniWrite($ConfigDir, "Basic", "ToU", "1")
    ElseIf $Msg = $ToUExit Then
        Exit 0
    EndIf
EndIfoÝ÷ Ù8b²+&ÊÇ+l¡ö«jw_¢»(êÞjÊ'¶P(Û!£©nëmë®*mÊîx§)íë2²×¦¶¶²|¢u欢{aÊk¡¹^ú®¢×«wöÆÞq«¬{*.v÷öØZ½è­®éçx"©h¢(¶º'm²Ö²¢§"·°®^¶¡×n+Ry趬Â)eéiʺÚ"µÍÚ[ÛYH ÑÕRPÛÛÝ[Ë]LÉÝÂÚ[ÛYH  Ñ]K]LÉÝÂÚ[ÛYH ÛZØË]LÉÝÂÜ
    ÌÎNÔÙ[Ù^Q[^IÌÎNËJBÓZØÈXXBÌÍÕH ][ÝÝX][ÝÈÐXØ][ÛÚ[ÛÌÍÐÛÛYÑHØÜ   [È ][ÝÉÌLÙ]ÉÌLØÛÛYË[I][ÝÈÐÛÛYÝ][ÛXÝÜBÌÍÒXÛÛHØÜ   [È ][ÝÉÌLÙ]ÉÌLÛÙÛËXÛÉ][ÝÈÒXÛÛXÝÜBÕÈÙÙBÌÍÕÕHH[TXY
    ÌÍÐÛÛYÑ   ][ÝÐÚXÉ][ÝÈ   ][ÝÕÕI][ÝË ][ÝÌ  ][ÝÊHÔXYYHÙÈ[XYHYÜYYÈHÕBY   ÌÍÕÕHH[ÕHÈÝY[YÜYYÂÕRPÜX]J    ÌÍÕ  [È ][ÝÈÈÙÙI][ÝË
Ì
BÕRTÙ]Ý]J
BÕRTÙ]XÛÛ   ÌÍÒXÛÛ
BÕRPÝÜX]SX[
    ][ÝÖ[ÝH]ÝYÜYHÈHÈÙÙHYÜHZ[ÈXHÈÙHÈÙÜ[K][ÝËLL
BÕRPÝÜX]QY]
    ][ÝÕÈÙÙHHÝ    ][ÝËKÌÍLMÍK    ÌÍÑT×ÔPQÓJBÌÍÕÕPYÜYHHÕRPÝÜX]PÚXÚØÞ
    ][ÝÒHYÜYHÈHÈÙÙI][ÝËKL
BÌÍÕÕPÛÛ[YHHÕRPÝÜX]P]Û    ][ÝÐÛÛ[YI][ÝË
ÍKL
L
BÌÍÕÕQ^]HÕRPÝÜX]P]Û ][ÝÑ^]    ][ÝËKL
L
BÕRPÝÙ]Ý]J  ÌÍÕÕPÛÛ[YK    ÌÍÑÕRWÑTÐPJBBÚ[HB    ÌÍÓÙÈHÕRQÙ]ÙÊ
BÙ[XÝØÙH    ÌÍÓÙÈH ÌÍÑÕRWÑUSÐÓÔÑBH^]ØÙH ÌÍÓÙÈH ÌÍÕÕPYÜYBÕRPÝÙ]Ý]J ÌÍÕÕPÛÛ[YK    ÌÍÑÕRWÑSPJBØÙH   ÌÍÓÙÈH ÌÍÕÕPÛÛ[YB[]J  ÌÍÐÛÛYÑ   ][ÝÐÚXÉ][ÝË   ][ÝÕÕI][ÝË ][ÝÌI][ÝÊBÙÐÞ
    ][ÝÐXØÜ]Y   ][ÝË  ][ÝÐXØÙ[ÙHXÚÛÝÛYÙY    ÌÌÎÉ][ÝÊB^]ØÙH  ÌÍÓÙÈH ÌÍÕÕQ^]^][Ù[XÝÑ[[Y
Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

can I ask a ridiculous question^^. Why do we have to use the loop (while ....Wend) when we use GUI?

Share this post


Link to post
Share on other sites

can I ask a ridiculous question^^. Why do we have to use the loop (while ....Wend) when we use GUI?

Are you asking why he used While/WEnd instead of Do/Until, or are you asking why we need a loop at all ?

That's because you don't have it running in a loop so the Gui can't stay open.

Actually he did have a loop, only he had it at the wrong place. First he have a loop that waits for the user to

click close and then the GUI is actually created... Well, the GUI really isn't created at all since the script will

only continue if GUIGetMsg equals the value of $GUI_EVENT_CLOSE, which it of course never will in this case,

so it just waits...forever.

Share this post


Link to post
Share on other sites

Are you asking why he used While/WEnd instead of Do/Until, or are you asking why we need a loop at all ?

Actually he did have a loop, only he had it at the wrong place. First he have a loop that waits for the user to

click close and then the GUI is actually created... Well, the GUI really isn't created at all since the script will

only continue if GUIGetMsg equals the value of $GUI_EVENT_CLOSE, which it of course never will in this case,

so it just waits...forever.

Yes I knew that he had a loop already. If you look at what I said again, I stated it wasn't running in a loop not that he didn't have one. But I used while/wend instead as preference and worked better for me for my example. :whistle:


EndFuncAutoIt is the shiznit. I love it.

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  
Followers 0