-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1 @@ | ||
from .mouse import move_cursor_left | ||
from .proc import exit_process | ||
|
||
import logger | ||
|
||
|
||
def check(handler): | ||
test_cases = [ | ||
move_cursor_left, | ||
exit_process | ||
] | ||
|
||
num_of_case = len(test_cases) | ||
for i, case in enumerate(test_cases): | ||
if case(handler): | ||
logger.info("Case {}/{}: {} is successed.".format( | ||
i + 1, num_of_case, case.__name__)) | ||
else: | ||
logger.error("Case {}/{}: {} is failed.".format( | ||
i + 1, num_of_case, case.__name__)) | ||
from .check import check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import logger | ||
|
||
from . import mouse | ||
from . import proc | ||
|
||
|
||
def check(handler): | ||
test_cases = [] \ | ||
+ mouse.get_cases() \ | ||
+ proc.get_cases() | ||
|
||
num_of_case = len(test_cases) | ||
for i, case in enumerate(test_cases): | ||
if case(handler): | ||
logger.info("Case {}/{}: {} is successed.".format( | ||
i + 1, num_of_case, case.__name__)) | ||
else: | ||
logger.error("Case {}/{}: {} is failed.".format( | ||
i + 1, num_of_case, case.__name__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,54 @@ | ||
import pydirectinput as pdi | ||
from win import get_cursor_pos | ||
|
||
|
||
def get_cases(): | ||
return [ | ||
move_cursor_left, | ||
move_cursor_right, | ||
move_cursor_up, | ||
move_cursor_down | ||
] | ||
|
||
|
||
def move_cursor_left(handler): | ||
handler.send_command('<to_insert><ctrl-]>') | ||
|
||
x = pdi.position()[0] | ||
x = get_cursor_pos()[0] | ||
handler.send_command('h' * 100) | ||
delta = abs(pdi.position()[0] - x) | ||
delta = x - get_cursor_pos()[0] | ||
|
||
handler.send_command('<to_insert>') | ||
return delta > 0 | ||
|
||
|
||
def move_cursor_right(handler): | ||
handler.send_command('<to_insert><ctrl-]>') | ||
|
||
x = get_cursor_pos()[0] | ||
handler.send_command('l' * 100) | ||
delta = get_cursor_pos()[0] - x | ||
|
||
handler.send_command('<to_insert>') | ||
return delta > 0 | ||
|
||
|
||
def move_cursor_up(handler): | ||
handler.send_command('<to_insert><ctrl-]>') | ||
|
||
y = get_cursor_pos()[1] | ||
handler.send_command('k' * 100) | ||
delta = y - get_cursor_pos()[1] | ||
|
||
handler.send_command('<to_insert>') | ||
return delta > 0 | ||
|
||
|
||
def move_cursor_down(handler): | ||
handler.send_command('<to_insert><ctrl-]>') | ||
|
||
y = get_cursor_pos()[1] | ||
handler.send_command('j' * 100) | ||
delta = get_cursor_pos()[1] - y | ||
|
||
handler.send_command('<to_insert>') | ||
return delta > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pydirectinput as pdi | ||
|
||
|
||
def get_cursor_pos(): | ||
return pdi.position() |