DrLarch Posted January 3, 2012 Share Posted January 3, 2012 I've been using AutoIt for some time now (started with AutoIt 2.x), but this is my first post. The problem I'm having is with the WinWait() function. I've read older posts with people complaining that it won't recognize windows properly (returns a 0 even though the window is present) and some chalked it up to an Adlib problem which supposedly is fixed in recent versions (running 3.3.6.1). But it is STILL a problem that I'm experiencing - it simply seems to be a rather unreliable function. It seems I have to go through heroic measures just to detect the pesky window that WinWait() simply can't see. Other functions can see it just fine (ie. WinGetText(), WinMove(), etc). I'm by no means an advanced coder, but I know when something isn't working. Here's my code that won't detect a particular window: $wincheck= WinWait ("Exercise Pro V5 ", "", 4) MsgBox (0, "test'", $wincheck) ; for troubleshooting If $wincheck= 0 Then MsgBox (0, "Installer Error", "Installation couldn't be completed." & @CRLF & "Please try again after other installs are finished." & @CRLF & "Cancelling...") WinWait ("BioEx Software", "Click the Finish button") WinActivate ("BioEx Software", "Click the Finish button") WinWaitActive ("BioEx Software", "Click the Finish button") SendKeepActive ("BioEx Software", "Click the Finish button") Sleep (100) Send ("!f") WinWaitClose ("BioEx Software", "Click the Finish button") Exit EndIf ...versus if I do this it works just fine: For $i = 1 to 6 $checktext = WinGetText ("Exercise Pro V5") $checktest = StringInStr ($checktext, "Please wait while Windows configures Exercise") If $checktest <> 0 Then ; Success - Correct window exists ExitLoop EndIf Sleep (1000) if $checktest = 0 And $i = 6 Then MsgBox (0, "Installer Error", "Installation couldn't be completed." & @CRLF & "Please try again after other installs are finished." & @CRLF & "Cancelling...") WinWait ("BioEx Software", "Click the Finish button") WinActivate ("BioEx Software", "Click the Finish button") WinWaitActive ("BioEx Software", "Click the Finish button") SendKeepActive ("BioEx Software", "Click the Finish button") Sleep (100) Send ("!f") WinWaitClose ("BioEx Software", "Click the Finish button") Exit EndIf Next I hate having to add WinWait, WinActivate, WinWaitActive, just to provide a bit of insurance for commands that don't seem to work reliably as well. Anyone have any feedback on these buggy (at least that's my impression) window sensing functions? I've tried using controls or handles for dealing with windows, but these don't stay consistent in one of the installers I'm automating. I've had to often turn my own routines that work into my own functions, but am still a little perplexed why the built-in ones seem to be flakey... Thanks! Link to comment Share on other sites More sharing options...
goldenix Posted January 3, 2012 Share Posted January 3, 2012 in first code you have a space at the end of the window name, in second sample you dont.when dealing with windows hire are some useful functions:Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase or Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=enables winhandles, -1 to -4=Nocasethere is also WinGetHandle() & WinList() My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
guinness Posted January 3, 2012 Share Posted January 3, 2012 Also use Au3Info to help you find more information about the window you're trying to interact with. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Valoo Posted February 13, 2012 Share Posted February 13, 2012 (edited) Hi,Just to let you know, on a project i am working on, I was having irreliable behavior with the winwait function...The thing was, I was trying to get the focus on a window with the title "Ouvrir" (french for "open") and then Send a local url to automate the "Save as..." function on a specific software...When I realised I could compare the title of a window, returned form the winwait function via the handle of the window :WinGetTitle(WinGetHandle("Ouvrir"))I found that there was a conflict with the firefox window (always opened of course ). There was some sort of a hidden windows with a title like "Ouvrir dans un nouvel onglet" which corresponds to a line in a "right-clic" menu in firefox... strange...anyway, problem solved,Hope that helps,cheersEdit : Opt("WinTitleMatchMode", 3) would have solved the problem Edited February 13, 2012 by Valoo 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