Esempio n. 1
0
def grab_screen(region=None):
    hwin = win32gui.GetDesktopWindow()

    if region:
        left, top, x2, y2 = region
        width = x2 - left + 1
        height = y2 - top + 1
    else:
        width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)
        height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)
        left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)
        top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)

    hwindc = win32gui.GetWindowDC(hwin)
    srcdc = win32ui.CreateDCFromHandle(hwindc)
    memdc = srcdc.CreateCompatibleDC()
    bmp = win32ui.CreateBitmap()
    bmp.CreateCompatibleBitmap(srcdc, width, height)
    memdc.SelectObject(bmp)
    memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY)

    signedIntsArray = bmp.GetBitmapBits(True)
    img = np.fromstring(signedIntsArray, dtype='uint8')
    img.shape = (height, width, 4)

    srcdc.DeleteDC()
    memdc.DeleteDC()
    win32gui.ReleaseDC(hwin, hwindc)
    win32gui.DeleteObject(bmp.GetHandle())

    return cv2.cvtColor(img, cv2.COLOR_BGRA2RGB)
Esempio n. 2
0
 def __init__(self, parent=None):
     super(Application, self).__init__(parent)
     self.title = 'Zadanie projektowe nr 2'
     screen_width = w32.GetSystemMetrics(0)
     screen_height = w32.GetSystemMetrics(1)
     self.width = 1024
     self.height = 768
     self.left = (screen_width - self.width) / 2
     self.top = -30 + (screen_height - self.height) / 2
     self.form_widget = None
     self.regA = Register("AX")
     self.regB = Register("BX")
     self.regC = Register("CX")
     self.regD = Register("DX")
     self.program_code = QPlainTextEdit(self)
     self.mode = -1
     self.help_bios = None
     self.step = False
     self.pattern1 = re.compile(r"\d{1,3}\s\D{3}\s\S{2},\S{2}")
     self.pattern2 = re.compile(r"\d{1,3}\s\D{3}\s\S{2},#\d{1,3}")
     self.pattern3 = re.compile(r"\d{1,3}\sINT\S{2}")
     self.pattern4 = re.compile(r"\d{1,3}\s\D{3,4}\s\S{2}")
     self.stack = []
     self.max_stack = 15
     self.stack_pointer = 0
     self.initWindow()
Esempio n. 3
0
    def receive_msg(self):
        self.lock.acquire()

        # for this problem: https://bbs.csdn.net/topics/390973288?page=1
        win32api.keybd_event(0x11, 0, 0, 0)  # ctrl
        win32api.keybd_event(0x11, 0, win32con.KEYEVENTF_KEYUP,
                             0)  # release key

        win32gui.ShowWindow(self.con_hwnd, win32con.SW_MAXIMIZE)
        win32gui.SetForegroundWindow(self.con_hwnd)

        time.sleep(1)

        x_mid = int(win32api.GetSystemMetrics(win32con.SM_CXSCREEN) / 2)
        y_mid = int(win32api.GetSystemMetrics(win32con.SM_CYSCREEN) / 2)
        win32api.SetCursorPos([x_mid, y_mid])

        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0,
                             0)  # left mouse button
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0,
                             0)  # release key

        win32api.keybd_event(0x11, 0, 0, 0)  # ctrl
        win32api.keybd_event(0x41, 0, 0, 0)  # 'a'
        win32api.keybd_event(0x11, 0, win32con.KEYEVENTF_KEYUP,
                             0)  # release key
        win32api.keybd_event(0x41, 0, win32con.KEYEVENTF_KEYUP,
                             0)  # release key

        win32api.keybd_event(0x11, 0, 0, 0)  # ctrl
        win32api.keybd_event(0x43, 0, 0, 0)  # 'c'
        win32api.keybd_event(0x11, 0, win32con.KEYEVENTF_KEYUP,
                             0)  # release key
        win32api.keybd_event(0x43, 0, win32con.KEYEVENTF_KEYUP,
                             0)  # release key

        time.sleep(1)

        win32clipboard.OpenClipboard()
        text = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
        win32clipboard.CloseClipboard()

        win32gui.SetForegroundWindow(self.cur_hwnd)

        time.sleep(1)

        self.lock.release()

        return text
Esempio n. 4
0
#     print("cant load configurations, exit")
# PATH
BUDDY_ROOT_PATH = all["BUDDY_ROOT_PATH"]
CLIENT_PATH = all["CLIENT_PATH"]
BUDDY_PATH = os.path.join(BUDDY_ROOT_PATH, "start.bat")

BUDDY_VERIFY_PATH = os.path.join(BUDDY_ROOT_PATH, "auto.exe")
BUDDY_STAT_PATH = os.path.join(BUDDY_ROOT_PATH, r"Settings\Default\Stats.json")
LOGS_PATH = os.path.join(BUDDY_ROOT_PATH, "Logs")
CLIENT_LOGIN_WINDOW_NAME = all["CLIENT_LOGIN_WINDOW_NAME"]
CLIENT_WINDOW_NAME = all["CLIENT_WINDOW_NAME"]
GAME_WINDOW_NAME = all["GAME_WINDOW_NAME"]
BUDDY_WINDOW_NAME = all["BUDDY_WINDOW_NAME"]
PYHL_NAME = "HL"

SCREEN_WIDTH = win32api.GetSystemMetrics(0)
SCREEN_HEIGHT = win32api.GetSystemMetrics(1)
LOGIN_ACCOUT_CLICK_POS = (35, 200)
LOGIN_PASSWORD_CLICK_POS = (35, 245)
LOGIN_ENTER_CLICK_POS = (180, 330)
CLIENT_POS = (-270, -500, 0, 0)
CLIENT_LOGIN_POS = (0, 0, 0, 0)
CLIENT_CLICK_POS = (10, 10)
GAME_WIDTH = 200
GAME_HEIGHT = 150
GAME_POS = (SCREEN_WIDTH - GAME_WIDTH, 0, GAME_WIDTH, GAME_HEIGHT)
BUDDY_WIDTH = all["BUDDY_WIDTH"]
BUDDY_HEIGHT = all["BUDDY_HEIGHT"]

BUDDY_POS = (0, 0, BUDDY_WIDTH, BUDDY_HEIGHT)
BUDDY_CLICK_POS = (BUDDY_POS[0] + BUDDY_WIDTH - 22, BUDDY_POS[1] + 103)
Esempio n. 5
0
import time, pyautogui, threading, os, random, sys, string
from tkinter import *
from win32 import win32api, win32gui
import PIL.ImageTk as ImageTk
from PIL import Image
from datetime import datetime


def destroy(event):
    root.destroy()


width = win32api.GetSystemMetrics(0)
height = win32api.GetSystemMetrics(1)

root = Tk()
root.geometry("600x600+%d+%d" % ((width / 2) - 300, (height / 2) - 300))
root.overrideredirect(1)
root.bind("<Escape>", destroy)
main = Frame(root, bg="blue")


class Tile:
    def __init__(self, location, number, x, y):
        self.number = number
        self.x = x
        self.y = y
        self.label = Label(location,
                           text=number,
                           bg="white",
                           fg="black",
Esempio n. 6
0
def onKeyboardEvent(event):
    if debug:
        print('Keyboard action detected, ' + str(event.Key) + ' was pressed.')
    if str(event.Key) == 'Lcontrol' or str(event.Key) == 'Rcontrol':
        hm.KeyDown = onWinCombo
        hm.KeyUp = cancelCombo
        return True
    else:
        return True


progParam = Tracker()

mons = win32api.EnumDisplayMonitors()
i = 0
while i < win32api.GetSystemMetrics(win32con.SM_CMONITORS):
    minfo = win32api.GetMonitorInfo(mons[i][0])
    progParam.l_monArray[i] = ([
        minfo['Monitor'][2] - minfo['Monitor'][0],
        minfo['Monitor'][3] - minfo['Monitor'][1]
    ], minfo['Monitor'][0], minfo['Monitor'][1], minfo['Monitor'][2],
                               minfo['Monitor'][3])
    i += 1
    if debug: print(minfo)
for key, rec in progParam.l_monArray.items():
    if vert:
        progParam.lSCREEN_HEIGHT += rec[0][1]
        progParam.lSCREEN_WIDTH = (
            rec[0][0]
        ) if progParam.lSCREEN_WIDTH < rec[0][0] else progParam.lSCREEN_WIDTH
        progParam.lYMAX = (