How to Scrape Tables from a Windows App
How to Scrape Tables from a Windows App
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 (373.61 KiB) Viewed 1130 times
Re: How to Scrape Tables from a Windows App
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.
Re: How to Scrape Tables from a Windows App
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!
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!
Who is online
Users browsing this forum: Google [Bot], imstupidpleshelp and 168 guests