Retrieve value from a textbox on a window and expose via HTTP

If you have a question or need help, this is the place to be.
Post Reply
hagur
Posts: 4
Joined: Thu Oct 22, 2009 10:31 am

Retrieve value from a textbox on a window and expose via HTTP

Post by hagur » Wed Sep 19, 2018 6:16 pm

Hi,

I've got a program which I want to extract a value from and expose via HTTP. The webserver plugin in EG can be used to trigger actions in EG but can it be used to retrieve data? What I'm trying to do is essentially this:

1. Locate a specific GUI control on a specific window (Using the FindWindow action)
2. Fetch the value of that GUI control (Using Grab text ? )
3. Be able to extract the value via an HTTP call (Using the webserver plugin ?)

Can this be accomplished with EG ?

User avatar
yokel22
Experienced User
Posts: 256
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Retrieve value from a textbox on a window and expose via HTTP

Post by yokel22 » Wed Sep 19, 2018 9:52 pm

Only if the webserver plugin is hosting the page you'd like to retrieve the value from. If it's not, you can scrape and parse the value out using python "urllib, requests, re". If you'd like an example of the latter, I can post one for ya.

User avatar
kgschlosser
Site Admin
Posts: 4313
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Retrieve value from a textbox on a window and expose via HTTP

Post by kgschlosser » Wed Sep 19, 2018 10:03 pm

If you are trying to capture anything from a browser window. the answer is. Not at the present moment. I know there is someone that is working on making a browser plugin that will allow something like this to be done.

The reason why you cannot grab from a browser window. is because the GUI in a browser does not use the built in windows controls. everything is custom drawn. so there is no API to locate these elements in the traditional manner. some king of a plugin need to be made on the browser end of things that would expose these elements so EventGhost would then have the ability to do whatever it is that needs to be done.


Now if you are grabbing the text from a Window that uses the standard Windows widgets/tools then the answer would be yes.
The Find Window action is not named to Find A Window so you can locate an application. tho this is usually what it is used for..
it is named as such for Find a Window Class based widget/tool. You will ne to locate the exact control/widget/tool that is going to have the text you want to grab. then using the grab text should work if it is a Text Control or the like. you have a 50/50 shot of it working on things like combo boxes or drop downs. menu items. things of that nature.

Now when you state using the webserver plugin to retreive data... You will need to elaborate on this some. Is it a simple webpage the data resides on??. or is it something where you have to send a REST or a SOAP request to in order to query the server to get the data?? Or is is a websocket server and you need to send a request over the websochet to retreive the data?

The webserver plugin is really designed as a web "server" so by nature it is going to want to serve and not be a client (for most things) so depending on what kind of a request you are making is what is going to determine what we need to do.
If you like the work I have been doing then feel free to Image

hagur
Posts: 4
Joined: Thu Oct 22, 2009 10:31 am

Re: Retrieve value from a textbox on a window and expose via HTTP

Post by hagur » Wed Sep 19, 2018 10:48 pm

Yeah, the window I'm trying to capture from is just a regular Win32 app.

The scenario is this:

I have a special program running which reads data from a connected device and displays it on screen. I'd like to be able to retrieve that data and use it in my own custom application, preferably VIA an HTTP call. That's why I figured I might be able to use EG for this, since I knew it already had functionality to "find" windows and retrieve data from them. Then I was hoping I could somehow leverage the Webserver plugin to request that data from EG via HTTP.

If the webserver plugin is only able to raise events in EG (not get data back from EG) then I guess I'm out of luck ....

Regards,
Hagur

User avatar
kgschlosser
Site Admin
Posts: 4313
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Retrieve value from a textbox on a window and expose via HTTP

Post by kgschlosser » Wed Sep 19, 2018 10:52 pm

Your first description led me to think that you wanted to pass the data to some form of an HTTP server. Not that you wanted to "host" the data for another machine to retrieve from EG. since the latter is the case then it is done using the webserver plugin.

The webserver plugin is not something i am well educated in it's use. Maybe yokel22 can help ya out on that end of things.
If you like the work I have been doing then feel free to Image

User avatar
yokel22
Experienced User
Posts: 256
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Retrieve value from a textbox on a window and expose via HTTP

Post by yokel22 » Thu Sep 20, 2018 4:22 pm

This is possible. I'll post an example when I get in front of a pc here.

**edit**

Ran into a bit of a problem getting it to return from a http request. Didn't have much time last night to see what was going on. Should have it worked out here shortly.

**edit**

User avatar
yokel22
Experienced User
Posts: 256
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Retrieve value from a textbox on a window and expose via HTTP

Post by yokel22 » Wed Sep 26, 2018 11:22 pm

Sorry, i got busy for a while & didn't have a chance to set this up until today. I tried this a few different ways. This was the simplest that worked. You can do this via ajax & json responses, but it's really an unnecessary complication. This example uses the webserver plugin to store variables persistently. Then writes those variables to a text file hosted by the webserver plugin. You can use the request python script from any device(just change the ip & port set at the top of the script).

I just added this to the Webserver Demo. You'll want to extract the folder somewhere on pc. Then within the webserver configuration point the html folder to the location you extracted the zip to. This also utilizes the file operations plugin, you'll need to install it if you don't already have it on your system. viewtopic.php?f=9&t=1011&hilit=file+operations After that the macro's within the "Retrieve web variables" folder should work. You can add as many variables as you like by setting up more actions for setting/getting Webserver plugin variables. If you start going crazy with variables, it may be easier to store/parse them as a python dict.
Attachments
WS - Demoshort.zip
(1.2 MiB) Downloaded 3 times
EG.WS.demoshort.xml
(23.12 KiB) Downloaded 6 times

Post Reply