2010/1/18 koniu <[email protected]>:
> On Sat, Jan 16, 2010 at 19:43, Sergey Mironov <[email protected]> wrote:
>> Hi. Could anybody expose some examples for fake_input() function?
>> I'd like to carry out an experiment with macros replaying. I want to
>> send series of key press events (with Ctrl and Shift, please) to
>> specific client, but seems, that wiki and maillist know nothing about
>> it.
>
> You can only send events to the client in focus. You can have a look
> at 'fake input' section here:
> http://github.com/koniu/awesome-configs/blob/master/functions.lua
>
> eg. sendkey{105,36} will send ctrl+return to the client (keycodes
> taken from xev).
>
> hope that helps
> koniu
>
> --
> To unsubscribe, send mail to [email protected].
>
Thanks for sample! I confirm, that fake_input works, but still there are some
strange things for me. I listed 2 cases below. By the way, why do you use timers
with fake_input() ? Is it some kind of workaround or just application logic ?
1. NOT working code
===================
Seems, that 2 calls to fake_input somehow 'annihilate' each other.
function sendkey(code, m)
-- Note: i've tried other windows too, it all the same.
if client.focus.class ~= "Evince" then
return
end
root.fake_input("key_press", code)
root.fake_input("key_release", code)
end
globalkeys = awful.util.table.join(
awful.key({ modkey }, "t", function () sendkey(99) end), -- 99 is code
of PgUp
... and so on
)
2. Working code
===============
This one works. Note exactly 1 call to fake_input
function sendkey(code)
if client.focus.class ~= "Evince" then
return
end
root.fake_input("key_release", code)
end
globalkeys = awful.util.table.join(
awful.key({ modkey }, "t", function () sendkey(99) end, -- 99 is code
of PgUp
... and so on
)
--
Thanks,
Sergey
--
To unsubscribe, send mail to [email protected].