#
"""
Simple example on how to send simple reports based on usages
"""
import pywinusb.hid as hid

def click_signal(target_usage, target_vendor_id):
    """This function will find a particular target_usage over output reports on
    target_vendor_id related devices, then it will flip the signal to simulate
    a 'click' event"""
    # usually you'll find and open the target device, here we'll browse for the
    # current connected devices
    all_devices = hid.HidDeviceFilter(vendor_id = target_vendor_id).get_devices()

    if not all_devices:
        print("Can't find target device (vendor_id = 0x%04x)!" % target_vendor_id)
    else:
        # search for our target usage
        # target pageId, usageId

        for device in all_devices:
            try:
                device.open()
                # browse output reports, we could search over feature reports also,
                # changing find_output_reports() to find_feature_reports()
                for report in device.find_output_reports():
                    if target_usage in report:
                        # found out target!
                        report[target_usage] = 1 # yes, changing values is that easy
                        # at this point you could change different usages at a time...
                        # and finally send the prepared output report
                        report.send()
                        # now toggle back the signal
                        report[target_usage] = 0
                        report.send()
                        print("\nUsage clicked!\n")
                        return
            finally:
                device.close()
        print("The target device was found, but the requested usage does not exist!\n")
    #
if __name__ == '__main__':
    target_vendor_id = 0x16c0 # just an example, change it to the actual vendor_id
    target_usage = hid.get_full_usage_id(0xFFAB, 0x0270) # generic vendor page, usage_id = 2
    # go for it!
    click_signal(target_usage, target_vendor_id)
104ffbe0746da414b9c5a06c26250c719ba076d2
<mask token>

<mask token>


def click_signal(target_usage, target_vendor_id):
    """This function will find a particular target_usage over output reports on
    target_vendor_id related devices, then it will flip the signal to simulate
    a 'click' event"""
    all_devices = hid.HidDeviceFilter(vendor_id=target_vendor_id).get_devices()
    if not all_devices:
        print("Can't find target device (vendor_id = 0x%04x)!" %
            target_vendor_id)
    else:
        for device in all_devices:
            try:
                device.open()
                for report in device.find_output_reports():
                    if target_usage in report:
                        report[target_usage] = 1
                        report.send()
                        report[target_usage] = 0
                        report.send()
                        print('\nUsage clicked!\n')
                        return
            finally:
                device.close()
        print(
            'The target device was found, but the requested usage does not exist!\n'
            )


<mask token>

<mask token>


def click_signal(target_usage, target_vendor_id):
    """This function will find a particular target_usage over output reports on
    target_vendor_id related devices, then it will flip the signal to simulate
    a 'click' event"""
    all_devices = hid.HidDeviceFilter(vendor_id=target_vendor_id).get_devices()
    if not all_devices:
        print("Can't find target device (vendor_id = 0x%04x)!" %
            target_vendor_id)
    else:
        for device in all_devices:
            try:
                device.open()
                for report in device.find_output_reports():
                    if target_usage in report:
                        report[target_usage] = 1
                        report.send()
                        report[target_usage] = 0
                        report.send()
                        print('\nUsage clicked!\n')
                        return
            finally:
                device.close()
        print(
            'The target device was found, but the requested usage does not exist!\n'
            )


if __name__ == '__main__':
    target_vendor_id = 5824
    target_usage = hid.get_full_usage_id(65451, 624)
    click_signal(target_usage, target_vendor_id)

<mask token>
import pywinusb.hid as hid


def click_signal(target_usage, target_vendor_id):
    """This function will find a particular target_usage over output reports on
    target_vendor_id related devices, then it will flip the signal to simulate
    a 'click' event"""
    all_devices = hid.HidDeviceFilter(vendor_id=target_vendor_id).get_devices()
    if not all_devices:
        print("Can't find target device (vendor_id = 0x%04x)!" %
            target_vendor_id)
    else:
        for device in all_devices:
            try:
                device.open()
                for report in device.find_output_reports():
                    if target_usage in report:
                        report[target_usage] = 1
                        report.send()
                        report[target_usage] = 0
                        report.send()
                        print('\nUsage clicked!\n')
                        return
            finally:
                device.close()
        print(
            'The target device was found, but the requested usage does not exist!\n'
            )


if __name__ == '__main__':
    target_vendor_id = 5824
    target_usage = hid.get_full_usage_id(65451, 624)
    click_signal(target_usage, target_vendor_id)

#
"""
Simple example on how to send simple reports based on usages
"""
import pywinusb.hid as hid

def click_signal(target_usage, target_vendor_id):
    """This function will find a particular target_usage over output reports on
    target_vendor_id related devices, then it will flip the signal to simulate
    a 'click' event"""
    # usually you'll find and open the target device, here we'll browse for the
    # current connected devices
    all_devices = hid.HidDeviceFilter(vendor_id = target_vendor_id).get_devices()

    if not all_devices:
        print("Can't find target device (vendor_id = 0x%04x)!" % target_vendor_id)
    else:
        # search for our target usage
        # target pageId, usageId

        for device in all_devices:
            try:
                device.open()
                # browse output reports, we could search over feature reports also,
                # changing find_output_reports() to find_feature_reports()
                for report in device.find_output_reports():
                    if target_usage in report:
                        # found out target!
                        report[target_usage] = 1 # yes, changing values is that easy
                        # at this point you could change different usages at a time...
                        # and finally send the prepared output report
                        report.send()
                        # now toggle back the signal
                        report[target_usage] = 0
                        report.send()
                        print("\nUsage clicked!\n")
                        return
            finally:
                device.close()
        print("The target device was found, but the requested usage does not exist!\n")
    #
if __name__ == '__main__':
    target_vendor_id = 0x16c0 # just an example, change it to the actual vendor_id
    target_usage = hid.get_full_usage_id(0xFFAB, 0x0270) # generic vendor page, usage_id = 2
    # go for it!
    click_signal(target_usage, target_vendor_id)