moses-palmer/pynput

MEDIA KEYS problem on windows 10

safaka123 opened this issue · 0 comments

When in debug mode, pyninput VOLUME UP and other multimedia keys work fine.
But when debug mode is not used, multimedia keys do not work. I gave a time delay but it still DOES NOT WORK.
The same applies to pyautogui.
You can see this in the video in the link.
I am using python 3.11 and visual studio code V1.91 windows 10

https://drive.google.com/file/d/1qPgqBMRqDTWmr4WTChsFp_3MefD2y5_n/view?usp=drive_link

MYprogram is:

import serial
from pynput.keyboard import Controller, KeyCode
from pynput.keyboard import Key
import pydirectinput # daha çok directx uyumlu oyunlar için kullanılabilir. diğerleri bunda sorunlu.
keyb = Controller()
ser = serial.Serial('COM1', 9600, timeout=.1)

time.sleep(5)

def volup(key):               #what to do if key pressed. takes value from handleJoyStickAsArrowKeys
    keyb.press(KeyCode.from_vk(0xAF))
    time.sleep(0.5)
    keyb.release(KeyCode.from_vk(0xAF))
    #keyb.tap(KeyCode.from_vk(0xAF))
    time.sleep(0.5)
    #keyb.tap(KeyCode.from_vk(0xAF))
    #pyautogui.press(key)  #runs pydirectinput using key from (argument)
    #print('UP: ', key)       #remove '#' from print to test data stream


while True:
    data=56
    #time.sleep(3)
    num = ser.readline()
    ser.reset_input_buffer() 
    #num=num[0:2]
    print(num)
    #num="SC186"
    datalen=num
    print(datalen)
    data2=len(datalen)
    if data2>4:
       num=num[0:4] 
       datalen=num
       print(datalen)
       data2=len(datalen)

    if data2>0:
        data3=int(datalen[2:data2])
    else:
        data3=0

    
    data=0
    databak=""
    if data2>0:
        print(data2)
        print (data3)
        print ("data3  ",data3)
        databak=("volumeup")
        #databak=komut_lookup[data3]
        print(" databak : ",databak)
        volup(databak)
        databak=""