Skip to main content

Python module to control the ch9329

Project description

pych9329

Python module to control ch9329

Installation

You can install the package via pip:

pip install pych9329

Usage

Quick start

import time

from serial import Serial

from pych9329 import chip_command
from pych9329 import keyboard
from pych9329 import mouse


def main():
    ser = Serial("COM10", 9600, timeout=0.5)

    # Receive the keyboard lock status
    result, kb_status = keyboard.receive_indicator_status(ser)
    if result:
        # {'usb_connect_status': True, 'num_lock': True, 'caps_lock': False, 'scroll_lock': False}
        print(kb_status)
        # Automatically turn off caps_lock
        if kb_status["caps_lock"]:
            keyboard.click(ser, "caps_lock")

    # Click the "Win + D" key combination
    # First press the 2 buttons at the same time
    # For optional parameters of modifiers, please refer to keyboard.MODIFIER_KEY_NAME_MAP
    keyboard.trigger(ser, ["D"], ["win"])
    # Usually there is a 10 millisecond interval between pressing a key and popping it up.
    # Simulate this behavior with sleep
    time.sleep(0.1)
    # Pop up all keys
    keyboard.trigger(ser, [""], [""])

    # Click a single key
    keyboard.click(ser, "a")
    keyboard.click(ser, "A")
    # Send text
    keyboard.send_text(ser, "\n")
    keyboard.send_text(ser, "Hello World\n")
    keyboard.send_text(ser, "abcdefghijklmnopqrstuvwxyz\n")
    keyboard.send_text(ser, "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n")
    keyboard.send_text(ser, "0123456789\n")
    keyboard.send_text(ser, "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\n")

    # Move the mouse
    mouse.move(ser, x=500, y=500)
    mouse.move(ser, x=50, y=50, relative_mode=True)
    # Click a button
    # For supported key names, please see mouse.MOUSE_BUTTON_NAME_MAP
    mouse.click(ser, button_name="left")

    # 2019A152BB40
    print(chip_command.get_serial_number(ser))
    # WCH UART TO KB-MS_V1.8
    print(chip_command.get_product(ser))
    # WWW.WCH.CN
    print(chip_command.get_manufacturer(ser))

    ser.close()


if __name__ == "__main__":
    main()

Example

More example please check the example directory.

License

MIT license.

Contributing

This project is modified from ch9329 library.

Thanks to the original author of the ch9329 library Pradish Bijukchhe

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pych9329-0.1.6.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pych9329-0.1.6-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file pych9329-0.1.6.tar.gz.

File metadata

  • Download URL: pych9329-0.1.6.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.1 Windows/11

File hashes

Hashes for pych9329-0.1.6.tar.gz
Algorithm Hash digest
SHA256 df7ec82764474c536f0d052582eafdc866700e510a4534280deb6f419a15b8f4
MD5 143e2b5de253ab5868ceb45c22228549
BLAKE2b-256 43dc03ffb2c55ecb4fd38c823f3ee13708f4297d59a115ebbab96ff68585e78e

See more details on using hashes here.

File details

Details for the file pych9329-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pych9329-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.1 Windows/11

File hashes

Hashes for pych9329-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 752a219ea4e6a0cbcf1cb62b16fda65346dd024bfaf7923bac0e3529990df54b
MD5 71d1bf41f3179aef2ae594dba69018cf
BLAKE2b-256 5f5e360112e589fc17538a1c869abae71127fa2a7b30002ff0a3fa5ca547cb81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page