i,
I have trying to code a small console app that will
allow a user to select a window and then create a
screen capture of the window. I haven't been able to
figure out how to do the screen capture part. The
code is as follows, the commented out lines at the end
are things I have tried, but don't work. Whenever I
try to create a compatibe Bitmap or DC it comes back
with an error as
win32ui: CreateCompatibl eDC failed
or
AttributeError: CreateCompatibl eDC
Any help would be greatly appreciated.
import win32gui
import win32ui
numWindows = 0
windows = []
winDict = {}
windowsText=[]
inc = 0
def _MyCallback( hwnd, extra ):
extra.append(hw nd)
win32gui.EnumWi ndows(_MyCallba ck, windows)
for i in windows:
if win32gui.IsWind owVisible(i):
if win32gui.IsWind owVisible:
windowsText.app end(i)
winDict[numWindows] = i
numWindows +=1
print "Please select a window to capture"
for window in windowsText:
windowText = win32gui.GetWin dowText(window)
print inc, windowText
inc += 1
selection = input()
print win32gui.GetWin dowText(winDict[selection])
myDC = win32ui.CreateD CFromHandle(win Dict[selection])
win32gui.SetFor egroundWindow(w inDict[selection])
win_sz = win32gui.GetCli entRect(winDict[selection])
myBitMap = win32ui.CreateB itmap()
#myMemDC = win32ui.CreateC ompatibleDC(myD C)
#myBitMap.BitBl t((0,0),(win_sz[2],win_sz[3],myDC,(0,0),0))
#myBitMap.Creat eCompatibleBitM ap(myDC,win_sz[2], win_sz[3])
#myBitMap.Creat eCompatibleDC(m yDC)
Thanks,
Rob
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
I have trying to code a small console app that will
allow a user to select a window and then create a
screen capture of the window. I haven't been able to
figure out how to do the screen capture part. The
code is as follows, the commented out lines at the end
are things I have tried, but don't work. Whenever I
try to create a compatibe Bitmap or DC it comes back
with an error as
win32ui: CreateCompatibl eDC failed
or
AttributeError: CreateCompatibl eDC
Any help would be greatly appreciated.
import win32gui
import win32ui
numWindows = 0
windows = []
winDict = {}
windowsText=[]
inc = 0
def _MyCallback( hwnd, extra ):
extra.append(hw nd)
win32gui.EnumWi ndows(_MyCallba ck, windows)
for i in windows:
if win32gui.IsWind owVisible(i):
if win32gui.IsWind owVisible:
windowsText.app end(i)
winDict[numWindows] = i
numWindows +=1
print "Please select a window to capture"
for window in windowsText:
windowText = win32gui.GetWin dowText(window)
print inc, windowText
inc += 1
selection = input()
print win32gui.GetWin dowText(winDict[selection])
myDC = win32ui.CreateD CFromHandle(win Dict[selection])
win32gui.SetFor egroundWindow(w inDict[selection])
win_sz = win32gui.GetCli entRect(winDict[selection])
myBitMap = win32ui.CreateB itmap()
#myMemDC = win32ui.CreateC ompatibleDC(myD C)
#myBitMap.BitBl t((0,0),(win_sz[2],win_sz[3],myDC,(0,0),0))
#myBitMap.Creat eCompatibleBitM ap(myDC,win_sz[2], win_sz[3])
#myBitMap.Creat eCompatibleDC(m yDC)
Thanks,
Rob
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Comment