nercon Posted June 17, 2014 Share Posted June 17, 2014 I am trying to create a script that automates a task. The way it works when run manually is you double click an option and then it runs and you have to answer 3 questions (yes or no) and that's it. We have some other scripts that have been created and I have been using them as a guide. It seems that they use the Windows Title to "call" the correct program (same as what happens when you manually double click the option). The problem is that when I use the AutoIt Windows Info tool when I run it manually is that the first window has no title. So I am not sure what to put in the script in order to "call" the correct program. I do see a handle, but apparently that changes each time it runs? I hope this all makes sense. Thanks in advance for any help. Link to comment Share on other sites More sharing options...
JohnOne Posted June 17, 2014 Share Posted June 17, 2014 Post whole summary tab of window info tool. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted June 17, 2014 Share Posted June 17, 2014 Along with any code you tried. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nercon Posted June 17, 2014 Author Share Posted June 17, 2014 Here is the window info tool:>>>> Window <<<<Title:Class: Synergy ContainerPosition: 77, 48Size: 1527, 954Style: 0x1ECF0000ExStyle: 0x00000100Handle: 0x0000000000640484>>>> Control <<<<Class: Synergy MainInstance: 1ClassnameNN: Synergy Main1Name:Advanced (Class): [CLASS:Synergy Main; INSTANCE:1]ID: 1Text:Position: 0, 42Size: 1519, 821I have not tried any code yet because I do not know how to call this first window. I believe it is calling it by the $MainTitle listed below.Here is code from a working script for another process:#include "TCM.au3"Tcm()Local $MainTitle = "SF Post Activity to Interfaces"Local $SynWindowTitle = " SF Post to Interfaces Selection Criteria "Local $RecoverTitle = "Recover"Local $PrintOnlyErrors = P("PrintOnlyErrors")Local $IncludeJobNotFound = P("IncludeJobNotFound")Local $QueryTitle = "Query"Local $retWindow = ""Local $retWindowInter = ""Local $TcmPrintTitle = "TCM Print"Local $CriteriaEntered = FalseLocal $processId = EnvGet("TcmScriptModuleProcessId")While ProcessExists($processId) And $processId <> 0TcmWriteDebugLog("started")Sleep($TcmWaitInterval)$retWindow = TcmWaitWindowsInfinite($QueryTitle, $TcmPrintTitle, $RecoverTitle)Switch $retWindowCase $QueryTitleTcmWriteDebugLog("Q!")B(6, "Yes", $QueryTitle)ContinueLoopCase $TcmPrintTitleTcmWriteDebugLog("P!")TcmSetupPrinter()ContinueLoopCase $RecoverTitleTcmWriteDebugLog("R!")B(2, "OK", $RecoverTitle)ContinueLoopCase ElseTcmWriteDebugLog("Else!")Sleep($TcmWaitInterval)If GuessTcmError($QueryTitle, $MainTitle, $TcmPrintTitle, $RecoverTitle) == True ThenTcmExit(-7)EndIfEndSwitchIf $CriteriaEntered == False ThenIf ProcessExists($processId) And $processId <> 0 And TcmWaitSynWindow($SynWindowTitle) ThenInputSearchCriteria()$CriteriaEntered = TrueEndIfEndIfWEndFunc InputSearchCriteria()$TcmWindow = $MainTitleW()If Not TcmWaitSynWindow($SynWindowTitle) ThenTcmExit(-6)EndIfIf $PrintOnlyErrors == "False" ThenSynOptionSelect(10)W()EndIfIf $IncludeJobNotFound == "False" ThenSynOptionSelect(9)W()EndIfW()B(300, "OK")EndFunc Link to comment Share on other sites More sharing options...
JohnOne Posted June 17, 2014 Share Posted June 17, 2014 You might get a handle to the window like so... $hwnd = WinGetHandle("[CLASS:Synergy Container]") AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted June 17, 2014 Share Posted June 17, 2014 Please enclose your code in AutoIt code tags (the blue "A" icon in the editor). That greatly enhances readability. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
nercon Posted June 17, 2014 Author Share Posted June 17, 2014 You might get a handle to the window like so... $hwnd = WinGetHandle("[CLASS:Synergy Container]") Thank you for the help. The problem I am having is that I think I need to identify the window so that I can pass the info to the main script so it knows which program to call. Here is another example, #include "TCM.au3" ;EnvSet("TcmScriptId", "1") ;EnvSet("TcmScriptArg", "1") ;EnvSet("TcmScriptArg1", "Year:2006") Tcm() Dim $MainTitle = "MRP - Material Requirements Report" $TcmWindow = $MainTitle W() BSyn($SynBtnOK, $MainTitle, "MR Period Dates") W() B(300, "OK") TcmSetupPrinter() $TcmWindow = $MainTitle W() BC($SynBtnCancel) I think I need the title so that it knows which "$TcmWindow" to use. Link to comment Share on other sites More sharing options...
JohnOne Posted June 17, 2014 Share Posted June 17, 2014 That code will identify the window. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nercon Posted June 17, 2014 Author Share Posted June 17, 2014 That code will identify the window. The script is going to be scheduled to run. So when the script starts there will be no window to identify. The script has to start the process. The main menu will be the only thing that is open at the time the script runs. I believe this is what tells the program what to select from the main menu: 9.Dim $MainTitle = "MRP - Material Requirements Report" 10. 11.$TcmWindow = $MainTitle But I don't have anything to set $MainTitle equal to. Link to comment Share on other sites More sharing options...
JohnOne Posted June 17, 2014 Share Posted June 17, 2014 Yes, so alter the code to identify the window by class. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
dilipped Posted June 18, 2014 Share Posted June 18, 2014 Hi. Actually I started recently with Autoit and though I am comfortable with autoit I struggle a lot with coding using UIAutomation components. It would be helpful if someone can show me a roadmap on how to start learning using UIAutomation components with AutoIt. Some good tutorials or link to some resources would be helpful. Link to comment Share on other sites More sharing options...
Wombat Posted June 19, 2014 Share Posted June 19, 2014 (edited) Hi. Actually I started recently with Autoit and though I am comfortable with autoit I struggle a lot with coding using UIAutomation components. It would be helpful if someone can show me a roadmap on how to start learning using UIAutomation components with AutoIt. Some good tutorials or link to some resources would be helpful. I began by looking for tutorials and whatnot, but alas the best thing to do is learn how to use google + this forum and just search for what it is you are wanting to do. 9 times out of 10 it's been done before (maybe differently than you are approaching it) and all you need to do is ask the right question to get the right answer. Coding and life in general can be surmised by this statement: You get out of it what you put in to it. So if you're not getting what you want out of it you are not inputting the required content. Computers are at this time re-active, they do what you tell them to or what others have told them to do. So if you are having trouble finding what you're looking for on the forum, maybe change how you are looking for it. Also, remember search engines run on databases and are best utilized with keywords not entire sentences. You limit your results when using complete sentences. If you are looking for examples check here and look through and see how they are doing theirs: http://www.autoitscript.com/forum/forum/9-example-scripts/ If you want to get an idea of how you can start, 1 way at least, then open SciTE and go to Tools>Koda(form designer) and play around with it, once you have a gui you like press generate form code and look at how the code behind the form you just made is laid out. This is how I got started. good luck Edited June 19, 2014 by Wombat dilipped 1 Just look at us.Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner The internet is our one and only hope at a truly free world, do not let them take it from us... 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