myotis Posted September 10, 2005 Posted September 10, 2005 (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 September 10, 2005 by myotis
jefhal Posted September 10, 2005 Posted September 10, 2005 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
myotis Posted September 10, 2005 Author Posted September 10, 2005 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/ElseThanks, 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
jefhal Posted September 10, 2005 Posted September 10, 2005 (edited) I now have a script that launces Library Master working. Active Words is a sort of macro program Please post your script when you get a few steps done and we can take a look. I used to use GroundControl for macro building until I discoverd AutoIT. I haven't needed to use GC since. I also took a look at ActiveWords just now and it looks very interesting. Of course, what's best about AutoIT is that the executables will run anywhere, whereas GC and AW appear to require a license for each machine. At a school with 500 machines, that a lot of moolah! Edited September 10, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
myotis Posted September 10, 2005 Author Posted September 10, 2005 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") ThenWinActivate ("Library Master", "")EndIfRun ("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") Thenas 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 isLibrary 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 ecologyThis 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 problemMacro 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
myotis Posted September 10, 2005 Author Posted September 10, 2005 (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") ThenWinActivate ("Library Master", "")EndIfRun ("C:\Program files\Balboa\LM4\LMW.exe")<{POST_SNAPBACK}>To reply to myself, I sort of have this working nowIf WinExists ("Library Master - Ecology - [Ecology - Brief View - Record 819 - Total 580 Records - Showing 780 Records]") ThenWinactivate("Library Master - Ecology - [Ecology - Brief View - Record 819 - Total 580 Records - Showing 780 Records]")ElseRun ("C:\Program Files\Balboa\LMW4\Lmw.exe")EndIfI was obviously wrong in my earlier assumptions.Indeed, I can shorten this to justIf WinExists ("Library Master") ThenWinactivate("Library Master")ElseRun ("C:\Program Files\Balboa\LMW4\Lmw.exe")EndIfAnd it works.What I cannot figure out at the moment is how to fit in the/nosplash ecology bit.Graham Edited September 10, 2005 by myotis
myotis Posted September 10, 2005 Author Posted September 10, 2005 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, butIf WinExists ("Library Master") ThenWinactivate("Library Master")ElseRun ("C:\Program Files\Balboa\LMW4\Lmw.exe /nosplash ecology")EndIfWorks 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
jefhal Posted September 10, 2005 Posted September 10, 2005 If WinExists ("Library Master") ThenWinactivate("Library Master")ElseRun ("C:\Program Files\Balboa\LMW4\Lmw.exe /nosplash ecology")EndIfExcellent 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 title3 = Exact title match4 = 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
myotis Posted September 10, 2005 Author Posted September 10, 2005 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now