Jump to content

Need some help....


LurchMan
 Share

Recommended Posts

Hey All -

I'm working on a project for work that requires me to have 2 scripts (essencially doing the same thing with slight differences), running on a single machine. Basically they are waiting for an event to happen, and I'm using ControlGetText to identify if a window exists. I need the 2 scripts to be able to differentiate between 2 windows that have the same Title, but different text in them. But the text is almost never the same in each instance. I would use PID's but since I'm only testing this on my machine for right now, and PID's aren't exactly the most reliable thing to use inbetween different work stations.

Example:

You have two sessions of notepad open, and you open the change font dialog box in one but not the other.

Just a couple questions:

How would I make it so that the script that is suppose to recognize it does, but the other does nothing, and keeps looping?

Do the handles that windows assigns different windows the same on different machines?

Is there a way to check Task name and not PID?

Up until this point my boss has given me the go ahead and continue with this project, but if I can't get this part to work correctly, I fear it may die, and my month of work will go down the crapper...

All help will be greatly appreciated!

Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

All of the Control* functions can use control parameters to specify the window.

ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID

TEXT - The text on a control, for example "&Next" on a button

CLASS - The internal control classname such as "Edit" or "Button"

INSTANCE - The 1-based instance when all given properties match

CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"

Link to comment
Share on other sites

Thanks for the reply -

I've been working with those throughout my scripts, but the 2 windows that im looking for won't always have the ID, or Text. Theres always 4 buttons on them that always say the same thing. When my 2 scripts are running simulatenously, and one window comes up, they both pick it up. I was wondering if theres a way so that only the one I want to catch it does, and the other one just continues like nothing happened.

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

I got a brilliant idea...

Run("Notepad.exe")
WinWait("Namnlös - Anteckningar")
WinSetTitle("Namnlös - Anteckningar", "", "MyNotepadWindow1")
WinWait("MyNotepadWindow1")

Run("Notepad.exe")
WinWait("Namnlös - Anteckningar")
WinSetTitle("Namnlös - Anteckningar", "", "MyNotepadWindow2")
WinWait("MyNotepadWindow2")

ControlSend("MyNotepadWindow1", "", "Edit1", "First window")
ControlSend("MyNotepadWindow2", "", "Edit1", "Second window")
Link to comment
Share on other sites

that would work if my scripts weren't waiting for the window to appear (sometimes it does sometimes it doesnt) its basically my giant looping error handling for a program outside of AutoIT

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

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...