PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:How do you send keypresses (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:How do you send keypresses
#1226
MB777 (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
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.
#1234
kksou (Admin)
Admin
Posts: 443
graph
User Online Now Click here to see the profile of this user
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.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved