Jump to content

My first If.. ElseIf statement


 Share

Recommended Posts

I know something's wrong, I just don't know where:

CODE
Run("C:\pqr\Get_Network_Adapter_Address.exe")

Do

$text = WinGetText("", "")

If $text = ("NOT found in Server Database") Then

Run("notepad.exe C:\pqr\users.ini")

Sleep(500)

Run("cmd.exe")

Sleep(500)

Send("ipconfig /all")

Send("{ENTER}")

WinWaitClose("users.ini - Notepad")

Send("{ENTER 2}")

ElseIf $text = ("Insert Text Here") Then

WinWaitActive("Title" , "Text")

Send("(ENTER)")

WinWaitActive("Title" , "Text")

Send("(ENTER)")

EndIf

Until WinWaitClose("NIC Address and Computer Name")

The first half is (pretty much) completed code. If the MAC address isn't located in the database, the script pulls up a dos prompt, sends it the ipconfig so I can get the MAC, and the opens up the .ini file I need to put the MAC address in.

The second half needs to wait until I have access to a PC to replicate what happens is if does successfully locate the mac in the database. It's all dialog boxes that pop up, which I should be able to deal with.

The trick is not every location will give me this error (some places I visit will allow the program to automatically get the MAC address, other places it won't). At the end of the script, it's going to run the final program (which I think I can handle).

I also am using the WinGetText because the titles of the dialog boxes are the same if the program succeeds or fails.

Hope all of this info is helpful. I've tried for about two hours now to figure this out on my own (and with the help of other posts in the fourms and the help file), but I'm just stumped.

THANKS!

Link to comment
Share on other sites

  • Developers

First of all: After EVERY Run() add WinWaitActive() function.

Just WinWait() will do ... WinWaitActive() could be tricky when the window doesn't get the focus .. :)

Also WinGetText() should have one of the first two parameters filled in that makes the target window unique and thus properly selected.

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

He is using Send() which works only with active window.

So maybe combination: WinWait() + WinActivate()

The reason (in the first section) that I don't user WinWait is because the title of the screen can differ as it's a DOS prompt. The sleep and send works well.

My concern is that I haven't written the code correctly. I have the second half of the info I need and will be putting it in shortly.

Link to comment
Share on other sites

CODE
Run("C:\pqr\Get_Network_Adapter_Address.exe")

Do

$text = WinGetText("", "")

If $text = ("NOT found in Server Database") Then

Run("notepad.exe C:\pqr\users.ini")

Sleep(500)

Run("cmd.exe")

Sleep(500)

Send("ipconfig /all")

Send("{ENTER}")

WinWaitClose("users.ini - Notepad")

Send("{ENTER 2}")

ElseIf $text = ("NIC Address and Computer Name updated Successfully") Then

Send("(ENTER)")

EndIf

Until WinWaitClose("NIC Address and Computer Name")

Run("C:\pqr\program.exe")

(The above is the final code)

With the above code, when it gets to the dialog box that says "Not found in databse", it doesn't open notepad and barrels on through right to the C:\pqr\program.exe

What did I do wrong?

Edited by viriiman
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...