473,500 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capturing/Recognizing Text In Another Window

Hello, everyone,

I'd like to write a Python program that could capture the contents of
another Windows program and analyze the resultant bitmap. First, I have no
idea how to capture another window. Second, I'm not even certain if this
graphical problem is a Python issue or a Windows issue.

Can anyone offer me some guidance on this?

Thanks,
Scott

--
Remove ".nospam" from the user ID in my e-mail to reply via e-mail.
Jul 18 '05 #1
7 3231
"Scott Brady Drummonds" <sc**********************@intel.com> wrote:

I'd like to write a Python program that could capture the contents of
another Windows program and analyze the resultant bitmap. First, I have no
idea how to capture another window. Second, I'm not even certain if this
graphical problem is a Python issue or a Windows issue.

Can anyone offer me some guidance on this?


If the thing you are trying to read is a text control, such as what Notepad
presents, you don't have to analyze a bitmap: you can fetch the text as a
string. You'll have to use the Windows API to do it, so you'll want to
read up on the win32gui and win32ui modules.

First, use a tool like spyxx to examine the app you want to scrape. Find
the ID of the control you want.

Now, fromm Python, you can use FindWindow or EnumWindows to find the
top-level app you want to manipulate. Then, you can use GetDlgItem to
fetch the window handle of the control with your desired ID. Then, use
win32gui.GetWindowText to fetch the text inside it.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #2
JD
I too am interested in this if anyone can shed some light. If I am
understanding Scott's question, he is not refering to text that can be
captured by GetWindowText or equivalent. For example, if the other
program was a checkers game, how might one capture the screen so as to
know where the checker pieces are?
"Scott Brady Drummonds" <sc**********************@intel.com> wrote in message news:<bl**********@news01.intel.com>...
Hello, everyone,

I'd like to write a Python program that could capture the contents of
another Windows program and analyze the resultant bitmap. First, I have no
idea how to capture another window. Second, I'm not even certain if this
graphical problem is a Python issue or a Windows issue.

Can anyone offer me some guidance on this?

Thanks,
Scott

Jul 18 '05 #3
Hello Scott,
I'd like to write a Python program that could capture the contents of
another Windows program and analyze the resultant bitmap. First, I have no
idea how to capture another window. Second, I'm not even certain if this
graphical problem is a Python issue or a Windows issue.

Can anyone offer me some guidance on this?


I'd use an automation program such as AutoIt
(http://www.hiddensoft.com/AutoIt)
to capture the scree usign ALT+PRTSC (there is an example in the help
on how to do this). Then use MS Paint or whatever to save the image to
the disc from the clipboard.

From there on you can open the bitmap and do whatever you want (try
PIL).

HTH.
Miki
Jul 18 '05 #4
On 15 Oct 2003 22:37:23 -0700, je*********@yahoo.com (JD) wrote:
To answer my own question for the benefit of others who are
interested, do it like this:

import win32gui
import win32ui

DC = win32ui.GetActiveWindow().GetDC()
MemDC = DC.CreateCompatibleDC( None )
BitMap = win32ui.CreateBitmap()
BitMap.CreateCompatibleBitmap(DC, 400, 400)
MemDC.SelectObject( BitMap )
MemDC.BitBlt((0,0), (400, 400), DC, (0,0), 13369376)
BitMap.SaveBitmapFile(MemDC, "c:\mybitmap.bmp")


Just wondering what the BitBlt is doing with
hex(13369376)

'0xcc0020'

Regards,
Bengt Richter
Jul 18 '05 #5
> >MemDC.BitBlt((0,0), (400, 400), DC, (0,0), 13369376)
Just wondering what the BitBlt is doing with
>>> hex(13369376)

'0xcc0020'


You can do a Google search on either the decimal or hex number to find out.
But I'll tell you anyway... :-)

BitBlt is a multipurpose function that takes a ROP (Raster OPeration) code
that controls exactly what it does. 0xCC0020 is the ROP code SRCCOPY, i.e.
do a simple copy from the source to the destination.

-Mike
Jul 18 '05 #6
On Thu, 16 Oct 2003 15:48:02 -0700, "Michael Geary" <Mi**@DeleteThis.Geary.com> wrote:
>MemDC.BitBlt((0,0), (400, 400), DC, (0,0), 13369376)

Just wondering what the BitBlt is doing with
>>> hex(13369376)

'0xcc0020'


You can do a Google search on either the decimal or hex number to find out.
But I'll tell you anyway... :-)

BitBlt is a multipurpose function that takes a ROP (Raster OPeration) code
that controls exactly what it does. 0xCC0020 is the ROP code SRCCOPY, i.e.
do a simple copy from the source to the destination.

D'oh. I knew that. I need to sleep better...

Regards,
Bengt Richter
Jul 18 '05 #7
Hi !

I obtain a traceback in line 4 : "win32ui : No windows is active." ???

@-salutations
--
Michel Claveau
Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2044
by: ebobnar | last post by:
I'm sure you all have seen how using the src argument in a script tag is essentially the same as including the body of the script within your page. For example: <script type="text/javascript"...
1
5348
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
3
4669
by: Vikram Bhatia | last post by:
1. Is there an event to capture scrolling using mouse wheel in Netscape 6.x? 2. When arrow keys are used to scroll a page in Netscape 6.x, the scrolling offsets obtained using...
7
20356
by: jerrygarciuh | last post by:
Hello, I have been playing with various Googled solutions for capturing the <Enter> key to suppress form submission. My first question is whether anyone has a script that works in all common...
15
1994
by: Larry Asher | last post by:
Hi all. I'm a bit of a novice in this arena so please forgive if this question reflects that. I am trying to grab the html from a website and display it within another webpage (once I get this to...
10
1649
by: CMG | last post by:
There is a program called ShortKey, the basic function of this program is the following: Say you define a shortkey called "MSDN". The program will then, everytime you type MSDN replace MSDN with...
15
9713
by: Nayan | last post by:
Hi, Can anyone suggest working sample of capturing a window's picture? I tried a few, but couldn't get the image. I don't know why those functions are not getting the image. Note: I want the...
1
1453
by: thulaseeram | last post by:
hi, i am using the following code for uploading <div id="iframe" name="iframe" style="width:850px; height:120px;"> <iframe name="attach_frame" id="attach_frame"...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.