Skip to content

send_keysequence_window() stops working after switching windows #23

Description

@hirnwunde

Hi folks,

sometimes my pythonscript stops working after switching windows with <Alt>-<Tab>.
This happens under DE Cinnamon, KDE Plasma and XFCE4.
When i use the same functionality at this point of time via commandline tool xdotool the keystrokes will be sended.
When i restart X completely (normal logout/hard <Ctrl>-<Alt>-<Backspace>) the script works again.

Maybe this is wine-related ... i send Keystrokes to a WoW-Window started with wine-4.12.1.r1.gaccf1895
There's also dxvk involved.

Honestly, i don't know what information you need to narrow down the error. here are some details:

  • Linux manjaro 4.19.69-1
  • X.Org X Server 1.20.5
  • X Protocol Version 11, Revision 0
  • libx11 1.6.8-1
  • xdotool 3.20160805.1-2
    xdotool usr/bin/xdotool
    xdotool usr/include/xdo.h
    xdotool usr/lib/libxdo.so
    xdotool usr/lib/libxdo.so.3
pip search libxdo
python-libxdo (0.1.2a1)  - Python bindings for libxdo
 INSTALLED: 0.1.2a1 (latest)

The script i use:

#!/usr/bin/env python3

from pynput import mouse
from xdo import Xdo
import threading

state = 0
thrCnt = 1
windowID = 0
objWin = object()

xdo = Xdo()

if windowID == 0:
    objWin = xdo.search_windows(
        winname=b'World of Warcraft', only_visible=True, require=True)
    windowID = objWin[0]
    print('First start. Set WinID to: ' + str(windowID))


def thread_Sendkey():
    global state
    global windowID
    global objWin

    while state == 1:
        xdo.send_keysequence_window(objWin[0], "2", 80000)


def on_click(x, y, button, pressed):
    global state
    global thrCnt
    v = button.value
    if pressed:
        if v == 8:
            if state == 0:
                thrCnt += 1
                print('start ' + str(thrCnt) + '...')
                x = threading.Thread(target=thread_Sendkey)
                x.start()  # start thread
                state = 1
            else:
                print('end\n---------------------------')
                state = 0


with mouse.Listener(on_click=on_click) as listenerm:
    listenerm.join()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions