Jump to content

Can't get this to work


 Share

Recommended Posts

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?

Link to comment
Share on other sites

  • Developers

- why are you doing?: Until WinWaitClose("NIC Address and Computer Name")

This will ensure the loop never loops.

Shouldn't that be Until Not WinExists("NIC Address and Computer Name") ?

- Is the text in the active window exact "NOT found in Server Database" ? or is is part of the text on the window ?

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

- why are you doing?: Until WinWaitClose("NIC Address and Computer Name")

This will ensure the loop never loops.

Shouldn't that be Until Not WinExists("NIC Address and Computer Name") ?

- Is the text in the active window exact "NOT found in Server Database" ? or is is part of the text on the window ?

Sorry I didn't clarify.

There's a program that's run (getnicaddress) that gets the MAC address (and other info) about the machine. Most of the time it's able to get the information, but sometimes (depending on the location and the security policies) it can't get the MAC address.

The point of this script is that if the dialog box comes up and says that it successfully got the MAC address, it then runs the main programs. If the dialog box comes up and says that it was unsuccessful in getting the MAC address, I would want it to run a command prompt with "ipconfig /all" and then open up the .ini file in notepad so I can manually enter in the MAC. After notepad is closed, the script would continue and run the main program.

Hope this helps. It's not so much that I'm looking for a loop, but more of a if this, then this but if this then this.

Thanks again.

P.S. I did try and figure this out on my own with the help of the fourms and the help file in autoit. That's how I was able to get this slop of code.

Link to comment
Share on other sites

  • Developers

Sorry I didn't clarify.

There's a program that's run (getnicaddress) that gets the MAC address (and other info) about the machine. Most of the time it's able to get the information, but sometimes (depending on the location and the security policies) it can't get the MAC address.

The point of this script is that if the dialog box comes up and says that it successfully got the MAC address, it then runs the main programs. If the dialog box comes up and says that it was unsuccessful in getting the MAC address, I would want it to run a command prompt with "ipconfig /all" and then open up the .ini file in notepad so I can manually enter in the MAC. After notepad is closed, the script would continue and run the main program.

Hope this helps. It's not so much that I'm looking for a loop, but more of a if this, then this but if this then this.

Thanks again.

P.S. I did try and figure this out on my own with the help of the fourms and the help file in autoit. That's how I was able to get this slop of code.

My point is that your loop doesn't loop at all but only runs one time.

Change the WinWaitClose to WinExists and the loop will start looping and the If will start IFing :) and when true will start the IPConfig...

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

My point is that your loop doesn't loop at all but only runs one time.

Change the WinWaitClose to WinExists and the loop will start looping and the If will start IFing :) and when true will start the IPConfig...

I'm don't think I want it to loop. Maybe I've written the wrong thing entirely.

I'm looking to have the script analyze a dialog box and depending on what the box says, do one of two things.

If then dialog box says A then it does A and then runs the main program but if the dialog box says B then it does B and runs the (same) main program.

In looking at the examples, I figured they way I wrote it was the right way, but I don't know anymore.

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