Sign in to follow this  
Followers 0
DocRock

Multiple Instances

9 posts in this topic

I am new at this program, but relatively familiar with VB, so it <shouldn't> be to hard....

My first stab a a program goes like this:

;8.14.07 first try using AutoIt
;AutoNotesBackup.au3
    ShellExecutewait("C:\Program Files\MediNotes\MediBack.exe")
    WinActivate ("MediNotes Backup")
    ControlClick ("Medinotes Backup","","[CLASS:Button; INSTANCE:2]","left")
;send ("{ENTER}")
;WinActivate("C:\Program Files\MediNotes\dbbackup.exe")
;Send ("Y{ENTER}")

This is supposed to work. However, when I compile and run it, I get 40 or 50 instances of the program, "MediBack.exe". I have no loops or iterations, so I don't understand why it is working that way.

Also, what is the best way to send a left click or "Enter"? You can see a couple of tries, but they haven't worked. The final part of the code works in about 1 of the 50 iterations to send a "Y{Enter}" to the dbbackup.exe program that is spawned.

Thanks for any help.

Doc Rock

Share this post


Link to post
Share on other sites



did you happen to name your script MediBack.au3 or exe?

I made the same mistake :)

Share this post


Link to post
Share on other sites

Im sure its just me since i too am new. But it appears that you have the last 3 lines commented out.

Dont know if that helps at all.

Share this post


Link to post
Share on other sites

Your program being an exe you won't need to use ShellExecute - try replacing it with a simple Run command.

Also the Wait option seem to be misplaced because the script will pause until the program execution ends and you want to do something (send something) while the program is running.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

I am new at this program, but relatively familiar with VB, so it <shouldn't> be to hard....

Welcome to AutoIt! :)

My first stab a a program goes like this:

;8.14.07 first try using AutoIt
;AutoNotesBackup.au3
    ShellExecutewait("C:\Program Files\MediNotes\MediBack.exe")
    WinActivate ("MediNotes Backup")
    ControlClick ("Medinotes Backup","","[CLASS:Button; INSTANCE:2]","left")
;send ("{ENTER}")
;WinActivate("C:\Program Files\MediNotes\dbbackup.exe")
;Send ("Y{ENTER}")
Since you are doing a WinActivate() right after execution, I doubt you really want ShellExecuteWait, probably meant just ShellExecute. When you add the 'Wait' the script is blocked, or 'paused' until the spawned process closes.

This is supposed to work.

How many times have I said that (while banging my head on the keyboard)... :)

However, when I compile and run it, I get 40 or 50 instances of the program, "MediBack.exe". I have no loops or iterations, so I don't understand why it is working that way.

The only way I see for that is if you compiled your script as MediBack.exe, and it was calling itself. Otherwise there would have to be a loop in there somewhere to get that symptom.

Also, what is the best way to send a left click or "Enter"?

ControlClick() and ControlSend() are more reliable than just MouseClick() or Send(), because they ensure the action is passed to the correct window.

You can see a couple of tries, but they haven't worked. The final part of the code works in about 1 of the 50 iterations to send a "Y{Enter}" to the dbbackup.exe program that is spawned.

Some notes on your code:

1. You probably didn't really want ShellExecuteWait

2. WinActivate should be preceded by WinWait, because otherwise it will be looking for the window a few milliseconds after execution, and it may not come up that fast.

3. The default WinTitleMatchMode is to match on left string, and it's case sensitive. Be sure "MediNotes Backup" is exactly right if you're going to use that for the title.

4. I'm not sure how critical it is, but there isn't usually a space after the semicolon in parameters like "[CLASS:Button;INSTANCE:2]"

5. The ugly thing about Send() is it will send to anything that has current focus, and that's why ControlSend() is better.

6. The WinActivate() with the .exe file for a title is surely wrong, unless that really is the window title.

Thanks for any help.

Well, this may or may not be help... :P

Doc Rock

What kind of name is that? And are you into bonsai, or did your tree run around the stake until it got tied up in its leash...?

:)

Never mind that, it's past my bed time.


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

did you happen to name your script MediBack.au3 or exe?

I made the same mistake :)

No, the program it call is is MediBack.exe. I named it something else. Thanks for the try

Share this post


Link to post
Share on other sites

What kind of name is that? And are you into bonsai, or did your tree run around the stake until it got tied up in its leash...?

:)

Never mind that, it's past my bed time.

Well, I think it's working now. This is my "final" code

;8.14.07 first try using AutoIt
;AutoNotesBackup.au3
;8.16.07 looks good now, I think...
    Run("C:\Program Files\MediNotes\MediBack.exe")
    WinWait("MediNotes Backup","",1)
    WinActivate ("MediNotes Backup")
    Winwait("MediNotes Backup","",1)
    ControlClick ("Medinotes Backup","","[CLASS:Button;INSTANCE:2]","left")
    Winwait("C:\Program Files\MediNotes\dbbackup.exe","",1)
    WinActivate("C:\Program Files\MediNotes\dbbackup.exe")
    Send ("Y{ENTER}")
    sleep (600000)
    send ("Y{ENTER}")

I'm note sure yet about the sleep line yet. I have to wait about 5 minutes for the dbbackup.exe program to do its thing before I sanr the next "Y{Enter}", so it seemed the right thing to do... This happens in a DOS box so I am limited somewhat

As far as the name...

I'm an Orthopaedic Surgeon (Thus the "Doc"). The symbol of Orthopaedics is the bent tree being straightened (Ortho=straight; Paed=child) as we used to do with crooked children with polio. Rock is just the first part of my name!!!

Thanks for the help. This seems to be a very valuable program, if I can only get through the syntax!!

Doc Rock

Share this post


Link to post
Share on other sites

Well, I think it's working now. This is my "final" code

Run("C:\Program Files\MediNotes\MediBack.exe")
    WinWait("MediNotes Backup","",1)
    WinActivate ("MediNotes Backup")
So far, so good!

Winwait("MediNotes Backup","",1)

Go for WinWaitActive() here. WinWait only tests for the window to exist.

WinWaitActive tests for the window to be the 'active' window with desktop focus.

That's a common series of functions when waiting for a window to pop up:

WinWait()

WinActivate()

WinWaitActive()

ControlClick ("Medinotes Backup","","[CLASS:Button;INSTANCE:2]","left")
    Winwait("C:\Program Files\MediNotes\dbbackup.exe","",1)
    WinActivate("C:\Program Files\MediNotes\dbbackup.exe")
    Send ("Y{ENTER}")
    sleep (600000)
    send ("Y{ENTER}")

I'm note sure yet about the sleep line yet. I have to wait about 5 minutes for the dbbackup.exe program to do its thing before I sanr the next "Y{Enter}", so it seemed the right thing to do... This happens in a DOS box so I am limited somewhat

As far as the name...

I'm an Orthopaedic Surgeon (Thus the "Doc"). The symbol of Orthopaedics is the bent tree being straightened (Ortho=straight; Paed=child) as we used to do with crooked children with polio. Rock is just the first part of my name!!!

Thanks for the help. This seems to be a very valuable program, if I can only get through the syntax!!

Doc Rock

Of course you didn't owe any explanation, I was just trying to be.... humerus! :)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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