Skip to content

Commit

Permalink
feat/docs: remove keyboard.write
Browse files Browse the repository at this point in the history
- This is removed because it is very reliant on the current selected keyboard layout. For example, writing `@` may work fine on the US keyboard layout but not on the UK keyboard layout
  • Loading branch information
winstxnhdw committed Jul 3, 2024
1 parent 81357fa commit deaad24
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 93 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ keyboard.press(0x0D)
keyboard.press(0x5B, 0x44)
```

#### String Inputs

`KeyWin` can also convert strings to key codes, albeit at a slight performance cost.

```python
from keywin import keyboard

keyboard.write('Hello World!')
```

### Mouse

Similar to the keyboard, `KeyWin` provides a low-level API for mouse inputs based on Microsoft's [MOUSEINPUT](https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-mouseinput) structure.
Expand Down
18 changes: 0 additions & 18 deletions keywin/keyboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from keywin.keyboard.utils import convert_to_key_code
from keywin.send_input import press_keyboard


Expand All @@ -17,20 +16,3 @@ def press(*keys: int) -> bool:
success (bool) : the success of the event
"""
return press_keyboard(keys)


def write(string: str) -> list[bool]:
"""
Summary
-------
high-level function to type a string
Parameters
----------
string (str) : string to type
Returns
-------
successes (list[bool]) : the success of the event(s)
"""
return [press(*key_codes) for key_codes in convert_to_key_code(string)]
6 changes: 0 additions & 6 deletions keywin/keyboard/exceptions/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions keywin/keyboard/utils/__init__.py

This file was deleted.

38 changes: 0 additions & 38 deletions keywin/keyboard/utils/convert_to_key_code.py

This file was deleted.

19 changes: 1 addition & 18 deletions tests/test_keywin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from keywin import KeyCodes
from keywin.keyboard import press
from keywin.keyboard.codes import Typables
from keywin.keyboard.utils import convert_to_key_code
from keywin.mouse import (
left_click,
left_press,
Expand All @@ -25,28 +23,13 @@
)


def test_convert_to_key_code():
"""
Summary
-------
test the `convert_to_key_code` function
"""
assert convert_to_key_code("a") == [[KeyCodes.VK_A]]
assert convert_to_key_code("A") == [[KeyCodes.VK_SHIFT, KeyCodes.VK_A]]
assert convert_to_key_code("Hello!") == [
[KeyCodes.VK_SHIFT, KeyCodes.VK_H],
[KeyCodes.VK_E, KeyCodes.VK_L, KeyCodes.VK_L, KeyCodes.VK_O],
[KeyCodes.VK_SHIFT, KeyCodes.VK_1],
]


def test_press():
"""
Summary
-------
test the `press` function
"""
assert all(press(*key_codes) for key_codes in Typables.table.values())
assert all(press(key) for key in KeyCodes.__dict__.values() if isinstance(key, int))


def test_mouse_helpers():
Expand Down

0 comments on commit deaad24

Please sign in to comment.