Jump to content
Sign in to follow this  
Necromorph

gui open gui loop needed

Recommended Posts

Necromorph

okay, here is what i got

#INCLUDE <GUIConstantsEX.au3>
#INCLUDE <ComboConstants.au3>
#INCLUDE <DateTimeConstants.au3>

GUICREATE("redLabel worklog", 350, 450)
    GUICTRLCREATELABEL("company", 25, 25)
    $tCompany=GUICTRLCREATECOMBO("all", 25, 40, 50, DEFAULT, $CBS_DROPDOWNLIST)
        GUICTRLSETDATA(-1, "AEC")
        GUICTRLSETDATA(-1, "AMS")
        GUICTRLSETDATA(-1, "CW")
        GUICTRLSETDATA(-1, "DTA")
        GUICTRLSETDATA(-1, "MF")
    GUICTRLCREATELABEL("user assisted (if applicable)", 125, 25)
    $tUser=GUICTRLCREATEINPUT("", 125, 40, 200)
    GUICTRLCREATELABEL("date", 25, 85)
    $tDate=GUICTRLCREATEMONTHCAL("", 25, 100, 235, 175)
    GUICTRLCREATELABEL("start time", 275, 115)
    $tStartTime=GUICTRLCREATEINPUT("", 275, 130, 50)
    GUICTRLCREATELABEL("end time", 275, 165)
    $tEndTime=GUICTRLCREATEINPUT("", 275, 180, 50)
    GUICTRLCREATELABEL("time spent", 275, 215, 50)
    $TotalTime=GUICTRLCREATEINPUT("", 275, 230, 50)
        GUICTRLSETSTATE(-1, $GUI_DISABLE)
    GUICTRLCREATELABEL("task(s) performed", 25, 300)
    $tTask=GUICTRLCREATEINPUT("", 25, 315, 300, 50)
    $tViewLog=GUICTRLCREATEBUTTON("&open log", 25, 400, 75)
    $tEmailLog=GUICTRLCREATEBUTTON("&email log", 100, 400, 75)
    $tCancel=GUICTRLCREATEBUTTON("&cancel <", 175, 400, 75)
    $tLogEntry=GUICTRLCREATEBUTTON("&log entry >", 250, 400, 75)
    GUISETSTATE()
WHILE 1
    $msg1=GUIGETMSG()
        IF $msg1=$GUI_EVENT_CLOSE THEN
            EXIT
        ELSEIF $msg1=$tCancel THEN
            EXIT
        ELSEIF $msg1=$tEmailLog THEN
            GUICREATE("redLabel worklog", 250, 200)
                GUICTRLCREATELABEL("select date range to attach to email", 25, 25)
                GUICTRLCREATELABEL("start date", 25, 50)
                $tStartDate=GUICTRLCREATEDATE("", 25, 65, 200)
                GUICTRLCREATELABEL("end date", 25, 100)
                $tEndDate=GUICTRLCREATEDATE("", 25, 115, 200)
                $tCancelAttachLog=GUICTRLCREATEBUTTON("&cancel <", 75, 150, 75)
                $tAttachLog=GUICTRLCREATEBUTTON("&attach >", 150, 150, 75)
                GUISETSTATE()
            WHILE 2
                $msg2=GUIGETMSG()
                    IF $msg2=$GUI_EVENT_CLOSE THEN
                        GUIDELETE()
                    ELSEIF $msg2=$tCancelAttachLog THEN
                        GUIDELETE()
                    ELSEIF $msg2=$tAttachLog THEN
                        GUISETSTATE(@SW_HIDE)
                    ENDIF
            WEND
        ENDIF
WEND

now what i need to do, when the second gui opens, and the "cancel button", or the "$GUI_EVENT_CLOSE" is hit, i need to close the gui, but still stay in the loop of the previous window, so if the button is hit again, it will make the gui again. i have tried using a "continueloop", but i cannot find the right placement of it to do what i need, i was wondering if there might be a better way to do what im trying to do. thanks for all your help.

Share this post


Link to post
Share on other sites
Beege

In your situation I would use a function for the second gui and then pass whatever information your getting from that gui back. What do you want the attach button to do?

#include <GUIConstantsEX.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>

Global $gui1 = GUICreate("redLabel worklog", 350, 450)
GUICtrlCreateLabel("company", 25, 25)
$tCompany = GUICtrlCreateCombo("all", 25, 40, 50, Default, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "AEC")
GUICtrlSetData(-1, "AMS")
GUICtrlSetData(-1, "CW")
GUICtrlSetData(-1, "DTA")
GUICtrlSetData(-1, "MF")
GUICtrlCreateLabel("user assisted (if applicable)", 125, 25)
$tUser = GUICtrlCreateInput("", 125, 40, 200)
GUICtrlCreateLabel("date", 25, 85)
$tDate = GUICtrlCreateMonthCal("", 25, 100, 235, 175)
GUICtrlCreateLabel("start time", 275, 115)
$tStartTime = GUICtrlCreateInput("", 275, 130, 50)
GUICtrlCreateLabel("end time", 275, 165)
$tEndTime = GUICtrlCreateInput("", 275, 180, 50)
GUICtrlCreateLabel("time spent", 275, 215, 50)
$TotalTime = GUICtrlCreateInput("", 275, 230, 50)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel("task(s) performed", 25, 300)
$tTask = GUICtrlCreateInput("", 25, 315, 300, 50)
$tViewLog = GUICtrlCreateButton("&open log", 25, 400, 75)
$tEmailLog = GUICtrlCreateButton("&email log", 100, 400, 75)
$tCancel = GUICtrlCreateButton("&cancel <", 175, 400, 75)
$tLogEntry = GUICtrlCreateButton("&log entry >", 250, 400, 75)
GUISetState()
While 1
    $msg1 = GUIGetMsg()
    Switch $msg1
        Case $GUI_EVENT_CLOSE, $tCancel
            Exit
        Case $tEmailLog
            _EmailLog()
    EndSwitch
WEnd


Func _EmailLog()
    Local $gui2 = GUICreate("redLabel worklog", 250, 200)
    GUICtrlCreateLabel("select date range to attach to email", 25, 25)
    GUICtrlCreateLabel("start date", 25, 50)
    $tStartDate = GUICtrlCreateDate("", 25, 65, 200)
    GUICtrlCreateLabel("end date", 25, 100)
    $tEndDate = GUICtrlCreateDate("", 25, 115, 200)
    $tCancelAttachLog = GUICtrlCreateButton("&cancel <", 75, 150, 75)
    $tAttachLog = GUICtrlCreateButton("&attach >", 150, 150, 75)
    GUISetState()
    GUISwitch($gui2)
    While 1
        $msg2 = GUIGetMsg()
        Switch $msg2
        Case $GUI_EVENT_CLOSE, $tCancelAttachLog
            GUIDelete()
            GUISwitch($gui1)
            Return
        Case $tAttachLog
            ;GUISetState(@SW_HIDE)
        EndSwitch
    WEnd
EndFunc   ;==>_EmailLog
Edited by Beege

Share this post


Link to post
Share on other sites
Necromorph

i havent gotten all the code in yet, but i want it to attach itself to an email, but i like your code for a fucnction, i will experiment with that. thanks for the reply

Share this post


Link to post
Share on other sites
Beege

Ok. I also notice you had

While 2

;;

Wend

which is not necessarily wrong, but not common and I think your confused. "While" statements continue while the expression is true. In autoit, 1 is equal to true and 0 is equal to false. Thats why you see while 1.

Share this post


Link to post
Share on other sites
Necromorph

thank you much or all of your help, i have one more question. for my other button in $gui1, the "view log" button, i, set another case for it, and use the FILEOPEN command for it, it doesnt open, it looks like this

case $tViewLog

FILEOPEN(@APPDATADIR &"\worklog\worklog2010.txt", 0)

but it doesn't work, and im not sure why,

thanks alot

Share this post


Link to post
Share on other sites
Beege

How do you know didn't work? what error did you get? That function wont launch notepad if thats what you expect to happen..

Edit: Use something like this to look for errors..

case $tLogEntry
        $hLog = FILEOPEN(@APPDATADIR &"\worklog\worklog2010.txt", 0)
        If $hLog = -1 Then
            MsgBox(0,'ERROR', 'Error opening File')
            ContinueCase
        EndIf
        $LogRead = FileRead($hLog)
        MsgBox(0,'LOG', $LogRead)
Edited by Beege

Share this post


Link to post
Share on other sites
Necromorph

hm, still can't get it to work, i do want it to open notepad so i can view what is in the file, here is my code

WHILE 1
    $msg1=GUIGETMSG()
    SWITCH $msg1
        CASE $GUI_EVENT_CLOSE, $tCancel
            EXIT
        CASE $tViewLog
                $hLog=FILEOPEN(@APPDATADIR &"\worklog\worklog2010.txt", 0)
                IF $hLog=-1 Then
                    MsgBox(0,'ERROR', 'Error opening File')
                ENDIF
                $LogRead=FILEREAD($hLog)
                                MSGBOX(0, "", $logRead)
        CASE $tEmailLog
            _EMAILLOG()
    ENDSWITCH
WEND

which works, but i want it to just open note pad to view the file. i plan on using this to log my time all day...., well wait, do you think it will be a problem opening it with a msgbox, it does look nicer then notepad. i will keep messing with it, if it will keep displaying all the text in the log then it will be fine, but after a few weeks even its going to be a pretty good size.

thanks again for all your help.

Share this post


Link to post
Share on other sites
Beege

If you want the default application to open the file look into using the Run() command or the shellExecute() command. And no I would'nt use msgbox() for viewing a log. Use msgbox() for simple questions or comments. ex:"Are you sure you want to exit?" yes no. "Blah blah blah completed succuesfully." OK. Things like that.

Share this post


Link to post
Share on other sites
Necromorph

ShellExecute, perfect. thanks again!!

Share this post


Link to post
Share on other sites
Beege

Sure thing. :mellow:

Share this post


Link to post
Share on other sites
Necromorph

heres a question for you, do you know how i can change the format of a GUICtrlCreateDate then use the $DTS_TIMEFORMAT, to make it display the time in the box, but i want it to be in military time, no AM/PM. im not sure if this can be done, but i was wondering if you knew how to.

thanks.

or, subtract a starttime from a finish time to get a "Time Spent" $var with the AM/PM format would work as well.

thanks

Edited by redLabel

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.