Sign in to follow this  
Followers 0
Necromorph

Polling the GUI

10 posts in this topic

#1 ·  Posted (edited)

#INCLUDE <GUIConstantsEx.au3>
#INCLUDE <ButtonConstants.au3>
GUICREATE("PalMate ERP Auto Installer", 300, 325)
    GUICTRLCREATELABEL("Comapany Name", 25, 25)
    $installname=GUICTRLCREATEINPUT("Demo", 25, 40, 250)
    GUICTRLCREATELABEL("Port Number", 25, 75)
    $installport=GUICTRLCREATEINPUT("3127", 25, 90, 250)
    GUICTRLCREATEGROUP("Database Options", 20, 125, 250, 100)
    $installopt_1=GUICTRLCREATERADIO("No Change", 25, 140)
    $installopt_2=GUICTRLCREATERADIO("Update Existing Database", 25, 160)
    $installopt_3=GUICTRLCREATERADIO("Initialize Database", 25, 180)
    $installopt_4=GUICTRLCREATERADIO("Demonstration Database", 25, 200)
    $dbbackupopt=GUICTRLCREATECHECKBOX("Backup Existing Database", 25, 240)
    $start=GUICTRLCREATEBUTTON("Next >", 125, 275, 75)
    $install_cancel=GUICTRLCREATEBUTTON("Cancel", 200, 275, 75)
    DO
    $msg=GUIGETMSG()
        FILECHANGEDIR(@PROGRAMFILESDIR)
        IF NOT FILEEXISTS("Automated Machine Systems\Palmate ERP\" & GUICTRLREAD($installname) & "\")THEN
        GUICTRLSETSTATE($dbbackupopt, $GUI_DISABLE)
        ENDIF
        EXITLOOP
    UNTIL $msg=$start   
    GUISETSTATE()
    GUICTRLSETSTATE($installopt_4, $GUI_CHECKED)
    GUICTRLSETSTATE($start, $GUI_DEFBUTTON)

    WHILE 1
    $msg=GUIGETMSG()
        IF $msg=$install_cancel THEN
            EXIT
        ELSEIF $msg=$GUI_EVENT_CLOSE THEN
            EXIT
        ELSEIF $msg=$start THEN
            EXITLOOP
        ENDIF   
WEND

Okay, i need to be able to Poll the GUI to see if the first $installname has changed, because i need the $dbbackupopt to be grayed out if the $installname dir doesn't exist, so how can i make it change everytime the $installname is changed?

Thanks in avanced.

Edited by redLabel

Share this post


Link to post
Share on other sites



#INCLUDE <GUIConstantsEx.au3>
#INCLUDE <ButtonConstants.au3>

GUICREATE("PalMate ERP Auto Installer", 300, 325)
    GUICTRLCREATELABEL("Comapany Name", 25, 25)
    $installname=GUICTRLCREATEINPUT("Demo", 25, 40, 250)
    GUICTRLCREATELABEL("Port Number", 25, 75)
    $installport=GUICTRLCREATEINPUT("3127", 25, 90, 250)
    GUICTRLCREATEGROUP("Database Options", 20, 125, 250, 100)
    $installopt_1=GUICTRLCREATERADIO("No Change", 25, 140)
    $installopt_2=GUICTRLCREATERADIO("Update Existing Database", 25, 160)
    $installopt_3=GUICTRLCREATERADIO("Initialize Database", 25, 180)
    $installopt_4=GUICTRLCREATERADIO("Demonstration Database", 25, 200)
    $dbbackupopt=GUICTRLCREATECHECKBOX("Backup Existing Database", 25, 240)
    $start=GUICTRLCREATEBUTTON("Next >", 125, 275, 75)
    $install_cancel=GUICTRLCREATEBUTTON("Cancel", 200, 275, 75)
    GUISETSTATE()
    GUICTRLSETSTATE($installopt_4, $GUI_CHECKED)
    GUICTRLSETSTATE($start, $GUI_DEFBUTTON)
WHILE 1
    DO
        $msg=GUIGETMSG()
            FILECHANGEDIR(@PROGRAMFILESDIR)
            IF NOT FILEEXISTS("Automated Machine Systems\Palmate ERP\" & GUICTRLREAD($installname) & "\")THEN 
                GUICTRLSETSTATE($dbbackupopt, $GUI_DISABLE)
            ELSEIF FILEEXISTS("Automated Machine Systems\Palmate ERP\" & GUICTRLREAD($installname) & "\")THEN
                GUICTRLSETSTATE($dbbackupopt, $GUI_ENABLE)
                EXITLOOP
            ENDIF 
    UNTIL $msg=$start
        IF $msg=$install_cancel THEN
            EXIT
        ELSEIF $msg=$GUI_EVENT_CLOSE THEN
            EXIT
        ELSEIF $msg=$start THEN
            EXITLOOP
        ENDIF   
WEND

this works for what i need to do, but i would like to assing the one control $installname a way to poll it by like "tabbing" out of it or clicking out of it, having it poll like that, because right now its polling everytime the mouse moves. any idea??

thanks again

Share this post


Link to post
Share on other sites

i really need some help with this i only need it to poll the $insallname while it is $GUI_FOCUS, but i can't make that work here is what i have, any idea why it isn't working

WHILE 1
    $msg=GUIGETMSG()
    DO 
        FILECHANGEDIR(@PROGRAMFILESDIR)
        IF NOT FILEEXISTS("Automated Machine Systems\Palmate ERP\" & GUICTRLREAD($installname) & "\")THEN
            GUICTRLSETSTATE($dbbackupopt, $GUI_DISABLE)
            GUICTRLSETSTATE($dbbackupopt, $GUI_UNCHECKED)
            EXITLOOP
        ELSEIF FILEEXISTS("Automated Machine Systems\Palmate ERP\" & GUICTRLREAD($installname) & "\")THEN
            GUICTRLSETSTATE($dbbackupopt, $GUI_ENABLE)
            EXITLOOP
        ENDIF
    UNTIL $installname=$GUI_NOFOCUS
        IF $msg=$install_cancel THEN
            EXIT
        ELSEIF $msg=$GUI_EVENT_CLOSE THEN
            EXIT
        ELSEIF $msg=$start THEN
            EXITLOOP
        ENDIF   
WEND

or if you have any other ideas, but it should DO..... UNTIL $installname=$GUI_NOFOCUS, so after i leave that input field, it should stop polling for the existence of the dir. but its not working like that.

please help. thanks

Share this post


Link to post
Share on other sites

thanks for the reply, basically what im trying to do is:

i have a GUI and the first $var in it is the company name of what im installing so i call that $installname

now if you have installed be for, you have the option to backup the database before you install

if it is a clean install you cannot do this, there isn't one to do so.

so i want to poll the $installname input field and check that to the directory that the database would be installed had you done so previously

because if you haven't, it will disable the checkbox control $dbbackupopt

but i only want to poll this directory when the $installname input field is $GUI_FOCUS, but it just doesn't seem to work like that.

because when its polling by defalt, it is doing it everytime the mouse moves and it make the control blink and looks crappy.

Share this post


Link to post
Share on other sites

acutally, i tried the SLEEP(10) works perfect, i just wanted to stop the flashing!!

Share this post


Link to post
Share on other sites

i think it just does that by default, that is why i was just trying to have it do it by focus on the $installname

but like i said the sleep(10) works perfect.

so

thanks again.

Share this post


Link to post
Share on other sites

but like i said the sleep(10) works perfect.

That is 10 ms per loop that GuiGetMsg() is blind. I would rather advise filtering the messages that GuiGetMsg() outputs. AutoIt Gui controls output positive numbered messages but special events (i.e mouse move) output negative numbered messages. You can use a Switch statement to filter messages not needed and thus conditional logic in the loop is processed only as needed.

So a snip of code may look like this

WHILE 1
    DO
        $msg=GUIGETMSG()
        Switch $msg
            Case 0, -11 ; I received -11 for mouse movements
                ContinueLoop
            Case Else
                ConsoleWrite($msg & @CRLF) ; just for testing purposes
        EndSwitch
        FILECHANGEDIR(@PROGRAMFILESDIR) ; is this needed in the loop? Once would seem adequate.

Share this post


Link to post
Share on other sites

okay, i will try that. thanks, and my FILCHANGEDIR() are probably over used, ive only been scirpting for around two weeks and this is the first Lang ive learned, but thanks for the tips, i will give them a try.

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