Jump to content

Listener for external controls


bigred
 Share

Recommended Posts

Does AutoIt have the ability to listen or monitor the OnEvent stuff of another app? Specifically I need to monitor an edit field for new lines fo text, and then "Do" code. I want to use an OnEvent handler because new lines of text can be added quite rapidly to the edit field. So I think using something like a timer that initiates a "GetLineCount" along with the extra code for determining if there has been a new line would cause problems since it would have to fire quite often. Also there are other complications that make that option probably unfeasible.

Edited by bigred
Link to comment
Share on other sites

to monitor and react when a string is found...

While 1
  Sleep(1)
  $n = ControlCommand("title","","Edit5","GetLineCount", "")
  $szBuff = ControlCommand("title","","Edit5","GetLine", $n)
  If StringInStr($szBuff,"Some String To Wait For") Then Break
Wend
MsgBox(4096,"","Text Found")

<{POST_SNAPBACK}>

Larry, you rock. I'm going to use this. I have just the place :ph34r:

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Problem is I'm not waiting for a particular string. I'm mainly waiting for any new string entered into the box. Most of the strings will be unique, but some will be identical.

Another thing is that I would have to cycle this code every 500, or 1000 ms since I need the code to react to some strings within that duration. Would there be a problem doing this code that frequently, along with code that writes the string to a text file, and parses out text that could trigger a bunch of ControlSetText commands, among other things. Also the other program this code is interfacing with needs a lot of system resources, and stable resources usage.

Also I plan on using this code in VB6 with AIX once I get the prototype working. Not sure if that changes things..?

Edited by bigred
Link to comment
Share on other sites

Problem is I'm not waiting for a particular string.  I'm mainly waiting for any new string entered into the box.  Most of the strings will be unique, but some will be identical.

Another thing is that I would have to cycle this code every 500, or 1000 ms since I need the code to react to some strings within that duration.  Would there be a problem doing this code that frequently, along with code that writes the string to a text file, and parses out text that could trigger a bunch of ControlSetText commands, among other things.

Also I plan on using this code in VB6 with AIX once I get the prototype working.  Not sure if that changes things..?

<{POST_SNAPBACK}>

so, have it act on changes, get the current string, then check it again, if it's different, then you do something.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Yes I understand it fully, and its a great solution, I just have some concerns.

What I'm wondering is, is it safe to do this check a bunch of times per second, say as often as every 50ms or even 10ms..? And there will not be any significant impact on system resources?

I need it to fire that often because if this is the only way for me to track and check new strings, I have to make sure it doesn't miss one.

Also this code "$n = ControlCommand("title","","Edit5","GetLineCount", "")" is not suitable to tell me if there is a new line since the text box dumps some of its content from time to time. It gets to 251 lines, and then trunkates to 64 lines.

Link to comment
Share on other sites

Yeah I guess I'll have to test it to know for sure. My concern is that the connected users may see some "hickups".

So since I'm not looking for one specific line, and the number of lines in the field do not increment normally, I guess the only method is to "GetLineCount" and do a string compare as often as performance will allow, hoping that I do not miss a line in the process.

Hmm, another idea would be to just use "GetLineCount" but to create some logic to handle the line truncation. If the program is already checking the line count that often, perhaps I can leave out the string checks. Maybe that would help if there would be any performance problems.

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