Jump to content

Unsure on how to pass form info on


Brentp
 Share

Recommended Posts

Hi All,

I am trying to make a tool to configure Outlook, that when run it will ask the user their name, email address, username and password

Ive gone through examples and have the two parts I need,

firstly the GUI with the fields and descriptions

and secondly the part that runs Outlook and watches when to insert certain things.

I just cant figure out how to put the two together.

I want the GUI to come up then the user enters in their details then they click OK, then the GUI closes and it launches Outlook and does setup on its own, filling in the details it gathered from the user.

In the 2nd section I haven't gone through and added the variables yet other than the $usernameinput

Thanks

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

$gui = GUICreate("Outlook Configuration", 534, 383)
$nameinput = GUICtrlCreateInput("Name", 8, 40, 217, 21)
$emailinput = GUICtrlCreateInput("Email Address", 8, 65, 270, 21)
$usernameinput = GUICtrlCreateInput("Username", 8, 90, 217, 21)
$passwordinput = GUICtrlCreateInput("password", 8, 115, 217, 21,$ES_PASSWORD)
$username = GUICtrlCreateLabel("Username - Enter your Email Username", 8, 150, 436, 17)
$password = GUICtrlCreateLabel("Password - Enter your password", 8, 200, 436, 17)
$ok=GUICtrlCreateButton("OK",8,241,217,30)

GUISetState()

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

WEnd 
 EndSwitch

 

 
Run("C:\Program Files\Microsoft Office\Office14\OUTLOOK.exe")
WinWaitActive("Microsoft Outlook 2010 Startup")
Send("{ENTER}")
WinWaitActive("Account Configuration")
Send("{ENTER}")
WinWaitActive("Microsoft Outlook")
Send("{TAB}{TAB}{TAB}{SPACE}{ENTER}")
WinWaitActive("Connect to")
Send("{TAB}{TAB}{TAB}{TAB}")
Send("Domain\", $usernameinput)
WinWaitActive("Add New Account", "Your e-mail account is successfully configured")
Send("{ENTER}")
Link to comment
Share on other sites

in your while Loop you will need to check the info you entered in your GUI

$usernameinput = GUICtrlRead($usernameinput)

$passwordinput = GUICtrlRead($passwordinput)

And after you use send

        Send($passwordinput)

But to fill a form .. I Don't know yet how to do that, i use the mousmove function to click at the right place and they type what i need...

Link to comment
Share on other sites

Where am I supposed to stick the GUICtrlRead?

Ive manage to make my button move on and launch outlook, by making it call a function

But at the part where it should insert the text $nameinput gathered from the users input it just sticks a 0

Slowly getting there,

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

Global $gui = GUICreate("Outlook Configuration", 534, 383)
Global $nameinput = GUICtrlCreateInput("Name", 8, 40, 217, 21)
Global $emailinput = GUICtrlCreateInput("Email Address", 8, 65, 270, 21)
Global $usernameinput = GUICtrlCreateInput("Username", 8, 90, 217, 21)
Global $passwordinput = GUICtrlCreateInput("password", 8, 115, 217, 21, $ES_PASSWORD)
Global $username = GUICtrlCreateLabel("Username - Enter your Email Username", 8, 150, 436, 17)
Global $password = GUICtrlCreateLabel("Password - Enter your password", 8, 200, 436, 17)
Global $ok = GUICtrlCreateButton("OK", 8, 241, 217, 30)


GUISetState()

While 1
    $nMsg = GUIGetMsg()
    $nameinput = GUICtrlRead($nameinput)

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ok
            ;$nameinput = GUICtrlRead($nameinput)
            OLconfig()
    EndSwitch
WEnd

Func OLconfig()

    Run("C:\Program Files\Microsoft Office\Office14\OUTLOOK.exe")
    WinWaitActive("Microsoft Outlook 2010 Startup")
    Send("{ENTER}")
    WinWaitActive("Account Configuration")
    Send("{ENTER}")
    WinWaitActive("Add New Account")
    Send("{TAB}")
    Send($nameinput)
EndFunc   ;==>OLconfig
Edited by Brentp
Link to comment
Share on other sites

I figured it out

Thanks NightKnightQC The GUICtrlRead lead me to the solution.

Im not sure if its all in the best order, but its now working.

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

Global $gui = GUICreate("Outlook Configuration", 534, 383)
Global $nameinput = GUICtrlCreateInput("Name", 8, 40, 217, 21)
Global $emailinput = GUICtrlCreateInput("Email Address", 8, 65, 270, 21)
Global $usernameinput = GUICtrlCreateInput("Username", 8, 90, 217, 21)
Global $passwordinput = GUICtrlCreateInput("password", 8, 115, 217, 21, $ES_PASSWORD)
GUICtrlCreateLabel("Username - Enter your Email Username", 8, 150, 436, 17)
GUICtrlCreateLabel("Password - Enter your password", 8, 200, 436, 17)
Global $ok = GUICtrlCreateButton("OK", 8, 241, 217, 30)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    $name = GUICtrlRead($nameinput)
    $email = GUICtrlRead($emailinput)
    $username = GUICtrlRead($usernameinput)
    $password = GUICtrlRead($passwordinput)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ok
            OLconfig()
    EndSwitch
WEnd

Func OLconfig()

    Run("C:\Program Files\Microsoft Office\Office14\OUTLOOK.exe")
    WinWaitActive("Microsoft Outlook 2010 Startup")
    Send("{ENTER}")
    WinWaitActive("Account Configuration")
    Send("{ENTER}")
    WinWaitActive("Add New Account")
    Send("{TAB}")
    Send($name)
    Send("{TAB}")
    Send($email)
    Send("{TAB}")
    Send($password)
    Send("{TAB}")
    Send($password)
    Send("{ENTER}")
    WinWaitActive("Connect to")
    Send("{TAB}{TAB}{TAB}{TAB}")
    Send("Domain\" & $username)
    Send("{ENTER}")
    WinWaitActive("Add New Account", "Your e-mail account is successfully configured")
    Send("{ENTER}")
    exit
EndFunc
Edited by Brentp
Link to comment
Share on other sites

Im not sure if its all in the best order

No it's not. The ctrls are always read because it's placed outside a condition in your infinite loop.

The best choice is to read the ctrls when you need their data, so when you click the $ok button.

...
While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ok
            ;here
            $name = GUICtrlRead($nameinput)
            $email = GUICtrlRead($emailinput)
            $username = GUICtrlRead($usernameinput)
            $password = GUICtrlRead($passwordinput)
            OLconfig()
    EndSwitch
WEnd
OR even better

Func OLconfig()
    ;here
    $name = GUICtrlRead($nameinput)
    $email = GUICtrlRead($emailinput)
    $username = GUICtrlRead($usernameinput)
    $password = GUICtrlRead($passwordinput)
...
Edit: Added indents.

Note: Don't forget to declare all your variables according to their scope.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Another option you might look at is CtrlClick instead of Tab and Enter sends.

You might also be interested in Run("control mlcfg32.cpl") to launch the mail utility from the control panel, allowing you to setup new accounts when one already exists.

Link to comment
Share on other sites

Thanks Firefox, I made the change.

Once you click the OK button is there away I can hide it or even close the box,

blckpythn - Does CtrlClick work off co-ordinates or the button name, I am wondering if its co-ordinates and someone has a different resolution will it cause problems. or does it not work that way?

Link to comment
Share on other sites

Thanks Firefox, I made the change.

Once you click the OK button is there away I can hide it or even close the box,

blckpythn - Does CtrlClick work off co-ordinates or the button name, I am wondering if its co-ordinates and someone has a different resolution will it cause problems. or does it not work that way?

 

It works off of control ID, so even if there are multiple buttons with the same name, it will select the correct one. Resolution will not be a problem at all.

To get the control ID, you can use the Au3Info tool found in the Tools menu of Scite.

Link to comment
Share on other sites

  • 2 weeks later...

This project is still going,

What I am trying to do now is,

The user enters their name and login details, then when they click 'OK' I want it to say 'are you sure you entered the details correctly'

Which I have a window popup and ask that, It has two buttons One to let you go back and check the details and the other to continue the script 

But I don't know to get it when you click the Check button to go back to the part where they enter their details.

I can Hide the confirm box, but on the window where they put their details, the OK button no longer works, Which I guess is because the script has moved on past this part

How do I jump back to that part making the button OK clickable again.

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

MsgBox (16, "GW2Outlook", "Before continuing, please save any open documents and exit all running Programs/Applications")

$hGUI = GUICreate( "Outlook Setup", 390, 290, -1, -1)
$hLabel = GUICtrlCreateLabel( "Email Setup", 8, 5, 268, 14)
GUICtrlSetFont( -1, 10)
Global $nameinput = GUICtrlCreateInput( "", 10, 65, 280, 22)
Global $emailinput = GUICtrlCreateInput( "", 10, 108, 280, 22)
Global $usernameinput = GUICtrlCreateInput( "", 10, 151, 280, 22)
Global $passwordinput = GUICtrlCreateInput( "", 10, 194, 280, 22, $ES_PASSWORD)
Global $ok = GUICtrlCreateButton( "OK", 124, 255, 139, 23)
$hLabel2 = GUICtrlCreateLabel( "Please enter your Email login details", 10, 25, 201, 15)
$nameinfo_button = GUICtrlCreateButton( "More Info", 292, 65, 60, 22)
$emailinfo_button = GUICtrlCreateButton( "More Info", 292, 108, 60, 22)
$usernameinfo_button = GUICtrlCreateButton( "More Info", 292, 151, 60, 22)
$passwordinfo_button = GUICtrlCreateButton( "More Info", 292, 194, 60, 22)
$hLabel7 = GUICtrlCreateLabel( "Your Name", 10, 50, 201, 15)
$hLabel6 = GUICtrlCreateLabel( "Email Address", 10, 93, 201, 15)
$hLabel5 = GUICtrlCreateLabel( "Email Username", 10, 136, 201, 15)
$hLabel4 = GUICtrlCreateLabel( "Password", 10, 179, 185, 15)

GUISetState()

While 1
    $hMsg = GUIGetMsg()

    Switch $hMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nameinfo_button
            MsgBox (64, "Your Name", "Please enter your full name, First and Last name.")
        Case $emailinfo_button
            MsgBox (64, "Email Address", "Please enter your Email Address.")
        Case $usernameinfo_button
            MsgBox (64, "Username", "Please enter your 8 digit Email Username.")
        Case $passwordinfo_button
            MsgBox (64, "Password", "Please enter your Password")
        Case $ok
    EndSwitch
WEnd



Func OK()
    $nGUI = GUICreate( "Are You Sure?", 535, 183, -1, -1)
    $hLabel20 = GUICtrlCreateLabel( "Please check that the details you have entered are correct, any incorrect information will cause the installation to fail.", 27, 32, 478, 57)
    $hButton = GUICtrlCreateButton( "Let Me Check", 108, 100, 140, 35)
    $hButton2 = GUICtrlCreateButton( "Its Correct, Continue", 281, 100, 140, 35)
    GUISetState(@SW_SHOW, $nGUI)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUISetState(@SW_HIDE, $nGUI)
        Case $hButton2
            MsgBox (64, "Please Wait", "After clicking 'OK' Please do NOT touch your keyboard or mouse until the installation has completed", 15)
            OLconfig()
    EndSwitch
WEnd

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