Skip to content

Making a cross-platform product#2

Open
KokeCacao wants to merge 2 commits into
utay:masterfrom
KokeCacao:master
Open

Making a cross-platform product#2
KokeCacao wants to merge 2 commits into
utay:masterfrom
KokeCacao:master

Conversation

@KokeCacao

Copy link
Copy Markdown

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

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

@rsohlot rsohlot left a comment

Copy link
Copy Markdown

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:

Comment thread dino-ml/scanner.py Outdated
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
Copy Markdown

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
Copy Markdown

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

utay commented Aug 27, 2018

Copy link
Copy Markdown
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 *.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