Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #5

Merged
merged 3 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 20 additions & 30 deletions .idea/workspace.xml

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions circle_ci_test/record_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys
from time import sleep

from je_auto_control import record
from je_auto_control import stop_record
from je_auto_control import type_key

record()
type_key("t")
type_key("e")
type_key("s")
type_key("t")

sleep(1)
stop_record()
27 changes: 11 additions & 16 deletions je_auto_control/osx/listener/osx_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@
from queue import Queue


class RecordQueue(object):
record_queue = Queue()

def __init__(self):
self.record_queue = None
app = NSApplication.sharedApplication()

def reset_queue(self):
self.record_queue = Queue()


record_queue_manager = RecordQueue()

class AppDelegate(NSObject):
def applicationDidFinishLaunching_(self, aNotification):
Expand All @@ -32,30 +26,31 @@ def applicationDidFinishLaunching_(self, aNotification):

def mouse_left_handler(event):
loc = NSEvent.mouseLocation()
record_queue_manager.record_queue.put(("mouse_left", loc.x, loc.y))
record_queue.put(("mouse_left", loc.x, loc.y))


def mouse_right_handler(event):
loc = NSEvent.mouseLocation()
record_queue_manager.record_queue.put(("mouse_right", loc.x, loc.y))
record_queue.put(("mouse_right", loc.x, loc.y))


def keyboard_handler(event):
record_queue_manager.record_queue.put(("keyboard", int(hex(event.keyCode()), 16)))
if int(event.keyCode()) == 98:
AppHelper.stopEventLoop()
pass
else:
record_queue.put(("keyboard", int(hex(event.keyCode()), 16)))
print(event)


def osx_record():
record_queue_manager.reset_queue()
app = NSApplication.sharedApplication()
record_queue = Queue()
delegate = AppDelegate.alloc().init()
NSApp().setDelegate_(delegate)
app.setDelegate_(delegate)
AppHelper.runEventLoop()


def osx_stop_record():
return record_queue_manager.record_queue
return record_queue


if __name__ == "__main__":
Expand Down
14 changes: 13 additions & 1 deletion je_auto_control/osx/record/osx_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ def stop_record(self):
raise AutoControlRecordException
return osx_stop_record()

osx_recorder = OSXRecorder()
osx_recorder = OSXRecorder()


if __name__ == "__main__":
test_osx_recorder = OSXRecorder()
test_osx_recorder.record()
temp = test_osx_recorder.stop_record()
print(temp)
for action in temp.queue:
print(action)
while True:
pass

14 changes: 8 additions & 6 deletions je_auto_control/wrapper/auto_control_record.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlRecordException
from je_auto_control.utils.je_auto_control_exception.exception_tag import record_not_found_action_error
from je_auto_control.wrapper.auto_control_mouse import click_mouse
Expand Down Expand Up @@ -34,10 +36,14 @@ def stop_record_keyboard():


def record():
if sys.platform == "darwin":
raise Exception("macos can't use recorder")
recorder.record()


def stop_record():
if sys.platform == "darwin":
raise Exception("macos can't use recorder")
action_queue = recorder.stop_record()
if action_queue is None:
raise AutoControlRecordException
Expand All @@ -53,12 +59,8 @@ def stop_record():
if __name__ == "__main__":
record()
from time import sleep
sleep(10)
sleep(5)
stop_record()
sleep(3)
import sys
if sys.platform in ["darwin"]:
record()
stop_record()
sleep(2)


3 changes: 1 addition & 2 deletions je_auto_control/wrapper/platform_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,7 @@
keyboard_check = osx_keyboard_check
mouse = osx_mouse
screen = osx_screen
recorder = osx_recorder
if None in [keys_table, mouse_table, keyboard_check, keyboard, mouse, screen, recorder]:
if None in [keys_table, mouse_table, keyboard_check, keyboard, mouse, screen]:
raise AutoControlException("Can't init auto control")

elif sys.platform in ["linux", "linux2"]:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="je_auto_control",
version="0.0.39",
version="0.0.40",
author="JE-Chen",
author_email="zenmailman@gmail.com",
description="auto control gui",
Expand Down
15 changes: 15 additions & 0 deletions test/platform_independent/test/record_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys
from time import sleep

from je_auto_control import record
from je_auto_control import stop_record
from je_auto_control import type_key

record()
type_key("t")
type_key("e")
type_key("s")
type_key("t")

sleep(1)
stop_record()