Registered Member
|
I need some help ...
This is my problem with kwin and 'xdotool' : I open kwrite ... then in konsole through 'wmctrl -lpx' I check kwrite's windowID is 0x05600015. Again in konsole, if I want to write a number (let's say 7) in kwrite I do the following : xdotool windowactivate 0x05600015 ; xdotool type "7" ... and the '7' is written. Now I am going to write a three lines script : #!/bin/bash ##################################################### xdotool windowactivate 0x05600015 ; xdotool type "7" I make the script executable ... and I run it ... ... ... and the '7' is written. Now through 'systemsettings' I define a custom shortcut which execute the previous script ... can you guess what is happening when I enter the custom shortcut ? ... kwrite's window gets activated (focused) ... but the '7' is NOT written. I have spent a whole day with no luck . Initially I didn't want to write any '7' nor entered hardcoded windowsIDs ... I planned to do some more interesting things, but I have simplified the problem the most ... and now I don't know what else I can try. By the way, I tried to debug adding 'set -x' to the script, but I don't know where can I check the output. Is there any kind of kwin's log where I can see any kind of warning or whatever ? Thank you very much. Ps.- I am running Kubuntu 13.04 amd64 (KDE 4.10.5) ... and 'xdotool' version 1:2.20110530.1-6 |
Administrator
|
Have you tried introducing a short sleep prior to attempting to active (and presumably focus) the window?
The shortcut may still be active - preventing the window from receiving focus, and resulting in the "7" disappearing into nowhere.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
Well ... things look better now.
It was certainly a sync problem ... Now my script mostly works ... and look like this : #!/bin/bash ######################################################################################## set -x xdotool windowactivate --sync 0x05600015 sleep 0.2 xdotool type "7" However I am still getting some problems ... about 10-20% of times kwrite window get no focus ... and the '7' is not written until I click over the window ... ... some other times it directly doesn't work ... I have tried to add a line after 'windowactivate' like this : xdotool windowfocus --sync 0x05600015 I have also tried to increase sleep time to 0.5 ... but I am not fully happy with the results yet ... To fine tune it I need to debug it and understand where the small remaining problems reside ... I need to understand what it's really happening ... I am very interested in checking the 'set -x' output ... Do you know where can I look at it ? Thank you ! |
|
The problem is that kglobalaccel reacts on keypresses (key the shortcut pressed, the window is activated though you didn't release it) and the fake type fails because of that.
You can also prepend "sleep 5" to both calls to test this (gives you enough time to release the keys for sure) -> try: xdotool windowactivate --sync 0x05600015 xdotool type --clearmodifiers "7" |
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar