LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Sending Keystrokes to a window (https://www.linuxquestions.org/questions/programming-9/sending-keystrokes-to-a-window-108286/)

seidren 10-25-2003 05:50 AM

Sending Keystrokes to a window
 
I want to know if there is any way to send a set of keystrokes to a window

I was working on a Sokoban Solution Generator and some of the solutions are too long for me to read and enter. So I want to just send the corresponding keystrokes to the window (Left key for left etc...).

In Windows I could have done this through the SendKeys function, I searched all over the net and only found the program 'expect' which works only for consoles.

Could some one please help me!!!!

vanquisher 10-25-2003 06:59 AM

never heard of Sokobon Solution generator...but you want to capture key strokes from a console program, you may want to check out ncurses...i've done some ncurses with C...you have them for perl and php too...if it's a GUI, use Qt...I don't think I understood ur problem clearly...so, can you please explain?

seidren 10-25-2003 10:48 PM

Well, let me explain a bit more.

I have been playing KSokoban for quite a while and now as the levels are getting harder for me, I decided to make a program which would read a Sokoban Map and then work through it and provide a solution.

I was successful at this. It works fine. It gives the shortest possible move. If anyone want the source code then mail me.

The problem comes when the map is pretty complex and the solution is quite long. It is hard to folow the solution as it is a series of Lefts, Rights Ups and Downs. A typical solution could end up with more than 200 such moves.

What I want to do is to take this series of moves and send them as keystrokes to the KSokoban application. Then when i send a left keystroke the player in the KSokoban game will move left thinking that I pressed the left key. (get it !!!!!).

There should be some way to do this, like sending a key press event to the KSokoban window or something similar.

Can anyone help me out with this please ???

vanquisher 10-25-2003 11:03 PM

Oh...then I clearly misunderstood your problem. sorry about that and sorry I can't help you. But I'd like to see the code you wrote for that game. Levels in Sokobon are getting pretty tough for me and even I wanted to write a program for auto-play. My mail id is vanquisher@coolgoose.com. Happy Hacking.

Tafta 10-27-2003 10:40 AM

That's cool Seidren. Can you please mail me the code. My mail is : zamrud_8@yahoo.com, or do you have your own web page some where ?

seidren 10-28-2003 06:24 AM

No, I dont have a webpage. I'll tell you when I make one.
I have sent the code to you. Use KDevelop3 to check it out.

Try to improve it if you can.


All times are GMT -5. The time now is 05:25 AM.