Making a cross-platform product#2
Open
KokeCacao wants to merge 2 commits into
Open
Conversation
rsohlot
suggested changes
Jul 30, 2018
rsohlot
left a comment
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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
|
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). |
Owner
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add - Windows version
Fix - Screenshot taking
Fix - Keyboard typing
Still have problems with picking pixels because the pixels are hard-coded. Not convenient.