diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 10b6744..afdf837 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,31 +3,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
@@ -82,7 +61,7 @@
-
+
@@ -105,7 +84,7 @@
-
+
@@ -113,12 +92,12 @@
-
+
-
+
@@ -127,7 +106,7 @@
-
+
@@ -135,12 +114,12 @@
-
+
-
+
@@ -157,12 +136,12 @@
-
+
-
+
@@ -171,7 +150,7 @@
-
+
@@ -179,12 +158,12 @@
-
+
-
+
@@ -240,18 +219,18 @@
-
+
-
+
+
-
@@ -289,6 +268,7 @@
+
@@ -332,8 +312,8 @@
-
+
diff --git a/je_auto_control/linux_with_x11/core/utils/x11_linux_display.py b/je_auto_control/linux_with_x11/core/utils/x11_linux_display.py
index 4e83b80..0f89198 100644
--- a/je_auto_control/linux_with_x11/core/utils/x11_linux_display.py
+++ b/je_auto_control/linux_with_x11/core/utils/x11_linux_display.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
+
if sys.platform not in ["linux", "linux2"]:
- raise Exception("should be only loaded on linux")
+ raise AutoControlException(linux_import_error)
import os
from Xlib.display import Display
diff --git a/je_auto_control/linux_with_x11/core/utils/x11_linux_vk.py b/je_auto_control/linux_with_x11/core/utils/x11_linux_vk.py
index 0d25362..5b02f77 100644
--- a/je_auto_control/linux_with_x11/core/utils/x11_linux_vk.py
+++ b/je_auto_control/linux_with_x11/core/utils/x11_linux_vk.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
+
if sys.platform not in ["linux", "linux2"]:
- raise Exception("should be only loaded on linux")
+ raise AutoControlException(linux_import_error)
import Xlib
from Xlib import XK
diff --git a/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py b/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py
index f6c404b..b7c0838 100644
--- a/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py
+++ b/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
+
if sys.platform not in ["linux", "linux2"]:
- raise Exception("should be only loaded on linux")
+ raise AutoControlException(linux_import_error)
from je_auto_control.linux_with_x11.core.utils.x11_linux_display import display
from Xlib.ext.xtest import fake_input
diff --git a/je_auto_control/linux_with_x11/listener/x11_linux_listener.py b/je_auto_control/linux_with_x11/listener/x11_linux_listener.py
index 305ecef..7f0b254 100644
--- a/je_auto_control/linux_with_x11/listener/x11_linux_listener.py
+++ b/je_auto_control/linux_with_x11/listener/x11_linux_listener.py
@@ -1,7 +1,12 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
+from je_auto_control.utils.je_auto_control_exception.exception_tag import listener_error
+
+
if sys.platform not in ["linux", "linux2"]:
- raise Exception("should be only loaded on linux")
+ raise AutoControlException(linux_import_error)
import Xlib.threaded
@@ -62,8 +67,8 @@ def run(self, reply):
if self.record_flag is True:
temp = (event.type, event.detail, event.root_x, event.root_y)
self.record_queue.put(temp)
- except Exception:
- raise Exception
+ except AutoControlException:
+ raise AutoControlException(listener_error)
def record(self, record_queue):
"""
@@ -128,8 +133,8 @@ def run(self):
current_display.record_free_context(self.context)
# keep running this to get event
next_event = self.root.display.next_event()
- except Exception:
- raise Exception
+ except AutoControlException:
+ raise AutoControlException(listener_error)
finally:
self.handler.still_listener = False
self.still_listener = False
diff --git a/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py b/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py
index bacf6f6..799453f 100644
--- a/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py
+++ b/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
+
if sys.platform not in ["linux", "linux2"]:
- raise Exception("should be only loaded on linux")
+ raise AutoControlException(linux_import_error)
from Xlib import X
from Xlib.ext.xtest import fake_input
diff --git a/je_auto_control/linux_with_x11/record/x11_linux_record.py b/je_auto_control/linux_with_x11/record/x11_linux_record.py
index cc2a39d..6a3e06f 100644
--- a/je_auto_control/linux_with_x11/record/x11_linux_record.py
+++ b/je_auto_control/linux_with_x11/record/x11_linux_record.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
+
if sys.platform not in ["linux", "linux2"]:
- raise Exception("should be only loaded on linux")
+ raise AutoControlException(linux_import_error)
from Xlib import X
diff --git a/je_auto_control/linux_with_x11/screen/x11_linux_screen.py b/je_auto_control/linux_with_x11/screen/x11_linux_screen.py
index 4a7618d..9ae66f7 100644
--- a/je_auto_control/linux_with_x11/screen/x11_linux_screen.py
+++ b/je_auto_control/linux_with_x11/screen/x11_linux_screen.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
+
if sys.platform not in ["linux", "linux2"]:
- raise Exception("should be only loaded on linux")
+ raise AutoControlException(linux_import_error)
from je_auto_control.linux_with_x11.core.utils.x11_linux_display import display
diff --git a/je_auto_control/osx/core/utils/osx_vk.py b/je_auto_control/osx/core/utils/osx_vk.py
index 40b20cb..fb7b865 100644
--- a/je_auto_control/osx/core/utils/osx_vk.py
+++ b/je_auto_control/osx/core/utils/osx_vk.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import osx_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["darwin"]:
- raise Exception("should be only loaded on MacOS")
+ raise AutoControlException(osx_import_error)
"""
osx keyboard virtual keycode
diff --git a/je_auto_control/osx/keyboard/osx_keyboard.py b/je_auto_control/osx/keyboard/osx_keyboard.py
index f53bb06..dcc950b 100644
--- a/je_auto_control/osx/keyboard/osx_keyboard.py
+++ b/je_auto_control/osx/keyboard/osx_keyboard.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import osx_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["darwin"]:
- raise Exception("should be only loaded on MacOS")
+ raise AutoControlException(osx_import_error)
import time
diff --git a/je_auto_control/osx/keyboard/osx_keyboard_check.py b/je_auto_control/osx/keyboard/osx_keyboard_check.py
index 3cf5d27..2d9f5f1 100644
--- a/je_auto_control/osx/keyboard/osx_keyboard_check.py
+++ b/je_auto_control/osx/keyboard/osx_keyboard_check.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import osx_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["darwin"]:
- raise Exception("should be only loaded on MacOS")
+ raise AutoControlException(osx_import_error)
import Quartz
diff --git a/je_auto_control/osx/listener/osx_listener.py b/je_auto_control/osx/listener/osx_listener.py
index 24a832b..ceed42b 100644
--- a/je_auto_control/osx/listener/osx_listener.py
+++ b/je_auto_control/osx/listener/osx_listener.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import osx_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["darwin"]:
- raise Exception("should be only loaded on MacOS")
+ raise AutoControlException(osx_import_error)
from Cocoa import *
diff --git a/je_auto_control/osx/mouse/osx_mouse.py b/je_auto_control/osx/mouse/osx_mouse.py
index 3587a4a..2f36a64 100644
--- a/je_auto_control/osx/mouse/osx_mouse.py
+++ b/je_auto_control/osx/mouse/osx_mouse.py
@@ -1,7 +1,11 @@
import sys
+
+from je_auto_control.utils.je_auto_control_exception.exception_tag import osx_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["darwin"]:
- raise Exception("should be only loaded on MacOS")
+ raise AutoControlException(osx_import_error)
import time
diff --git a/je_auto_control/osx/record/osx_record.py b/je_auto_control/osx/record/osx_record.py
index 2aa726b..19663b3 100644
--- a/je_auto_control/osx/record/osx_record.py
+++ b/je_auto_control/osx/record/osx_record.py
@@ -1,7 +1,11 @@
import sys
+
+from je_auto_control.utils.je_auto_control_exception.exception_tag import osx_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["darwin"]:
- raise Exception("should be only loaded on MacOS")
+ raise AutoControlException(osx_import_error)
from je_auto_control.osx.listener.osx_listener import osx_record
from je_auto_control.osx.listener.osx_listener import osx_stop_record
diff --git a/je_auto_control/osx/screen/osx_screen.py b/je_auto_control/osx/screen/osx_screen.py
index 57879cd..bb059ba 100644
--- a/je_auto_control/osx/screen/osx_screen.py
+++ b/je_auto_control/osx/screen/osx_screen.py
@@ -1,3 +1,11 @@
+import sys
+
+from je_auto_control.utils.je_auto_control_exception.exception_tag import osx_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
+if sys.platform not in ["darwin"]:
+ raise AutoControlException(osx_import_error)
+
import Quartz
diff --git a/je_auto_control/utils/action_file/json_loader.py b/je_auto_control/utils/action_file/json_loader.py
index eda181f..1c7b2d3 100644
--- a/je_auto_control/utils/action_file/json_loader.py
+++ b/je_auto_control/utils/action_file/json_loader.py
@@ -4,6 +4,7 @@
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlJsonActionException
from je_auto_control.utils.je_auto_control_exception.exception_tag import cant_save_json_error
+from je_auto_control.utils.je_auto_control_exception.exception_tag import cant_find_json_error
lock = Lock()
@@ -19,7 +20,7 @@ def read_action_json(json_file_path: str):
with open(json_file_path) as read_file:
return read_file.read()
except AutoControlJsonActionException:
- raise AutoControlJsonActionException
+ raise AutoControlJsonActionException(cant_find_json_error)
finally:
lock.release()
diff --git a/je_auto_control/utils/je_auto_control_exception/exception_tag.py b/je_auto_control/utils/je_auto_control_exception/exception_tag.py
index 9bd305b..879d58b 100644
--- a/je_auto_control/utils/je_auto_control_exception/exception_tag.py
+++ b/je_auto_control/utils/je_auto_control_exception/exception_tag.py
@@ -4,6 +4,12 @@
je_auto_control_error = "Auto control error"
je_auto_control_critical_exit_error = "Auto control critical exit error"
"""
+os tags
+"""
+linux_import_error = "should be only loaded on linux"
+osx_import_error = "should be only loaded on MacOS"
+windows_import_error = "should be only loaded on windows"
+"""
keyboard tags
"""
keyboard_error = "Auto control keyboard error"
@@ -39,6 +45,10 @@
cant_find_image = "can't find image"
find_image_error_variable = "variable error"
"""
+listener tags
+"""
+listener_error = "Auto control listener error"
+"""
record tags
"""
record_queue_error = "can't get record queue it's none are you using stop record before record"
diff --git a/je_auto_control/windows/core/utils/win32_ctype_input.py b/je_auto_control/windows/core/utils/win32_ctype_input.py
index 0465dd2..3d7ff8d 100644
--- a/je_auto_control/windows/core/utils/win32_ctype_input.py
+++ b/je_auto_control/windows/core/utils/win32_ctype_input.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
import ctypes
from ctypes import wintypes
diff --git a/je_auto_control/windows/core/utils/win32_vk.py b/je_auto_control/windows/core/utils/win32_vk.py
index 0f043f2..56354a9 100644
--- a/je_auto_control/windows/core/utils/win32_vk.py
+++ b/je_auto_control/windows/core/utils/win32_vk.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
"""
windows mouse virtual keycode
diff --git a/je_auto_control/windows/keyboard/win32_ctype_keyboard_control.py b/je_auto_control/windows/keyboard/win32_ctype_keyboard_control.py
index 9df3668..811f68e 100644
--- a/je_auto_control/windows/keyboard/win32_ctype_keyboard_control.py
+++ b/je_auto_control/windows/keyboard/win32_ctype_keyboard_control.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
from je_auto_control.windows.core.utils.win32_ctype_input import Input
from je_auto_control.windows.core.utils.win32_ctype_input import Keyboard
diff --git a/je_auto_control/windows/keyboard/win32_keyboard_check.py b/je_auto_control/windows/keyboard/win32_keyboard_check.py
index ab07efa..231e053 100644
--- a/je_auto_control/windows/keyboard/win32_keyboard_check.py
+++ b/je_auto_control/windows/keyboard/win32_keyboard_check.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
import ctypes
diff --git a/je_auto_control/windows/listener/win32_keyboard_listener.py b/je_auto_control/windows/listener/win32_keyboard_listener.py
index eadb15d..281aef5 100644
--- a/je_auto_control/windows/listener/win32_keyboard_listener.py
+++ b/je_auto_control/windows/listener/win32_keyboard_listener.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
from ctypes import *
from ctypes.wintypes import MSG
diff --git a/je_auto_control/windows/listener/win32_mouse_listener.py b/je_auto_control/windows/listener/win32_mouse_listener.py
index e74fe7f..6a124de 100644
--- a/je_auto_control/windows/listener/win32_mouse_listener.py
+++ b/je_auto_control/windows/listener/win32_mouse_listener.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
from ctypes import *
from ctypes.wintypes import MSG
diff --git a/je_auto_control/windows/mouse/win32_ctype_mouse_control.py b/je_auto_control/windows/mouse/win32_ctype_mouse_control.py
index d7cdca5..d1652e2 100644
--- a/je_auto_control/windows/mouse/win32_ctype_mouse_control.py
+++ b/je_auto_control/windows/mouse/win32_ctype_mouse_control.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
from je_auto_control.windows.core.utils.win32_ctype_input import Input
from je_auto_control.windows.core.utils.win32_ctype_input import win32_LEFTDOWN
diff --git a/je_auto_control/windows/record/win32_record.py b/je_auto_control/windows/record/win32_record.py
index 19319bc..8b96340 100644
--- a/je_auto_control/windows/record/win32_record.py
+++ b/je_auto_control/windows/record/win32_record.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
from je_auto_control.windows.listener.win32_keyboard_listener import Win32KeyboardListener
from je_auto_control.windows.listener.win32_mouse_listener import Win32MouseListener
diff --git a/je_auto_control/windows/screen/win32_screen.py b/je_auto_control/windows/screen/win32_screen.py
index 7698327..7b2eebf 100644
--- a/je_auto_control/windows/screen/win32_screen.py
+++ b/je_auto_control/windows/screen/win32_screen.py
@@ -1,7 +1,10 @@
import sys
+from je_auto_control.utils.je_auto_control_exception.exception_tag import windows_import_error
+from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
+
if sys.platform not in ["win32", "cygwin", "msys"]:
- raise Exception("should be only loaded on windows")
+ raise AutoControlException(windows_import_error)
import ctypes
diff --git a/je_auto_control/wrapper/auto_control_image.py b/je_auto_control/wrapper/auto_control_image.py
index 8b7645a..dfcdcc4 100644
--- a/je_auto_control/wrapper/auto_control_image.py
+++ b/je_auto_control/wrapper/auto_control_image.py
@@ -1,6 +1,7 @@
-from je_auto_control.utils.je_auto_control_exception import exception_tag
-from je_auto_control.utils.je_auto_control_exception.exceptions import ImageNotFoundException
from je_auto_control.utils.image import template_detection
+from je_auto_control.utils.je_auto_control_exception.exception_tag import cant_find_image
+from je_auto_control.utils.je_auto_control_exception.exception_tag import find_image_error_variable
+from je_auto_control.utils.je_auto_control_exception.exceptions import ImageNotFoundException
from je_auto_control.wrapper.auto_control_mouse import click_mouse
from je_auto_control.wrapper.auto_control_mouse import set_position
@@ -13,12 +14,12 @@ def locate_all_image(image, detect_threshold: float = 1, draw_image: bool = Fals
"""
try:
image_data_array = template_detection.find_image_multi(image, detect_threshold, draw_image)
- except Exception:
- raise ImageNotFoundException(exception_tag.find_image_error_variable)
+ except ImageNotFoundException:
+ raise ImageNotFoundException(find_image_error_variable)
if image_data_array[0] is True:
return image_data_array[1]
else:
- raise ImageNotFoundException(exception_tag.cant_find_image)
+ raise ImageNotFoundException(cant_find_image)
def locate_image_center(image, detect_threshold: float = 1, draw_image: bool = False):
@@ -29,15 +30,15 @@ def locate_image_center(image, detect_threshold: float = 1, draw_image: bool = F
"""
try:
image_data_array = template_detection.find_image(image, detect_threshold, draw_image)
- except Exception:
- raise ImageNotFoundException(exception_tag.find_image_error_variable)
+ except ImageNotFoundException:
+ raise ImageNotFoundException(find_image_error_variable)
if image_data_array[0] is True:
height = image_data_array[1][2] - image_data_array[1][0]
width = image_data_array[1][3] - image_data_array[1][1]
center = [int(height / 2), int(width / 2)]
return [image_data_array[1][0] + center[0], image_data_array[1][1] + center[1]]
else:
- raise ImageNotFoundException(exception_tag.cant_find_image)
+ raise ImageNotFoundException(cant_find_image)
def locate_and_click(image, mouse_keycode: int, detect_threshold: float = 1, draw_image: bool = False):
@@ -49,8 +50,8 @@ def locate_and_click(image, mouse_keycode: int, detect_threshold: float = 1, dra
"""
try:
image_data_array = template_detection.find_image(image, detect_threshold, draw_image)
- except Exception:
- raise ImageNotFoundException(exception_tag.find_image_error_variable)
+ except ImageNotFoundException:
+ raise ImageNotFoundException(find_image_error_variable)
if image_data_array[0] is True:
height = image_data_array[1][2] - image_data_array[1][0]
width = image_data_array[1][3] - image_data_array[1][1]
@@ -61,4 +62,4 @@ def locate_and_click(image, mouse_keycode: int, detect_threshold: float = 1, dra
click_mouse(mouse_keycode)
return [image_center_x, image_center_y]
else:
- raise ImageNotFoundException(exception_tag.cant_find_image)
+ raise ImageNotFoundException(cant_find_image)
diff --git a/je_auto_control/wrapper/auto_control_keyboard.py b/je_auto_control/wrapper/auto_control_keyboard.py
index 99779af..e1b59d0 100644
--- a/je_auto_control/wrapper/auto_control_keyboard.py
+++ b/je_auto_control/wrapper/auto_control_keyboard.py
@@ -1,6 +1,12 @@
import sys
-from je_auto_control.utils.je_auto_control_exception import exception_tag
+from je_auto_control.utils.je_auto_control_exception.exception_tag import keyboard_hotkey
+from je_auto_control.utils.je_auto_control_exception.exception_tag import keyboard_press_key
+from je_auto_control.utils.je_auto_control_exception.exception_tag import keyboard_release_key
+from je_auto_control.utils.je_auto_control_exception.exception_tag import keyboard_type_key
+from je_auto_control.utils.je_auto_control_exception.exception_tag import keyboard_write
+from je_auto_control.utils.je_auto_control_exception.exception_tag import keyboard_write_cant_find
+from je_auto_control.utils.je_auto_control_exception.exception_tag import table_cant_find_key
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlCantFindKeyException
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlKeyboardException
from je_auto_control.wrapper.platform_wrapper import keyboard
@@ -17,14 +23,14 @@ def press_key(keycode: int, is_shift: bool = False):
try:
keycode = keys_table.get(keycode)
except Exception:
- raise AutoControlCantFindKeyException(exception_tag.table_cant_find_key)
+ raise AutoControlCantFindKeyException(table_cant_find_key)
try:
if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]:
keyboard.press_key(keycode)
elif sys.platform in ["darwin"]:
keyboard.press_key(keycode, is_shift=is_shift)
except Exception:
- raise AutoControlKeyboardException(exception_tag.keyboard_press_key)
+ raise AutoControlKeyboardException(keyboard_press_key)
def release_key(keycode: int, is_shift: bool = False):
@@ -36,14 +42,14 @@ def release_key(keycode: int, is_shift: bool = False):
try:
keycode = keys_table.get(keycode)
except Exception:
- raise AutoControlCantFindKeyException(exception_tag.table_cant_find_key)
+ raise AutoControlCantFindKeyException(table_cant_find_key)
try:
if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]:
keyboard.release_key(keycode)
elif sys.platform in ["darwin"]:
keyboard.release_key(keycode, is_shift=is_shift)
except Exception:
- raise AutoControlKeyboardException(exception_tag.keyboard_release_key)
+ raise AutoControlKeyboardException(keyboard_release_key)
def type_key(keycode: int, is_shift: bool = False):
@@ -55,7 +61,7 @@ def type_key(keycode: int, is_shift: bool = False):
press_key(keycode, is_shift)
release_key(keycode, is_shift)
except AutoControlKeyboardException:
- raise AutoControlKeyboardException(exception_tag.keyboard_type_key)
+ raise AutoControlKeyboardException(keyboard_type_key)
def check_key_is_press(keycode: int):
@@ -80,11 +86,11 @@ def write(write_string: str, is_shift: bool = False):
if keys_table.get(single_string) is not None:
type_key(single_string, is_shift)
else:
- raise AutoControlKeyboardException
+ raise AutoControlKeyboardException(keyboard_write_cant_find)
except AutoControlKeyboardException:
- print(exception_tag.keyboard_write_cant_find + " : " + single_string, file=sys.stderr)
+ print(keyboard_write_cant_find, single_string, sep="\t", file=sys.stderr)
except AutoControlKeyboardException:
- raise AutoControlKeyboardException(exception_tag.keyboard_write)
+ raise AutoControlKeyboardException(keyboard_write)
def hotkey(key_code_list: list, is_shift: bool = False):
@@ -99,4 +105,4 @@ def hotkey(key_code_list: list, is_shift: bool = False):
for key in key_code_list:
release_key(key, is_shift)
except AutoControlKeyboardException:
- raise AutoControlKeyboardException(exception_tag.keyboard_hotkey)
+ raise AutoControlKeyboardException(keyboard_hotkey)
diff --git a/je_auto_control/wrapper/auto_control_mouse.py b/je_auto_control/wrapper/auto_control_mouse.py
index e1d6351..3937dd4 100644
--- a/je_auto_control/wrapper/auto_control_mouse.py
+++ b/je_auto_control/wrapper/auto_control_mouse.py
@@ -1,6 +1,9 @@
import sys
-from je_auto_control.utils.je_auto_control_exception import exception_tag
+from je_auto_control.utils.je_auto_control_exception.exception_tag import mouse_click_mouse
+from je_auto_control.utils.je_auto_control_exception.exception_tag import mouse_press_mouse
+from je_auto_control.utils.je_auto_control_exception.exception_tag import mouse_release_mouse
+from je_auto_control.utils.je_auto_control_exception.exception_tag import mouse_set_position
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlCantFindKeyException
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlMouseException
from je_auto_control.wrapper.auto_control_screen import size
@@ -16,7 +19,7 @@ def position():
try:
return mouse.position()
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_get_position)
+ raise AutoControlMouseException(mouse_get_position)
def set_position(x: int, y: int):
@@ -27,7 +30,7 @@ def set_position(x: int, y: int):
try:
mouse.set_position(x=x, y=y)
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_set_position)
+ raise AutoControlMouseException(mouse_set_position)
def press_mouse(mouse_keycode: int, x: int = None, y: int = None):
@@ -39,7 +42,7 @@ def press_mouse(mouse_keycode: int, x: int = None, y: int = None):
try:
mouse_keycode = mouse_table.get(mouse_keycode)
except Exception:
- raise AutoControlCantFindKeyException(exception_tag.table_cant_find_key)
+ raise AutoControlCantFindKeyException(table_cant_find_key)
try:
now_x, now_y = position()
if x is None:
@@ -51,7 +54,7 @@ def press_mouse(mouse_keycode: int, x: int = None, y: int = None):
elif sys.platform in ["darwin"]:
mouse.press_mouse(x, y, mouse_keycode)
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_press_mouse)
+ raise AutoControlMouseException(mouse_press_mouse)
def release_mouse(mouse_keycode: int, x: int = None, y: int = None):
@@ -63,7 +66,7 @@ def release_mouse(mouse_keycode: int, x: int = None, y: int = None):
try:
mouse_keycode = mouse_table.get(mouse_keycode)
except Exception:
- raise AutoControlCantFindKeyException(exception_tag.table_cant_find_key)
+ raise AutoControlCantFindKeyException(table_cant_find_key)
try:
now_x, now_y = position()
if x is None:
@@ -71,14 +74,14 @@ def release_mouse(mouse_keycode: int, x: int = None, y: int = None):
if y is None:
y = now_y
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_get_position)
+ raise AutoControlMouseException(mouse_get_position)
try:
if sys.platform in ["win32", "cygwin", "msys", "linux", "linux2"]:
mouse.release_mouse(mouse_keycode)
elif sys.platform in ["darwin"]:
mouse.release_mouse(x, y, mouse_keycode)
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_release_mouse)
+ raise AutoControlMouseException(mouse_release_mouse)
def click_mouse(mouse_keycode: int, x: int = None, y: int = None):
@@ -90,7 +93,7 @@ def click_mouse(mouse_keycode: int, x: int = None, y: int = None):
try:
mouse_keycode = mouse_table.get(mouse_keycode)
except Exception:
- raise AutoControlCantFindKeyException(exception_tag.table_cant_find_key)
+ raise AutoControlCantFindKeyException(table_cant_find_key)
try:
now_x, now_y = position()
if x is None:
@@ -98,11 +101,11 @@ def click_mouse(mouse_keycode: int, x: int = None, y: int = None):
if y is None:
y = now_y
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_get_position)
+ raise AutoControlMouseException(mouse_get_position)
try:
mouse.click_mouse(mouse_keycode, x, y)
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_click_mouse)
+ raise AutoControlMouseException(mouse_click_mouse)
def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: str = "scroll_down"):
@@ -119,7 +122,7 @@ def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: st
try:
now_cursor_x, now_cursor_y = position()
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_get_position)
+ raise AutoControlMouseException(mouse_get_position)
width, height = size()
if x is None:
x = now_cursor_x
@@ -144,4 +147,4 @@ def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: st
scroll_direction = special_table.get(scroll_direction)
mouse.scroll(scroll_value, scroll_direction)
except Exception:
- raise AutoControlMouseException(exception_tag.mouse_click_mouse)
+ raise AutoControlMouseException(mouse_click_mouse)
diff --git a/je_auto_control/wrapper/auto_control_record.py b/je_auto_control/wrapper/auto_control_record.py
index 807d63a..5c2f2b3 100644
--- a/je_auto_control/wrapper/auto_control_record.py
+++ b/je_auto_control/wrapper/auto_control_record.py
@@ -1,15 +1,13 @@
import sys
from je_auto_control.utils.action_executer.action_execute import execute_action
+from je_auto_control.utils.je_auto_control_exception.exception_tag import macos_record_error
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlJsonActionException
from je_auto_control.wrapper.auto_control_keyboard import type_key
from je_auto_control.wrapper.auto_control_mouse import click_mouse
from je_auto_control.wrapper.platform_wrapper import recorder
-from je_auto_control.utils.je_auto_control_exception.exception_tag import macos_record_error
-
-
event_dict = {"mouse_left": "click_mouse", "mouse_right": "click_mouse", "mouse_middle": "click_mouse",
"keyboard": "type_key"}
@@ -57,6 +55,7 @@ def stop_record():
if __name__ == "__main__":
record()
from time import sleep
+
sleep(5)
stop_record()
sleep(2)
diff --git a/je_auto_control/wrapper/auto_control_screen.py b/je_auto_control/wrapper/auto_control_screen.py
index 282f105..f0378c3 100644
--- a/je_auto_control/wrapper/auto_control_screen.py
+++ b/je_auto_control/wrapper/auto_control_screen.py
@@ -1,9 +1,9 @@
import cv2
import numpy as np
-from cv2 import cvtColor
from je_auto_control.utils.image.screenshot import pil_screenshot
-from je_auto_control.utils.je_auto_control_exception import exception_tag
+from je_auto_control.utils.je_auto_control_exception.exception_tag import screen_get_size
+from je_auto_control.utils.je_auto_control_exception.exception_tag import screen_screenshot
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlScreenException
from je_auto_control.wrapper.platform_wrapper import screen
@@ -15,10 +15,10 @@ def size():
try:
return screen.size()
except AutoControlScreenException:
- raise AutoControlScreenException(exception_tag.screen_get_size)
+ raise AutoControlScreenException(screen_get_size)
-def screenshot(file_path: str = None, region:list = None):
+def screenshot(file_path: str = None, region: list = None):
"""
:param file_path screenshot file save path
:param region screenshot region
@@ -26,4 +26,4 @@ def screenshot(file_path: str = None, region:list = None):
try:
return cv2.cvtColor(np.array(pil_screenshot(file_path=file_path, region=region)), cv2.COLOR_RGB2BGR)
except AutoControlScreenException:
- raise AutoControlScreenException(exception_tag.screen_screenshot)
+ raise AutoControlScreenException(screen_screenshot)
diff --git a/setup.py b/setup.py
index 345964b..9d4eec3 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@
setuptools.setup(
name="je_auto_control",
- version="0.0.51",
+ version="0.0.64",
author="JE-Chen",
author_email="zenmailman@gmail.com",
description="auto testing",