Jump to content

Newbie Question


Recommended Posts

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

Here is the window info tool:

>>>> Window <<<<

Title:

Class: Synergy Container

Position: 77, 48

Size: 1527, 954

Style: 0x1ECF0000

ExStyle: 0x00000100

Handle: 0x0000000000640484

>>>> Control <<<<

Class: Synergy Main

Instance: 1

ClassnameNN: Synergy Main1

Name:

Advanced (Class): [CLASS:Synergy Main; INSTANCE:1]

ID: 1

Text:

Position: 0, 42

Size: 1519, 821

I 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 = False

Local $processId = EnvGet("TcmScriptModuleProcessId")

While ProcessExists($processId) And $processId <> 0

TcmWriteDebugLog("started")

Sleep($TcmWaitInterval)

$retWindow = TcmWaitWindowsInfinite($QueryTitle, $TcmPrintTitle, $RecoverTitle)

Switch $retWindow

Case $QueryTitle

TcmWriteDebugLog("Q!")

B(6, "Yes", $QueryTitle)

ContinueLoop

Case $TcmPrintTitle

TcmWriteDebugLog("P!")

TcmSetupPrinter()

ContinueLoop

Case $RecoverTitle

TcmWriteDebugLog("R!")

B(2, "OK", $RecoverTitle)

ContinueLoop

Case Else

TcmWriteDebugLog("Else!")

Sleep($TcmWaitInterval)

If GuessTcmError($QueryTitle, $MainTitle, $TcmPrintTitle, $RecoverTitle) == True Then

TcmExit(-7)

EndIf

EndSwitch

If $CriteriaEntered == False Then

If ProcessExists($processId) And $processId <> 0 And TcmWaitSynWindow($SynWindowTitle) Then

InputSearchCriteria()

$CriteriaEntered = True

EndIf

EndIf

WEnd

Func InputSearchCriteria()

$TcmWindow = $MainTitle

W()

If Not TcmWaitSynWindow($SynWindowTitle) Then

TcmExit(-6)

EndIf

If $PrintOnlyErrors == "False" Then

SynOptionSelect(10)

W()

EndIf

If $IncludeJobNotFound == "False" Then

SynOptionSelect(9)

W()

EndIf

W()

B(300, "OK")

EndFunc

Link to comment
Share on other sites

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

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

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

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

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 by Wombat

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...