GNGNUT Posted September 15, 2011 Share Posted September 15, 2011 (edited) hi guys new to all this and still getting my head around it i have a simple script for work, when we need to create a button on our systems we get a lot of errors before we can choose the button we want to addso i have created this Func _WinWaitActivate($vWintitle, $vWinText, $timeout)WinWait($vWintitle, $vWinText, $timeout)If Not WinActive($vWintitle, $vWinText) Then WinActivate($vWintitle, $vWinText)WinWaitActive($vWintitle, $vWinText, $timeout)EndFunc ;==>_WinWaitActivate for $i = 1 to 400error()Next func error() $vWintitle = "Error" $vwintext = "OK" $vbut = "[CLASS:Button; INSTANCE:1]" _WinWaitActivate($vWintitle, $vWinText, 2) Controlclick ($vWintitle,$vWinText,$vbut)EndFunc This error Has different count depending on the system (enviroment) we are using and currently set at 366 timethe loop runs too slow (1 sec per click) and wondering if i can speed this loop up "pending the error window box" kind regardscraig Edited September 15, 2011 by GNGNUT Link to comment Share on other sites More sharing options...
water Posted September 15, 2011 Share Posted September 15, 2011 (edited) Do I understand you correctly that you have an application that throws an error window from time to time and if the error window appears you want your script to click on the button? If yes, we have something similar created for the OutlookEX UDF to click away the Outlook security warning. _OL_Warnings is started by the main script. It waits until the error window appears and clicks the OK button. The _OLWarnings script is terminated when the calling process has finished. Edited September 15, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
ChrisL Posted September 15, 2011 Share Posted September 15, 2011 Put Opt("WinWaitDelay",1) at the top of your script [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
water Posted September 15, 2011 Share Posted September 15, 2011 (edited) I would use: error(400) Func error($number) $vWintitle = "Error" $vWinText = "OK" $vbut = "[CLASS:Button; INSTANCE:1]" For $i = 1 To $number WinWait($vWintitle, $vWinText, 2) If Not WinActive($vWintitle, $vWinText) Then WinActivate($vWintitle, $vWinText) WinWaitActive($vWintitle, $vWinText, $timeout) ControlClick($vWintitle, $vWinText, $vbut) Next EndFunc ;==>errorShould be much faster because you eliminate 800 function calls. Edited September 15, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GNGNUT Posted September 15, 2011 Author Share Posted September 15, 2011 (edited) thank you for you feed back guys @water 1st message basicly i need this to function when i only goto add icon due to needing to read system errors that may only pop up here and therei know there is a issue when adding icon, and this is the reason for the small script only problem is i dont have a lot to work with.below is the summary from the info help tool I could set it to use the visable text but there can be a lot of different errorsand that leading to 300 + different bits of script for ever one. >>>> Window <<<<Title: ErrorClass: #32770Position: 822, 491Size: 281, 126Style: 0x94C801C5ExStyle: 0x00010101Handle: 0x005203D0>>>> Control <<<<Class:Instance:ClassnameNN:Name:Advanced (Class):ID:Text:Position:Size:ControlClick Coords:Style:ExStyle:Handle:>>>> Mouse <<<<Position: 970, 506Cursor ID: 2Color: 0x0055EA>>>> StatusBar <<<<>>>> ToolsBar <<<<>>>> Visible Text <<<<OKUnable to set com-handle property. (5677)>>>> Hidden Text <<<< @ water. 2nd message. this script seems to run at the same speed as the one I wrote not sure if its the winwait part holding it up or the winactivate as it needs to do this each time. @chrisl. this speeds it up but if there is a small dely in the screen coming up it will end the script. have been playing with it func error() $vWintitle = "Error" $vwintext = "OK" $vbut = "[CLASS:Button; INSTANCE:1]" winActive($vWintitle, $vWinText) Controlclick($vWintitle,$vWinText,$vbut)EndFunc but this stops just like Chrisl idea Edited September 15, 2011 by GNGNUT Link to comment Share on other sites More sharing options...
water Posted September 15, 2011 Share Posted September 15, 2011 i have a simple script for work, when we need to create a button on our systems we get a lot of errors before we can choose the button we want to addI have re-read your first post. I fear I still don't get the point. Some questions to make it clearer:How do you create the button?On what systems do you create the button?What kind of errors do you get?Who raises the error (your application, an Autoit script ...)? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GNGNUT Posted September 15, 2011 Author Share Posted September 15, 2011 (edited) im using visula files and it is visual files that is kicking up the error. to creat a button / icon simple right click in the taskbar inside of visual files and select create icon < at this point is when the errors start, "Unable to set com-handle property. (5677)" "Error occurred while accessing component property/method: Add. Element not found Error code: 0x80020009 ADD-LISTVIEW-ITEM ficonadn.w (5890)" "Error occurred while accessing component property/method: Listitems. Element not found Error code: 0x80020009 ADD-COLUMN-ENTRY ficonadn.w (5890)" heres 3 errors taht pop up within the 366 i have at the moment Edited September 15, 2011 by GNGNUT Link to comment Share on other sites More sharing options...
ChrisL Posted September 15, 2011 Share Posted September 15, 2011 thank you for you feed back guys @ water. 2nd message. this script seems to run at the same speed as the one I wrote not sure if its the winwait part holding it up or the winactivate as it needs to do this each time. @chrisl. this speeds it up but if there is a small dely in the screen coming up it will end the script. have been playing with it func error() $vWintitle = "Error" $vwintext = "OK" $vbut = "[CLASS:Button; INSTANCE:1]" winActive($vWintitle, $vWinText) Controlclick($vWintitle,$vWinText,$vbut) EndFunc but this stops just like Chrisl idea Do what Water suggested and still put Opt("WinWaitDelay",1) at the top of the script as by default Autoit waits 250ms after every window action You might also want to concider using ControlFocus before ControlClick which can help if you still get things stoppping. ControlFocus($vWintitle,$vWinText,$vbut) Controlclick($vWintitle,$vWinText,$vbut) What happens after you click the button, does the window disappear? [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
GNGNUT Posted September 15, 2011 Author Share Posted September 15, 2011 yes soon as i click ok to error message the next one pops up and so on that has made the loop go a lot faster thanks guys for all your help script as iit stands :) Opt("WinWaitDelay",2) error(400) Func error($number) $vWintitle = "Error" $vWinText = "OK" $vbut = "[CLASS:Button; INSTANCE:1]" For $i = 1 To $number WinWait($vWintitle, $vWinText, 2) If Not WinActive($vWintitle, $vWinText) Then WinActivate($vWintitle, $vWinText) WinWaitActive($vWintitle, $vWinText, $timeout) ControlClick($vWintitle, $vWinText, $vbut) Controlfocus($vWintitle,$vWinText,$vbut) Next EndFunc ;==>error Link to comment Share on other sites More sharing options...
ChrisL Posted September 15, 2011 Share Posted September 15, 2011 You want the ControlFocus line before ControlClick [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire 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