How to Scrape Tables from a Windows App

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
a_script
Posts: 2
Joined: 08 Sep 2018, 16:33

How to Scrape Tables from a Windows App

07 Dec 2018, 19:09

Hello, I have been trying to scrape these tables from a Windows application ... with much frustration so far lol. May I ask, what am I doing wrong? Help would be so much appreciated. Thank you.
Attachments
Screen Cap of AHK Code.png
Screen Cap of AHK Code.png (373.61 KiB) Viewed 1132 times
User avatar
Frosti
Posts: 426
Joined: 27 Oct 2017, 14:30
Contact:

Re: How to Scrape Tables from a Windows App

09 Dec 2018, 05:12

I think you need WinSpy to get more informations from controls inside these windows. But better use ACCViewer to look for the window tree. Or try to read from elementhost1 - is shown as text in WindowSpy in your screenshot.
a_script
Posts: 2
Joined: 08 Sep 2018, 16:33

Re: How to Scrape Tables from a Windows App

10 Dec 2018, 22:36

Thank you very much for replying, Frosti, as I've made some headway following your suggestion. Here are some screencaps which reveal the table column/row values I'm trying to scrape to a .csv file, which I've included in the screencaps as the equivalent output I'm trying to achieve. I noticed that the "Paths" printout at the bottom of ACCViewer follow in the format of row.column, where (1.1, 2.2, etc.) are (1st row, 1st column; 2nd row, 2nd column, respectively), which include the columns/headers counting from index 1 in this "Paths" printout. However, the rows (excluding the columns) do begin at index 0 as you can see (e.g. "Name: Symbol Row 0"). Also, the image focused on the whole table ("Name: DataGridView", "Role: table") reveals the total number of rows cells I need to iterate over ("ChildCount: 171") + 1 to include the column headers.

The example .csv file is saved by selecting "Save Content..." in the context menu of every window, by the way; and I currently have a really clunky PyAutoGUI script that right-clicks thru the x,y coordinates of every window and selects to save the contents via simple raw keyboard inputs. However, this breaks in certain circumstances and is really clunky and "blind" as to what it's even doing and not to mention is a very slow process. I think that using AHK for this instead would be a bit faster and more stable by selecting the window titles and context menu elements explicitly, but I doubt it'd be enough of an edge to warrant re-writing the script to save the tables in AHK instead of Python. So I'm thinking that scraping the values directly at the lowest level possible would be the fastest and best way to replace this script to save all these tables because I need to do intraday analysis of them and so need to be able to "refresh" very quickly rather than wait the 2-3 mins to run thru my current keyboard macro to save them all (while more alerts come thru in the meantime, thus possibly skewing the data a bit).

So again, just to clarify, I'm looking to scrape and save to .csv files which are identical to the ones saved by the program in the example .csv file output format I included, so I'm just using that MsgBox as a test placeholder just to see if i can manage to scrape the first few rows including the column headers.

Thanks again, Frosti, much appreciated!
2018-12-10 16_46_21-Window.png
2018-12-10 16_46_21-Window.png (307.55 KiB) Viewed 1049 times
2018-12-10 16_48_12-Window.png
2018-12-10 16_48_12-Window.png (307.76 KiB) Viewed 1049 times
2018-12-10 18_18_42-Window.png
2018-12-10 18_18_42-Window.png (292.87 KiB) Viewed 1049 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Dobbythenerd1 and 329 guests