Exemplo n.º 1
0
 def __get_client(self):
     rect = GetClientRect(self.hwnd)
     point = ScreenToClient(self.hwnd, (0,0))
     x = abs(point[0])
     y = abs(point[1])
     w = rect[2]
     h = rect[3]
     return Rect(y, x, w, h)
Exemplo n.º 2
0
 def bounds(self):
     """"
     returns (left, top, right, bottom) of client area
     in screen coordinates
     """
     (cl, ct, cr, cb) = GetClientRect(self.hwnd)
     (sl, st) = ClientToScreen(self.hwnd, (cl, ct))
     (sr, sb) = ClientToScreen(self.hwnd, (cr, cb))
     return tuple([sl, st, sr, sb])
 def __get_handle_rect(hwnd) -> Rect:
     # Get the size of the rectangle
     x, y, x1, y1 = GetClientRect(hwnd)
     # Get the position of the rectangle top corner on screen.
     x, y = ClientToScreen(hwnd, (x, y))
     # Move the bottom right corner by the offset
     x1 += x
     y1 += y
     return Rect(Point(x, y), Point(x1, y1))
Exemplo n.º 4
0
def clientRect():
    global client
    global running
    try:
        x, y, width, height = GetClientRect(client)
    except:
        running = False
        quit()
    return x, y, width, height
def screenshot(window_title=None, factorx=0, factory=0):
    if window_title:
        hwnd = FindWindow(None, window_title)
        if hwnd:
            SetForegroundWindow(hwnd)
            x, y, x1, y1 = GetClientRect(hwnd)
            x, y = ClientToScreen(hwnd, (x, y))
            x1, y1 = ClientToScreen(hwnd, (x1 - x, y1 - y))
            # x,y,x1,y1 position and size
            x += int((x1 * factorx / 2))
            x1 -= int((x1 * factorx))
            y += int((y1 * factory / 2))
            y1 -= int((y1 * factory))
            im = pyautogui.screenshot(region=(x, y, x1, y1))
            return im
        else:
            print('Window not found!')
    else:
        im = pyautogui.screenshot()
        return im
    def __init__(self):
        self.AHK = AHK()
        self.application = self.start_game()
        self.process_id = self.application.process
        self.process = Process(pid=self.process_id)
        self.dialog = self.get_window_dialog()
        self.handle = self.dialog.handle
        self.window = Window.from_pid(self.AHK, self.process_id)

        left, top, right, bot = GetClientRect(self.handle)
        w = right - left
        h = bot - top

        self.hwndDC = GetWindowDC(self.handle)
        self.mfcDC = CreateDCFromHandle(self.hwndDC)
        self.saveDC = self.mfcDC.CreateCompatibleDC()
        self.saveDC_handle = self.saveDC.GetSafeHdc()

        self.saveBitMap = CreateBitmap()
        self.saveBitMap.CreateCompatibleBitmap(self.mfcDC, w, h)
        self.bmpinfo = self.saveBitMap.GetInfo()
        self.saveDC.SelectObject(self.saveBitMap)

        self.navigate_main_menu()
        self.enter_avoidance()
        self.process.suspend()

        self.PREVIOUS_ACTION = 0
        self.deathcount = self.get_game_deathcount()
        self.action_space = spaces.Discrete(6)
        self.elapsed_time = 0.0

        self.observation_space = spaces.Dict({"window":
                                                  spaces.Box(low=0, high=255, shape=self.get_observation_space_size(),
                                                             dtype=np.uint8),
                                              "time": spaces.Box(low=0, high=900, shape=(1,))})
Exemplo n.º 7
0
def get_window_client_area_position():
    window_handle = FindWindow('Anno1602HistoryEditionWindow',
                               'Anno 1602 History Edition')
    left, top, right, bottom = GetClientRect(window_handle)
    left2, top2 = ClientToScreen(window_handle, (left, top))
    return left2, top2
Exemplo n.º 8
0
Arquivo: main.py Projeto: hldh214/PUBG
parser.add_argument('-v',
                    '--verbose',
                    help='verbose output',
                    action='count',
                    default=0)
args = parser.parse_args()
logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S')
notify = Notify(args.notify)
verboseprint = notify.method if args.verbose else lambda *a, **k: None
round_count = 0

hwnd = FindWindow('UnrealWindow', None)
SetForegroundWindow(hwnd)
_left, _top, _right, _bottom = GetClientRect(hwnd)
left, top = ClientToScreen(hwnd, (_left, _top))
right, bottom = ClientToScreen(hwnd, (_right, _bottom))
window_rect = [left, top, right, bottom]
dicts = {
    'start': pickle.load(open('dicts/start.pkl', 'rb')),
    'war_start': pickle.load(open('dicts/war_start.pkl', 'rb')),
    'plane': pickle.load(open('dicts/plane.pkl', 'rb')),
    'reconnect': pickle.load(open('dicts/reconnect.pkl', 'rb')),
    'cancel': pickle.load(open('dicts/cancel.pkl', 'rb')),
    'exit_to_lobby': pickle.load(open('dicts/exit_to_lobby.pkl', 'rb')),
    'tl_pubg_logo': pickle.load(open('dicts/tl_pubg_logo.pkl', 'rb')),
    'timeout': pickle.load(open('dicts/timeout.pkl', 'rb')),
    'war_countdown': pickle.load(open('dicts/war_countdown.pkl', 'rb'))
}
Exemplo n.º 9
0
 def resize_client(self, w, h):
     cx1, cy1, cx2, cy2 = GetClientRect(self.hwnd)
     wx1, wy1, wx2, wy2 = GetWindowRect(self.hwnd)
     dx = (wx2 - wx1) - cx2
     dy = (wy2 - wy1) - cy2
     MoveWindow(self.hwnd, wx1, wy1, w+dx, h+dy, True)