Jump to content
Sign in to follow this  
Steveiwonder

Auto GUI Update

Recommended Posts

Steveiwonder

Hey All,

I'm new to this and have been playing around most of yesterday trying to create some simple auto login scripts for my work place. I'm Familiar with Autohotkey which is similiar to this. So far i prefer Auto It seems to be alot more functionality avilable.

Here are my example scripts so far.

Func UKClarify_Login()
    Local $FileLocation = "C:\Clarify\eFrontOffice8\ClarifyClient\clarify.exe"

    ;File Check & Run or Error;
    If FileExists($FileLocation) == 0 Then
        MsgBox(16, "File Not Found","Unable to find UK Clarify Client, please check check Uk Clairfy is installed")
        Return 0
    Else
        Run($FileLocation, "C:\Clarify\eFrontOffice8\ClarifyClient")
    EndIf
    ;End of File Check;

    ;Main Login Window;
    WinWaitActive("Clarify Login")
    ControlSend("Clarify Login","","Edit1","{BS 14}{DEL 14}********") ;Going to add functionality to read from INI
    ControlSend("Clarify Login","","Edit2","{BS 14}{DEL 14}********") ;Going to add functionality to read from INI
    ControlClick("Clarify Login", "Login", "Button1", "left","1")
    
    ;Login Complete;

    ;Maximize Window;
    WinWaitActive("Clarify - ClearSupport - [Console]")
    WinSetState("Clarify - ClearSupport - [Console]","", @SW_MAXIMIZE)
    ;Maximize Complete;
    
    Return 1
EndFunc

Func btW_Login()

    _IELoadWaitTimeout(10000) ;All Pages must load in under 10seconds or a failure will occur
    $btW = _IECreate("http://www.btwholesale.com")
    ;New Page Loading;
    _IELoadWait($btW)
    ;New Page Loaded;

    ;Confirm correct page loaded or fail;
    If WinExists("BT Wholesale : homepage_logout -") == 0 Then
        MsgBox(16, "Loading Failed","Page took longer than 10 seconds to load or fail completeley.",4);Loading Failed;
        Return 0
    EndIf
    ;Confirm correct page loaded complete;

    $oForm = _IEFormGetObjByName ($btW, "LoginForm") ; Sets the Form

    $oUsername = _IEFormElementGetObjByName ($oForm, "USER") ;Sets the User InputBox
    $oPassword = _IEFormElementGetObjByName ($oForm, "PASSWORD") ;Sets the Password InputBox


    _IEFormElementSetValue ($oUsername, "**********") ;Enter Username
    _IEFormElementSetValue ($oPassword, "**********") ;Enter Password

    _IEFormSubmit($oForm) ;Submit Form

    ;New Page Loading;
    _IELoadWait($btW)
    ;New Page Loaded

    ;Confirm correct page loaded or fail;
    If WinExists("BT Wholesale : admin -") == 0 Then
        MsgBox(16, "Loading Failed","Page took longer than 10 seconds to load or fail completeley.",4);Loading Failed;
        Return 0
    EndIf
    ;Confirm correct page loaded complete;


    $oForm = _IEFormGetObjByName ($btW, "LoginForm") ; Sets the Form for new page
    _IEFormSubmit($oForm) ;Submit Form

    ;New Page Loading;
    _IELoadWait($btW)
    ;New Page Loaded

    ;Confirm correct page loaded or fail;
    If WinExists("BT Wholesale : customerzone_login -") == 0 Then
        MsgBox(16, "Loading Failed","Page took longer than 10 seconds to load or fail completeley.",4);Loading Failed;
        Return 0
    EndIf
    ;Confirm correct page loaded complete;

    $btWECO = _IECreate("https://ecorepair4.btwholesale.com/validatelogin.aspx"); Open ECO Screen

    ;New Page Loading;
    _IELoadWait($btWECO)
    ;New Page Loaded

    ;Confirm correct page loaded or fail;
    If WinExists("BT Wholesale.com | eCo.Repair -") == 0 Then
        MsgBox(16, "Loading Failed","Page took longer than 10 seconds to load or fail completeley.",4);Loading Failed;
        Return 0
    EndIf
    ;Confirm correct page loaded complete;

    _IEQuit($btW);quit initial BT window
    Return 1
EndFunc

I'm just using these two as examples - I have like 5 or 6 more scripts for different applications i use while working.

Here is the script that pulls them all together:

login.au3

#include <BT Wholesale Login.au3>
#include <Clarify Login.au3>
#include <Func.au3>
#include <IE.au3>


;BT Wholesale Login
If btW_Login() Then
    $login_btW = 1 ;login successful
Else
    $login_btW = 0 ;login failed
EndIf
;BT Wholesale Login end

;UK Clarify Login
If UKClarify_Login() Then
    $login_cUK = 1 ;login successful
Else
    $login_cUK = 0 ;login failed
EndIf
;UK Clarify Login end;

Within login.au3 i need a GUI which has each process as when complete it shows a green tick(image i have) or a red cross to show its failed. As you can see if one of the functions logging me into an application fails it specific variable will be set to 0.

I have tried to play around with the GUI but just have absolutly no idea where im going with it.

what i think it should look like.

Imagine a GUI window around each of these examples :)

Example 1:

BT Login: Loading

Clarify: Waiting

Example: 2

BT Login: Complete!

Clarify: Loading

Example: 3

BT Login: Complete!

Clarify: Failed

I know my example of my GUI aren't exactly good but i didnt really know how else to show.

I not looking for anyone to try and write the script for me, but maybe point me in the right direction or give me some idea's.

Really appreciate your assistance.

Thanks you.

p.s. please forgive me if have missed anything or it doesnt make sense, just ask:)


They call me MrRegExpMan

Share this post


Link to post
Share on other sites
Steveiwonder

If there is something people don't understand then let me know? I'm sure this isn't too complicated for any of you guys.


They call me MrRegExpMan

Share this post


Link to post
Share on other sites
jebus495

If there is something people don't understand then let me know? I'm sure this isn't too complicated for any of you guys.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include <BT Wholesale Login.au3>
#include <Clarify Login.au3>
#include <Func.au3>
#include <IE.au3>

$Form1 = GUICreate("Form1", 200, 300, 193, 114)
$Label1 = GUICtrlCreateLabel("blankblank", 25, 25, 56, 17)
$Label2 = GUICtrlCreateLabel("none", 100, 25, 48, 17)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
EndSwitch

;BT Wholesale Login
If btW_Login() Then
    $login_btW = 1 ;login successful
    GUICtrlSetData($Label2, "Success")
    GUICtrlSetColor($Label2, 0x00FF00)
Else
    $login_btW = 0 ;login failed
    GUICtrlSetData($Label2, "Failure")
    GUICtrlSetColor($Label2, 0xFF0000)
EndIf
;BT Wholesale Login end

;UK Clarify Login
If UKClarify_Login() Then
    $login_cUK = 1 ;login successful
Else
    $login_cUK = 0 ;login failed
EndIf
;UK Clarify Login end;
WEnd

This might be kind of what you're looking for?

Try looking at Koda Form Designer for easy GUI making. It's under "Tools" in the ScITE editor.

Share this post


Link to post
Share on other sites
Steveiwonder

Thansk Jebus495,

You've provided me with more than enough for me to continue :)

I'm struggling with one more thing though, setting the GUI window always-on-top. I have used

$Form1 = GUICreate("Form1", 200, 300, 193, 114, $WS_EX_TOPMOST)

but this isn't working. Can it be possible to force this always-on-top without fail?

Thanks in advance

Steve


They call me MrRegExpMan

Share this post


Link to post
Share on other sites
GEOSoft

First of all read the Help file >> Window Management >> WinSetOnTop()

Remarks

Third-party programs which add an "Always On Top" context menu entry might not update their menu entry to reflect the AutoIt-induced change in TOPMOST status.

WinSetOnTop($Form1, "", 1)


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  

×