Skip to content

Commit 2e4d9a2

Browse files
committed
update fetch_screen_size()
1 parent 0fa6d36 commit 2e4d9a2

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Let's do some tries to dump traditional mouse
44

55
Use keyboard to click anywhere of screen. OpenCV based screenshot visual recognition.
66

7-
> The **vi** in the name here can mean "Vim", "Vision" or whatever
7+
> The **vi** in the name here can mean "Vim", "Vision-recognition" or whatever
88
99
![screenshot](demo.gif)
1010

@@ -26,8 +26,9 @@ This is still very simple and **in alpha preview** stage currently. Anything cou
2626
2727
There're some known issues. Apparently there're many we can do to improve it (open for discussion) :
2828

29-
- Algorithm (filtering, recognizing, parameters... ) . If you don't have a high contrast GUI, or some icons or buttons don't have clear contour, it may fail to recognize them.
30-
- It's better to make it faster when using hi-res screens
29+
- Algorithm (filtering, recognizing, parameters... ) . Currently, if you don't have a high contrast GUI, or some icons or buttons don't have clear contour, or two objects too close, it may fail to recognize.
30+
31+
- It's better to make it faster when using hi-res full-screens (in the future will apply grid selecting)
3132

3233
## Other vi / keybinding projects
3334

viscreen.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,23 @@ def resetRegions() :
514514
keypListFiltered = keypList
515515

516516

517-
# def fetch_screen_size() :
518-
# global screenW, screenH
519-
# root = tk.Tk()
520-
# w = root.winfo_screenwidth()
521-
# h = root.winfo_screenheight()
522-
# screenW = w
523-
# screenH = h
524-
# root.destroy();
517+
def fetch_screen_size() :
518+
global screenW, screenH
519+
520+
521+
app = QGuiApplication([])
522+
screens = QGuiApplication.screens()
523+
524+
total_geometry = QRect()
525+
for s in screens:
526+
total_geometry = total_geometry.united(s.geometry())
527+
528+
print(total_geometry.x(), total_geometry.y(), total_geometry.width(), total_geometry.height())
529+
530+
w = total_geometry.width()
531+
h = total_geometry.height()
532+
screenW = w
533+
screenH = h
525534

526535

527536
if __name__ == '__main__':

0 commit comments

Comments
 (0)