LPHK icon indicating copy to clipboard operation
LPHK copied to clipboard

Volume Controls Not Working on Mac

Open reggievick opened this issue 4 years ago • 15 comments

The volume controls are not working on Mac.

System Version: macOS 10.15.5 Script: TAP vol_up Log: ---------------- BEGIN LOG 15/07/2020 14:23:12 ---------------- LPHK - LaunchPad HotKey - A Novation Launchpad Macro Scripting System Version: 0.3.0 Platform: Macintosh Is compiled executable: False Is portable: True Operating path: /Users//downloads/LPHK-0.3.0 User path: /Users//downloads/LPHK-0.3.0 Program file path: /Users//downloads/LPHK-0.3.0 Program file: /Users//downloads/LPHK-0.3.0/LPHK.py Log file (this file): /Users//downloads/LPHK-0.3.0/LPHK.log

pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html

[scripts] (0, 7) No script running, starting script in background... [scripts] (0, 7) Now running script... [scripts] (0, 7) Tap key vol_up [scripts] (0, 7) Script done running.

reggievick avatar Jul 15 '20 20:07 reggievick

I'm sorry but I cannot fix this as I do not own a Mac, so we'll have to wait until someone that knows python and has a Mac comes along

duncte123 avatar Jul 15 '20 21:07 duncte123

I'm sorry but I cannot fix this as I do not own a Mac, so we'll have to wait until someone that knows python and has a Mac comes along

I think it's just sending the wrong keyboard signals since other keys work fine. What file would have the bindings for mac?

EDIT: Yes it appears to be an issue with pyautogui's keybindings. The following doesn't result in a volume up press, which i think is essentially what LPHK is using.

import pyautogui
pyautogui.press('volumeup')

reggievick avatar Jul 16 '20 15:07 reggievick

Could you try the same with pynput? https://pypi.org/project/pynput/

duncte123 avatar Jul 16 '20 19:07 duncte123

Could you try the same with pynput? https://pypi.org/project/pynput/

@duncte123 that worked! Not familiar enough with LPHK to implement this though.

from pynput.keyboard import Key, Controller keyboard = Controller() keyboard.press(Key.media_volume_up) ^[[A keyboard.release(Key.media_volume_up)

reggievick avatar Jul 16 '20 19:07 reggievick

I'm gonna try and replace pyautogiu with pynput for mac

duncte123 avatar Jul 16 '20 19:07 duncte123

Okay thanks, let me know if you need me to test anything.

reggievick avatar Jul 16 '20 19:07 reggievick

Could you test this PR and let me know if it works? https://github.com/nimaid/LPHK/pull/57

duncte123 avatar Aug 17 '20 11:08 duncte123

Could you test this PR and let me know if it works? #57

The volume controls are now working, but a previous script is now broken:

PRESS ctrl TAP 1 RELEASE ctrl

This should mimic ctrl+1 and switch to the first mac desktop, but isn't anymore. I will do some testing tonight to see what's wrong.

reggievick avatar Aug 17 '20 15:08 reggievick

try this script

@ASYNC
PRESS ctrl
PRESS 1
WAIT_UNPRESSED
RELEASE_ALL

9 out of 10 times TAP is too fast

duncte123 avatar Aug 17 '20 16:08 duncte123

no that didn't work either. I don't think the pynput "press" holds the key down. In their documentation you need a with block.

from pynpyt docs: with keyboard.pressed(Key.shift): keyboard.press('a') keyboard.release('a')

reggievick avatar Aug 17 '20 17:08 reggievick

Are you making sure that you are running as root and that the application is trusted as described here? https://pynput.readthedocs.io/en/latest/limitations.html#macos

duncte123 avatar Aug 18 '20 07:08 duncte123

Are you making sure that you are running as root and that the application is trusted as described here? https://pynput.readthedocs.io/en/latest/limitations.html#macos

I wasn't, but that didn't fix it. I'm pretty sure it's due to pynput's "press" function behaving like a tap of the key. So we are sending ctrl then 1 instead of ctrl+1. They require using a "with" block for key combos which would be very difficult to implement in your app i think.

What if you use pynput for only media keys, and pyautogui for the rest of the keys. It's not very elegant, but i believe it would fix the media keys, while preserving the current infrastructure for every other key.

reggievick avatar Aug 18 '20 12:08 reggievick

Then I'm not sure why there is a separate tap method https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Controller.tap

I'm gonna dig a bit in the source to figure this one out

duncte123 avatar Aug 18 '20 13:08 duncte123

Update: visiting pynput on github gave me this issue: https://github.com/moses-palmer/pynput/issues/297

duncte123 avatar Aug 18 '20 13:08 duncte123

The volume controls are not working on Mac.

System Version: macOS 10.15.5 Script: TAP vol_up Log: ---------------- BEGIN LOG 15/07/2020 14:23:12 ---------------- LPHK - LaunchPad HotKey - A Novation Launchpad Macro Scripting System Version: 0.3.0 Platform: Macintosh Is compiled executable: False Is portable: True Operating path: /Users//downloads/LPHK-0.3.0 User path: /Users//downloads/LPHK-0.3.0 Program file path: /Users//downloads/LPHK-0.3.0 Program file: /Users//downloads/LPHK-0.3.0/LPHK.py Log file (this file): /Users//downloads/LPHK-0.3.0/LPHK.log

pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html

[scripts] (0, 7) No script running, starting script in background... [scripts] (0, 7) Now running script... [scripts] (0, 7) Tap key vol_up [scripts] (0, 7) Script done running.

Hey there, I'm trying to use this program on mac, could you please describe how you managed to install it ?

Thanks and sorry for replying here I haven't found anything concerning mac os use. Best, Julien.

Shiro555 avatar Dec 09 '21 18:12 Shiro555