Skip to content

Commit

Permalink
initial verison
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMoan committed Oct 28, 2020
1 parent ee7ca72 commit d7e5642
Show file tree
Hide file tree
Showing 13 changed files with 1,342 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include **/lib libRemoteInput*
recursive-include **/lib/headers/ *.hxx
15 changes: 15 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
pillow = "*"
pyautogui = "*"
psutil = "*"
setuptools = "*"

[requires]
python_version = "3.9"
121 changes: 121 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions examples/get_window_screenshot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import win32gui
import win32ui
from ctypes import windll
from PIL import Image

hwnd = win32gui.FindWindow(None, "Old School RuneScape")

# Change the line below depending on whether you want the whole window
# or just the client area.
# left, top, right, bot = win32gui.GetClientRect(hwnd)
left, top, right, bot = win32gui.GetWindowRect(hwnd)
w = right - left
h = bot - top

hwndDC = win32gui.GetWindowDC(hwnd)
mfcDC = win32ui.CreateDCFromHandle(hwndDC)
saveDC = mfcDC.CreateCompatibleDC()

saveBitMap = win32ui.CreateBitmap()
saveBitMap.CreateCompatibleBitmap(mfcDC, w, h)

saveDC.SelectObject(saveBitMap)

# Change the line below depending on whether you want the whole window
# or just the client area.
result = windll.user32.PrintWindow(hwnd, saveDC.GetSafeHdc(), 1)
# result = windll.user32.PrintWindow(hwnd, saveDC.GetSafeHdc(), 0)
print(result)

bmpinfo = saveBitMap.GetInfo()
bmpstr = saveBitMap.GetBitmapBits(True)

im = Image.frombuffer(
"RGB", (bmpinfo["bmWidth"], bmpinfo["bmHeight"]), bmpstr, "raw", "BGRX", 0, 1
)

im.show()
win32gui.DeleteObject(saveBitMap.GetHandle())
saveDC.DeleteDC()
mfcDC.DeleteDC()
win32gui.ReleaseDC(hwnd, hwndDC)

if result == 1:
# PrintWindow Succeeded
im.save("test.png")
24 changes: 24 additions & 0 deletions examples/pyautogui_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pyautogui
import _pyautogui_remoteinput

pyautogui.platformModule = _pyautogui_remoteinput
reflect = pyautogui.platformModule.REFLECT

reflect.EIOS_Inject()

# Get number of clients
client_count = reflect.EIOS_GetClients()
print(f"there are {client_count} clients")

# Get first clients PID
client_pid = reflect.EIOS_GetClientPID(0)

# Pair the client and get the target or eios_ptr
eios_ptr = reflect.EIOS_PairClient(client_pid)
print(f"Pointer for the target for client is = {eios_ptr}")

pyautogui.click(478, 294)
pyautogui.click(375, 263)
pyautogui.typewrite("password")
pyautogui.click(329, 319)
pyautogui.platformModule._size()
78 changes: 78 additions & 0 deletions examples/tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import getpass

from pyautoeios.eios import EIOS
from pyautoeios.hex_keycodes import VK_ESC, VK_LBUTTON

print("injecting into client")
# Create instance of Remote Input
reflect = EIOS()

# Get number of clients
client_count = reflect.EIOS_GetClients()
print(f"there are {client_count} clients")

# Get first clients PID
client_pid = reflect.EIOS_GetClientPID(0)

# Pair the client and get the target or eios_ptr
eios_ptr = reflect.EIOS_PairClient(client_pid)
print(f"Pointer for the target for client is = {eios_ptr}")

reflect.lose_focus(eios_ptr)
have_focus1 = reflect.has_focus(eios_ptr)
print(f"have_focus1 = {have_focus1}")

reflect.gain_focus(eios_ptr)
have_focus2 = reflect.has_focus(eios_ptr)
print(f"have_focus2 = {have_focus2}")

dimensions = reflect.get_target_dimensions(eios_ptr)
print(f"dimensions = {dimensions}")

mouse_position = reflect.get_mouse_position(eios_ptr)
print(f"mouse_position = {mouse_position}")

real_mouse_position = reflect.get_real_mouse_position(eios_ptr)
print(f"real_mouse_position = {real_mouse_position}")

print(
"If you're at the login screen enter password to do a stupidly simple login _SCDECLpt with fixed coordinates"
)
password = getpass.getpass()
if password:
reflect.hold_key(eios_ptr, VK_ESC)
time.sleep(0.3)
reflect.release_key(eios_ptr, VK_ESC)
reflect.hold_key(eios_ptr, VK_ESC)
time.sleep(0.3)
reflect.release_key(eios_ptr, VK_ESC)
reflect.hold_key(eios_ptr, VK_ESC)
time.sleep(0.3)
reflect.release_key(eios_ptr, VK_ESC)

reflect._EIOS_MoveMouse(eios_ptr, 478, 294)
mouse_position = reflect.get_mouse_position(eios_ptr)
print(f"mouse_position = {mouse_position}")

reflect._EIOS_HoldMouse(eios_ptr, 478, 294, VK_LBUTTON)
time.sleep(0.3)
reflect._EIOS_ReleaseMouse(eios_ptr, 478, 294, VK_LBUTTON)
mouse_position = reflect.get_mouse_position(eios_ptr)
print(f"mouse_position = {mouse_position}")

reflect._EIOS_HoldMouse(eios_ptr, 375, 263, VK_LBUTTON)
time.sleep(0.3)
reflect._EIOS_ReleaseMouse(eios_ptr, 375, 263, VK_LBUTTON)
mouse_position = reflect.get_mouse_position(eios_ptr)
print(f"mouse_position = {mouse_position}")

reflect._EIOS_SendString(eios_ptr, password, 100, 100)

reflect._EIOS_HoldMouse(eios_ptr, 329, 319, VK_LBUTTON)
time.sleep(0.3)
reflect._EIOS_ReleaseMouse(eios_ptr, 329, 319, VK_LBUTTON)
mouse_position = reflect.get_mouse_position(eios_ptr)
print(f"mouse_position = {mouse_position}")

reflect._lose_focus(eios_ptr)
reflect._EIOS_ReleaseTarget(eios_ptr)
3 changes: 3 additions & 0 deletions examples/testpath.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import importlib.resources
f = importlib.resources.files(__package__)
print(f / 'lib')
39 changes: 39 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[metadata]
name = pyautoeios
version = attr: src.pyautoeios.__VERSION__
author = Brett Moan
author-email = [email protected]
home-page = https://github.com/BrettMoan/pyautoeios
description = automate an old school classic
long-description = file: README.md
long_description_content_type = text/markdown
license = BSD 3-Clause
license-file = LICENSE
platform = any
keywords = {keywords}
classifiers =
Development Status :: 2 - Pre-Alpha
Intended Audience :: Developers
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Environment :: Win32 (MS Windows)
Operating System :: Microsoft :: Windows :: Windows 10
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Games/Entertainment
Topic :: Scientific/Engineering :: Image Recognition
Topic :: Scientific/Engineering :: Image Processing
project_urls =
Bug Tracker = https://github.com/BrettMoan/pyautoeios/issues
Changelog = https://github.com/BrettMoan/pyautoeios/blob/master/CHANGELOG.md

include_package_data = True

[options]
package_dir=
=src
packages=find:

[options.packages.find]
where=src
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import setuptools

setuptools.setup()
7 changes: 7 additions & 0 deletions src/pyautoeios/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pyautogui import *
from pyautoeios import eios
import pyautoeios.hex_keycodes as hexcodes
from pyautoeios import _pyautogui_remoteinput
platformModule = _pyautogui_remoteinput
__AUTHOR__ = "[email protected]"
__VERSION__ = "0.0.1"
Loading

0 comments on commit d7e5642

Please sign in to comment.