pipetman Posted April 30, 2007 Share Posted April 30, 2007 Hi, I'm complete new to AutoIT, but think it could be helpful to a particular problem I have. I run a microscope, that loads it samples automatically onto the stage, then focuses, takes an image and loads the next sample. Occasionally, it can't focus and the microscope software comes up with an error message, requiring user intervention. It is this need for user intervention, that I'd like to get rid off. Pressing some button in the error message window at this point simply continues with the remaining samples, which I'd like the AutoIT script to do. I'm just not sure how exactly to go about this. I was thinking about running the script parallel to the microscope software and checking e.g. every 5 minutes, if the error message window is present. If it is, the script clicks the 'continue' button and keeps monitoring until I shut it down. So the script could look something like this: [Create GUI with 'Close' button, that allows to shut down the script] Do [ErrorMessageExists]=false If [ErrorMessageExists]= true Then [ClickSomeButton] Else [wait for 5 minutes] EndIf Until [i press the 'Close' button] Is that a reasonable way to go about it (I don't have much experience in scripting)? Some of the stuff in square brackets I can probably figure out, but having looked only briefly at the documentation, I didn't find a way to poll for the existence of a window and didn't find a way put this 5 min delay in. A little help would be greatly appreciated. Thanks - p Link to comment Share on other sites More sharing options...
PaulIA Posted April 30, 2007 Share Posted April 30, 2007 Hi, I'm complete new to AutoIT, but think it could be helpful to a particular problem I have. I run a microscope, that loads it samples automatically onto the stage, then focuses, takes an image and loads the next sample. Occasionally, it can't focus and the microscope software comes up with an error message, requiring user intervention. It is this need for user intervention, that I'd like to get rid off. Pressing some button in the error message window at this point simply continues with the remaining samples, which I'd like the AutoIT script to do. I'm just not sure how exactly to go about this. I was thinking about running the script parallel to the microscope software and checking e.g. every 5 minutes, if the error message window is present. If it is, the script clicks the 'continue' button and keeps monitoring until I shut it down. So the script could look something like this: [Create GUI with 'Close' button, that allows to shut down the script] Do [ErrorMessageExists]=false If [ErrorMessageExists]= true Then [ClickSomeButton] Else [wait for 5 minutes] EndIf Until [i press the 'Close' button] Is that a reasonable way to go about it (I don't have much experience in scripting)? Some of the stuff in square brackets I can probably figure out, but having looked only briefly at the documentation, I didn't find a way to poll for the existence of a window and didn't find a way put this 5 min delay in. A little help would be greatly appreciated. Thanks - pWelcome to the forum. Your approach is indeed logical. Start by looking at the following AutoIt functions in the help file: WinExists WinActive WinActivate GUIGetMsg ControlSend Also use the AutoIt info tool to determine the control type (probably just an ordinary button) and ID that you need to use. If you get stuck, feel free to post you code and we'll do what we can to help you out. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Zedna Posted April 30, 2007 Share Posted April 30, 2007 Also look at AdlibEnable function and it's examples.For creating Autoit GUIs use Koda form designer, it's in Scite4Autoit3 (menu Tools) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
herewasplato Posted April 30, 2007 Share Posted April 30, 2007 (edited) Use the "AutoIt Window Info" tool to get/copy/paste the window title and text mentioned below.[start > Programs > AutoIt v3 > AutoIt Window Info]Replace $title = "title" with the window title of the error message.Replace $text = "text" with some window text of the error message.Then run the script below:AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("TrayIconDebug", 1) HotKeySet("{ESC}", "Terminate") $title = "title" $text = "text" While 1 TrayTip("Microscope Script", "Press Esc to Exit", 100) If WinExists($title, $text) Then WinActivate($title, $text) WinWaitActive($title, $text) Send("{ENTER}") EndIf Sleep(200) WEnd Func Terminate() Exit EndFunc ;==>TerminateThe script assumes that you want to send "ENTER" to the error message - you can change that to handle the error message as needed and to load the next sample all within the If/EndIf area.Take a look at the Control functions if you want something more reliable than "Send"....hope this helps...Edit: Welcome to the forum. Edited April 30, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
pipetman Posted May 1, 2007 Author Share Posted May 1, 2007 Wow, thanks everybody - This is extremely helpful - p Link to comment Share on other sites More sharing options...
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