xdtools key to wine window when not active?

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
KennyDave
Newbie
Newbie
Posts: 1
Joined: Fri Oct 13, 2023 4:56 pm

xdtools key to wine window when not active?

Post by KennyDave »

I'm trying to send a keypress to a wine application (mediamonkey) using xdotools. No problem when the window is active, but when it isn't, the program doesn't accept the keypress. As per this note from 2015, I think.
But sending keystrokes to a specific window uses a different API than simply typing to the active window, and many applications just ignore them.
Is there a setting to enable wine to accept keypresses from xdotool when it is not active? Or am I on the wrong track? Has anyone managed to do this successfully with wine? It seems possible in the past, but now most programs don't seem to accept key presses when not focused.

My workaround which I haven't done yet is to flick focus to it, press the key and flick back. But that will make my screen flicker if I'm in a full screen app, or over mediamonkey, so not ideal.

This is my code at the moment for what it's worth, with a special key on my silly keyboard assigned to each option:

Code: Select all

#!/bin/sh
 
case $1 in
   "play")
       key="Control_L+P"
       ;;
   "next")
       key='Control_L+N'
       ;;
   "prev")
       key='Control_L+B'
       ;;
   "rand")
        key='Control_L+Shift_L+L'
       ;;
   *)
       echo "Usage: $0 play|next|prev|rand"
       exit 1
        ;;
esac
xdotool key --window $(xdotool search --name "MediaMonkey"|head -n1) $key
exit 0
Thank you if you can help; I'm learning as I go, it has taken me a while to get to this point and I may have got the wrong end of the stick with xdotool. Someone must have attempted this in the last 5 years though I think.
Locked