Page 1 of 1

Scan info from screen

Posted: Fri Jun 17, 2016 7:26 am
by Victorio
This is not just Xbase problem, but I want know, if is possible read info from screen ?

I have some utility (i mean in C,C++) ,that have user window, and on this is some info. Utility do not generate any report.
I need use this info for my application.

Reading info pixel by pixel wil be very complicated, also do not know, where will be windows positioning.

Good way will be run this utility but redirect output not to screen, but to file, where will be easyer analyze it.

Re: Scan info from screen

Posted: Fri Jun 17, 2016 8:04 am
by rdonnay

Code: Select all

oWindow := AppDeskTop()
oScreenDump := GraSaveScreen( oWindow, {0,0}, o:Window:currentSize() )
oScreenDump:saveFile( 'screendump.jpg', XBPBMP_FORMAT_JPG )

Re: Scan info from screen

Posted: Fri Jun 17, 2016 12:15 pm
by Victorio
Thank you Roger !

I must try it. So analyzing image will be more complicated because screen resolution...
if no other option I must work on it.

Re: Scan info from screen

Posted: Fri Jun 17, 2016 6:19 pm
by Cliff Wiernik
I use a similar technique in my program, using the code from the 1.9 documents. You it to print out the current window, not necessarily the application window, to a printer. I could just as easy save to a file. It does not require any special considerations for screen resolution. I did not compare my code to Roger's example, but it looks similar.

Re: Scan info from screen

Posted: Fri Jun 17, 2016 7:01 pm
by Auge_Ohr
Victorio wrote:This is not just Xbase problem, but I want know, if is possible read info from screen ?
depends on Windows Control / Part if you get Result with WM_GETTEXT
https://msdn.microsoft.com/en-us/librar ... s.85).aspx

first you need Handle of Windows , next Handle of Control inside ( e.g. "edit" = SLE )

Code: Select all

LOCAL nTextLen:=512
LOCAL Buffer:=Space(nTextLen)+Chr(0)
LOCAL nWin
LOCAL nHandle 
LOCAL nDLL := DllLoad("User32.dll")

  // API "FindWindowA" ( Dialog - Titlebar )
  nWin:= DllCall(nDLL, DLL_STDCALL, "FindWindowA", "#32770"+ Chr(0), "FRITZ!fax - send by Xbase++" + Chr(0))

  // API "FindWindowExA" ( Edit-Control inside )
  nHandle := DllCall(nDLL, DLL_STDCALL, "FindWindowExA", nWin, 0,"edit"+Chr(0),nil)

  // "read" from Edit-Control 
  DllCall(nDll,DLL_STDCALL,"SendMessageA", nHandle, WM_GETTEXT, nTextLen, @Buffer)
  // "write" to Edit Control
  DllCall(nDll,DLL_STDCALL,"SendMessageA", nHandle, WM_SETTEXT, LEN(cFaxNo),cFaxNo )
i use WinID.EXE to find those Information about a Control
http://www.dennisbabkin.com/winid/