Sign in to follow this  
Followers 0
myotis

launching and switching programs

9 posts in this topic

#1 ·  Posted (edited)

I would like to write an AutoIT script that I can run from Active Words that will launch a program if it isn't running, but will simply switch to the active window if it is already running.

The program I am switching to, tries to start a second instance of the program and gives an error that I am only licensed to run a single copy.

I assuming that I should write the script, compile it and then run the exe from Active Words

The program needs a switch to stop the splash screen and you need to specify the name of database.

ie

"C:\Program Files\Balboa\LMW4.exe" /nosplash ecology

Can anyone help me get started with this.

I have tried the tutorial, compiled the hello world script and run it as an exe from Active Words so I understand the basic process but have no experience of scripting or AutoIT.

Many thanks,

Graham

Edited by myotis

Share this post


Link to post
Share on other sites



Can anyone help me get started with this.

I don't know what Active Words is, but I would read up the following functions in the help manual:

WinExists, ProcessExists, Run, If/Then/Else

and you should be off to a good start. Once you have some lines written press F5 to run it and see what the error checking tells you is wrong. It will show the line number and the point at which it failed.


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

I don't know what Active Words is, but I would read up the following functions in the help manual:

WinExists, ProcessExists, Run, If/Then/Else

Thanks, I shall give these a look. I now have a script that launces Library Master working. So hopefully looking at these functions will help with the next bit.

Active Words is a sort of macro program http://www.activewords.com/ but with some users augmenting it with AutoIT. It was Active Words support that suggested AutoIT to me.

Thanks again,

Graham

Share this post


Link to post
Share on other sites

Please post your script when you get a few steps done and we can take a look.

<{POST_SNAPBACK}>

Thanks, but that may be some time,as I don't really know where to start :-(

I have cobbled together this, but needless to say it doesn't work.

If WinExists ("Library Master") Then

WinActivate ("Library Master", "")

EndIf

Run ("C:\Program files\Balboa\LM4\LMW.exe")

I have assumed that with the endif statement, that if the window doesn't exsit then the script will move onto the next line.

I have also tried

If ProcessExists ("LMW.exe") Then

as my first line, but it doesn't work either.

So I assume it is the second line that is wrong. It launches the program OK, but doesn't switch to the open window.

However the full window title is

Library Master - Ecology - [Ecology - Brief view - record 819 - Total 580 Records - showing 780 records]

So I am not sure what I need to type into the script to describe the open window. Also, part of the title will vary with the view the prgram happens to be in, and will change as records are added.

I also need to add the switch /nosplash and the name of the database to open which is "ecology".

C:\Program Files\Balboa\LM4\LMW.exe /nosplash ecology

This would normally launch the program with the ecology database loaded but doesn't work, so I obviously haven't got the syntax for this right either .

I am also not sure how I step through the script with F5 (this inserts the date in Notepad). Are you using a proper editor to write the script?

nd o your other point, Active Words has a three machine license, and yes it does have some useful out of the box tools, but it won't cope with this problem

Macro Express copes with this problem out of the box, and if I wasn't finding Active Words easier to set up and run, and finding the Plugins useful, I would just stick to Macro Express http://www.macros.com/

Thanks for your help,

Graham

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks, but that may be some time,as I don't really know where to start :-(

I have cobbled together this, but needless to say it doesn't work.

If WinExists ("Library Master") Then

WinActivate ("Library Master", "")

EndIf

Run ("C:\Program files\Balboa\LM4\LMW.exe")

<{POST_SNAPBACK}>

To reply to myself, I sort of have this working now

If WinExists ("Library Master - Ecology - [Ecology - Brief View - Record 819 - Total 580 Records - Showing 780 Records]") Then

Winactivate("Library Master - Ecology - [Ecology - Brief View - Record 819 - Total 580 Records - Showing 780 Records]")

Else

Run ("C:\Program Files\Balboa\LMW4\Lmw.exe")

EndIf

I was obviously wrong in my earlier assumptions.

Indeed, I can shorten this to just

If WinExists ("Library Master") Then

Winactivate("Library Master")

Else

Run ("C:\Program Files\Balboa\LMW4\Lmw.exe")

EndIf

And it works.

What I cannot figure out at the moment is how to fit in the

/nosplash ecology bit.

Graham

Edited by myotis

Share this post


Link to post
Share on other sites

What I cannot figure out at the moment is how to fit in the

/nosplash ecology bit.

Graham

<{POST_SNAPBACK}>

Mmmm, well I am sure I tried this before, but

If WinExists ("Library Master") Then

Winactivate("Library Master")

Else

Run ("C:\Program Files\Balboa\LMW4\Lmw.exe /nosplash ecology")

EndIf

Works just fine this time.

I will just compile it and I will be able to run it from Active Words.

Many thanks for your help, without your pointers I would still be floundering about.

Graham

Share this post


Link to post
Share on other sites

If WinExists ("Library Master") Then

Winactivate("Library Master")

Else

Run ("C:\Program Files\Balboa\LMW4\Lmw.exe /nosplash ecology")

EndIf

Excellent job! It's nice to see your motivation to learn AutoIT.

Keep in mind that the reason that you can use only the beginning part of the window title is because that's the default for "windowtitlematchmode":

From the manual:

"WinTitleMatchMode Alters the method that is used to match window titles during search operations.

1 = Match the title from the start (default)

2 = Match any substring in the title

3 = Exact title match

4 = Advanced mode, see Window Titles & Text (Advanced)"

In any case, great work!


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Excellent job! It's nice to see your motivation to learn AutoIT.

Keep in mind that the reason that you can use only the beginning part of the window title is because that's the default for "windowtitlematchmode":

<{POST_SNAPBACK}>

In fact the default is what I want, because the rest of it is likely to change. Anyway it was an interesting experience and might well get me started to try and script other ("simple") things in the future.

Thanks again for your help.

Graham

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