-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenMaginification.py
More file actions
46 lines (30 loc) · 1.14 KB
/
Copy pathScreenMaginification.py
File metadata and controls
46 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# screen maginification
import pyautogui
import pygame
import PIL
from PIL import Image
pygame.init()
LocationLeft = 50
LocationTop = 50
LocationWidth = 100
LocationHeight = 100
Magnification = 3
gameDisplay = pygame.display.set_mode((LocationWidth * Magnification , LocationHeight * Magnification ))
crashed = False
ImageFileName="ScreenLarger.png"
try:
while not crashed:
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
x, y = pyautogui.position()
LocationLeft = x - 25
LocationTop = y - 25
screenshot = pyautogui.screenshot(region=(LocationLeft,LocationTop, LocationWidth, LocationHeight))
img = Image.frombytes(screenshot.mode,screenshot.size,screenshot.tobytes())
img = img.resize((LocationWidth * Magnification, LocationHeight * Magnification))
theimg = pygame.image.frombuffer(img.tobytes(), img.size, img.mode)
gameDisplay.blit(theimg,(0,0))
pygame.display.update()
except KeyboardInterrupt:
print('\n')