Jump to content

Application Monitoring


Recommended Posts

I need to monitor a Windows forms application and trigger an action when the text in a field changes. Can anyone point me in the right direction on how to handle this?

My AutoIT script will be running in a loop and can poll every few seconds.

Link to comment
Share on other sites

Well, shooting blind here, but ControlGetText() on a loop might be a good place to start.

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

My last sentence may have been misleading. I would like to capture the "on text changed" event or something like that. Polling is not preferred method, but the AutoIT script would be running.

Link to comment
Share on other sites

If the issue is .NET Windows Forms control names, there is an advanced NAME spec for that, see "Controls" in the help file:

$sText = ControlSetText("[TITLE:My Window]", "", "[NAME:textBoxFolder]")

:(

Edit: Posted before seeing last by Capel. The trick is to identify the control class and exactly what notification messages it sends. Then you can try GuiOnEventMode and GuiCtrlSetOnEvent() with it, or use GuiRegisterMsg() to catch and handle the messages.

:lol:

Edit2: No, dummy, GuiOnEventMode is only for AutoIt controls! :mellow:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You might be in trouble then, I'm currently trying to automate ACT! but it's got non-standard controls and it's a royal pain in the patukis.

ACT!Posted Image

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

So if I use GuiRegisterMsg as in:

GUIRegisterMsg($WM_SETTEXT,"MyWM_COMMAND") I believe WM_SETTEXT is the message I'm looking for, but it does not seem to work.

Let's take something simple. Say I want my AutoIT script to monitor a change in the display of the Windows Calculator. The following code does not work.

$handle=WinActivate("Calculator","")

GUIRegisterMsg($WM_SETTEXT,"MyWM_COMMAND")

 while GUIGetMsg() <> -3
 WEnd

 func MyWM_COMMAND($handle,$Msg, $wParam, $lParam)
  ConsoleWrite("message recieved" & @CRLF)
 EndFunc

What am I missing?

Link to comment
Share on other sites

That's not what you want -- quoting MSDN:

An application sends a WM_SETTEXT message to set the text of a window.

Try EN_CHANGE and EN_UPDATE, but I'm not sure either is triggered by simply typing in the box.

If you search this forum for those, you'll find examples.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks PsaltyDS,

Let me confirm that I'm not chasing my tail. I have an AutoIT script running an AutoIT GUI. I want to monitor a 3rd party application (GoldMine) so that when the GoldMine user changes the current record, I do something with AutoIT. Another detail is that GoldMine is a MIDI application. When the user changes the current contact, the title of the MDI window changes. This change is what I want to monitor.

Is this possible with AutoIT? I read a post last night that led me to believe that it is not, so I want to confirm.

Link to comment
Share on other sites

If all you need to know is when the title changes, just get the handle of the window first, then check WinGetTitle($hWnd) in a loop for the change.

But if you want/need to get down to the message level, and the user is working in a standard Windows API Edit control, then you should be able to trap those messages.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I would prefer not to do polling. What I would like is to intercept the message so the AutoIT script is event driven by the 3rd party application. Here is what I'm doing:

$g=GUICreate("",200,200)
$bNameSearch = GUICtrlCreateButton("Change Title",50,50,100,25)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND,"MyWM_COMMAND")

$handle=WinActivate("FrontRange","")

While GUIGetMsg() <> -3
WEnd

 func MyWM_COMMAND($handle,$Msg, $wParam, $lParam)
  ConsoleWrite("message received" & @CRLF)
 EndFunc

The problem is that I receive the message when I click the button. That is not what I want. I want to receive the message when the user changes the record. What I do know is that the MDI sub window is a control. I'm still off base here, any ideas?

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