Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making a cross-platform product #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

KokeCacao
Copy link

Add - Windows version
Fix - Screenshot taking
Fix - Keyboard typing

Still have problems with picking pixels because the pixels are hard-coded. Not convenient.

Copy link

@rsohlot rsohlot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom screenshot can be taken by this code in windows:

os.system("screencapture -R{},{},{},{} tmp.png".format(x, y, w, h))
img = Image.open("tmp.png")
return img
# os.system("screencapture -R{},{},{},{} tmp.png".format(x, y, w, h))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be done same as the main code( taking screenshots of custom window size) by the following code :

import win32gui

...

def screenshot(x, y, w, h):

toplist, winlist = [] ,[]
def enum_cb(hwnd, results):
    winlist.append((hwnd, win32gui.GetWindowText(hwnd)))
win32gui.EnumWindows(enum_cb, toplist)

chrome = [(hwnd, title) for hwnd, title in winlist if 'chrome' in title.lower()]
# just grab the hwnd for first window matching chrome
chrome = chrome[0]
hwnd = chrome[0]

win32gui.SetForegroundWindow(hwnd)
bbox = win32gui.GetWindowRect(hwnd)
img = ImageGrab.grab(bbox=(x,y,w,h))
img.save('tmp.PNG')
return img

@vdmitriyev
Copy link

I used this utility - https://github.com/chuntaro/screenshot-cmd instead of given one for windows (and I also had to correct the key hooks).

@utay
Copy link
Owner

utay commented Aug 27, 2018

Hey @KokeCacao, thanks for the PR and sorry for the long time I've took to answer!

It looks good to me overall but are the *.whl files necessary? If not, they don't need to be pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants