Re:How do you send keypresses (1 viewing) (1) Guest
Favoured: 0
|
|
|
TOPIC: Re:How do you send keypresses
|
MB777 (User)
Fresh Boarder
Posts: 3
|
|
How do you send keypresses 1 Month, 1 Week ago
|
Karma: 0
|
|
Can you send keypresses with PHP-GTK?
I want to write an application for a game that automates some moves. I have used php to create the display, with sliders to control various key delays.
I want it so that when a user presses certain keys, it performs automatic moves. This involves sending keypresses. Can it be done?
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 443
|
|
Re:How do you send keypresses 1 Month ago
|
Karma: 8
|
|
For gtk+, it's possible to simiulate a keypress by emitting a GdkEvent manually. But for php-gtk, I haven't found a way yet.
However, for many applications, usually you will have a "key-press-event" signal handler to handle all the keypresses. For each keypress, you will have a corresponding action.
For example, suppose
keypress "a" corresponds to action_a()
keypress "b" corresponds to action_b()
keypress "c" corresponds to action_c()
Now if you want keypress "m" to be the same as keypress "a", followed by "b", and then "c". Instead of simulating keypress "a", "b" and "c", for signal handler of keypress "k", you can do a sample
function action_k() {
action_a();
action_b();
action_c();
}
I know it's a bit different from what you have in mind. But I think this method will work for most of the cases.
Regards,
/kksou
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
|