Sign in to follow this  
Followers 0
Xander

Pulling hidden text from a window

6 posts in this topic

#1 ·  Posted (edited)

I want to set up a monitor program that keeps an eye on a few things. One that I have in mind would be to have my Outlook reminders' info copied into my Messenger 'personal text' frame.

Below is the information that comes from my Reminder window itself. What I'm unsure of how to do, specifically, is to isolate the text that is in bold. So, search for "Location" and clip the part after it (with ClipPut($address) ). I should be able to handle the rest.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Service Call

Start time: Thursday, May 12, 2005 1:00 PM

Location: 123 Main St. 555-1212

&Meeting Services

If you're wondering, as I make service calls, the purpose would be to have my computer keep my friends alert to my last whereabouts. And, partly, to see if it can be done :(

Edited by Xander

Share this post


Link to post
Share on other sites



check out these in help file:

Opt("WinDetectHiddenText", 1) ;0=don't detect, 1=do detect

WinGetText

--------------------------------------------------------------------------------

Retrieves the text from a window.

WinGetText ( "title" [, "text"] )

after that is is just a mater of parsing the info


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Well, here's what I have so far.

Global $text
Opt("WinDetectHiddenText", 1);0=don't detect, 1=do detect
Do
    Until WinExists("1 Reminder","&Open Item")
WinWait( "1 Reminder")
WinActivate ( "1 Reminder")
$text = WinGetText("1 Reminder", "")
$left = StringInStr($text, "Location:") + 9
$text = StringTrimLeft($text, $left)
$right = StringInStr($text, "Dismiss")
$address = StringTrimRight($text,stringlen($text)-$right+2)
ClipPut($address)
WinActivate ( "MSN Messenger")
Send("!to{TAB}");nav to Options and Personal msg
Send("SC - " & $address & "{enter}")
Exit

Had some trouble getting it to work. Without the Do/Until, it seems convinced that the window is still present, even after it having been run. Now, I just need to work out a "Stay in the background and loop until another reminder comes up"

Suggestions on best way to do that without hogging CPU time?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well, here's what I have so far. 

Had some trouble getting it to work.  Without the Do/Until, it seems convinced that the window is still present, even after it having been run.  Now, I just need to work out a "Stay in the background and loop until another reminder comes up"

Suggestions on best way to do that without hogging CPU time?

<{POST_SNAPBACK}>

Yeah, put a Sleep(10) in your loop. :( Believe it or not, a 10ms wait time actually keeps it from being a tick hog.

So...change your idle loop to

Do
   Sleep(10)
Until <condition>

And do the whole thing until another one pops up?

Global $text
Opt("WinDetectHiddenText", 1);0=don't detect, 1=do detect
HotKeySet("{ESC}","MyExit")
While 1
   Sleep(10)
   Do
      Sleep(10)
   Until WinExists("1 Reminder","&Open Item")
   WinWait( "1 Reminder")
   WinActivate ( "1 Reminder")
   $text = WinGetText("1 Reminder", "")
   $left = StringInStr($text, "Location:") + 9
   $text = StringTrimLeft($text, $left)
   $right = StringInStr($text, "Dismiss")
   $address = StringTrimRight($text,stringlen($text)-$right+2)
   ClipPut($address)
   WinActivate ( "MSN Messenger")
   Send("!to{TAB}");nav to Options and Personal msg
   Send("SC - " & $address & "{enter}")
WEnd

Exit

Func MyExit()
   Exit
EndFunc
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Good, Blue_Drache!

Remember how I mentioned that it thinks there is some kind of 'phantom' window still around, even if the reminder has been closed? Because of that, the While/WEnd option doesn't work - it just keeps looping and re-sending to the window.

However, if I start the program, a reminder comes up, it does its job, closes the reminder, and exits and then I run the program again, it's fine. It no longer sees the 'phantom.' This causes me to wonder if the script isn't retaining some kind of value from the WinExists that, if I can identify it and clear/reset that value, it should be fine to run in a loop.

Even if I try changing WinClose to WinKill, it still thinks it exists:

While 1
Do
Sleep(1000)
    Until WinExists("1 Reminder","&Dismiss")
    Opt("WinDetectHiddenText", 1);0=don't detect, 1=do detect
    WinWait( "1 Reminder")
    WinActivate ( "1 Reminder")
    $text = WinGetText("1 Reminder", "")
;parse out the "location" part of the reminder window
    $left = StringInStr($text, "Location:") + 9
    $text = StringTrimLeft($text, $left)
    $right = StringInStr($text, "Dismiss")
    $address = StringTrimRight($text,stringlen($text)-$right+2) 
    WinActivate ( "MSN Messenger")
    Send("!to{TAB}");nav to Options and Personal msg
    Send($address & "{enter}")
    WinKill("1 Reminder","")
    msgbox(1,"5=Exists+Enabled",Wingetstate("1 Reminder"));<-- gives a "5"
    WEnd
    Exit

The Sleep does make a huge difference. I've even got it checking only every minute for even less drain. I wonder what makes the difference CPU-wise between a tight, do-nothing loop and a Sleep statement? To my brain, they'd be the same but I won't argue. If I can get things working as a loop, this will be a big help.

My best thought right now is to set it up as a scheduled task every minute or two and have it check and close.

OH - is there any way to lock out the keyboard -while- the Send is taking place? This way, if I'm at the keys when a reminder comes up then I won't be interferring.

Edited by Xander

Share this post


Link to post
Share on other sites

Here's how I've made it work!

Sleep(3000); <-- pause to give last version time to close
Opt("WinTitleMatchMode",2)
$g_szVersion = "My Script 1.1"
If WinExists($g_szVersion) Then Exit; <--make sure only one running
.
. ;<--no changes, except does not use the While/WEnd loop; just Do/Until
.
run("reminder.exe") ;<-- runs itself again which clears the "WinExists" flag
Exit

Working like a charm.

Share this post


Link to post
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
Sign in to follow this  
Followers 0