Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#346503 - 19/07/2011 19:10 Spy++ like window text scraping... but from a batch file or VBS?
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Man, Google is really failing me here.

I'm looking for a way to screen-scrape the text off of the window of a running application. I want to get the same information you'd get by running "Spy++" and then drilling down into the various windows and controls of the application.

The trick is I want to do this programatically, from a script, such as a batch file or a VBScript file. All of the applications I've seen that have functionality similar to Spy++ are all GUI apps without a command-line equivalent. I don't know of a way to directly window-scrape from a batch file, and a VBScript won't let me call the GetWindowText API directly.

Searching for scraping utilities gets me a lot of links to software designed to scrape web pages. But it's an app I want to scrape, not a web page.

I could theoretically write this whole thing in C/++/# but I'm trying to do this as a plain-text script without needing a compiler or a development environment.

Any ideas?
_________________________
Tony Fabris

Top
#346505 - 19/07/2011 20:22 Re: Spy++ like window text scraping... but from a batch file or VBS? [Re: tfabris]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
Might be worth trying to do this in Powershell. That way you get the script you want, but with the .Net framework access that may get you what you need. Powershell 1.0 was shipped in Vista, and 2.0 with Windows 7. It can also be manually installed on XP.

Top
#346506 - 19/07/2011 21:04 Re: Spy++ like window text scraping... but from a batch file or VBS? [Re: drakino]
hybrid8
carpal tunnel

Registered: 12/11/2001
Posts: 7738
Loc: Toronto, CANADA
Are you familiar with AutoIt? It's a scripting language with control over windows and controls. You could possibly write your entire program in AutoIt, or simply write the necessary scraping bits and call them from your VBScript.

I haven't used it in over 5 years, so I can't say for sure it has what you need, but take a look: http://www.autoitscript.com/site/autoit/

I last used it to control three different GUI applications, each with multiple windows and controls like buttons, sliders, drop-down boxes and text fields.


Edited by hybrid8 (19/07/2011 21:05)
_________________________
Bruno
Twisted Melon : Fine Mac OS Software

Top
#346507 - 19/07/2011 21:45 Re: Spy++ like window text scraping... but from a batch file or VBS? [Re: hybrid8]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Heh. I was about to reply to Tom that I'd just solved my problem by writing the solution in AutoIt and compiling a tiny EXE from that.

smile

This solves my problem by not requiring a special installation of PowerShell onto my XP targets.
_________________________
Tony Fabris

Top
#346508 - 19/07/2011 22:44 Re: Spy++ like window text scraping... but from a batch file or VBS? [Re: tfabris]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
(Mostly for my future googling)

Hmm, nice. So AutoIt is similar to AppleScript in the Mac world. May have to look deeper into it if the need arises for such a thing.

Top
#346511 - 19/07/2011 23:43 Re: Spy++ like window text scraping... but from a batch file or VBS? [Re: drakino]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Yeah, AutoIt is pretty handy when trying to automate Windows things that have no UI but a GUI. Sometimes things aren't quite as straightforward as they would seem, though, like when someone writes a specialized control/widget and you have to resort to faking mouse interaction. And error checking becomes a really big part of your script.

Also, AutoIt is more akin to the Mac apps iKey and QuicKeys.
_________________________
Bitt Faulk

Top
#346513 - 20/07/2011 01:53 Re: Spy++ like window text scraping... but from a batch file or VBS? [Re: drakino]
hybrid8
carpal tunnel

Registered: 12/11/2001
Posts: 7738
Loc: Toronto, CANADA
Originally Posted By: drakino

Hmm, nice. So AutoIt is similar to AppleScript in the Mac world.


No, not really. AutoIt doesn't suck. wink

AppleScript is just about the worst "scripting" tool I've ever used in my life. At the core, it has ass-backwards and completely convoluted syntax.

If an app doesn't have AppleScript support baked in, you're out of luck. If you want to create your own GUI stuff, AppleScript is limited without add-ons.

AutoIt can control and manipulate pretty much any application in various ways, including through direct GUI manipulation if all else fails. It can also create a lot of GUI elements itself.

And if you have any experience with pretty much any other programming language, AutoIt is extremely straight forward.
_________________________
Bruno
Twisted Melon : Fine Mac OS Software

Top