LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-25-2003, 05:50 AM   #1
seidren
Member
 
Registered: May 2003
Distribution: Ubuntu, Windows XP
Posts: 90

Rep: Reputation: 16
Question 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!!!!
 
Old 10-25-2003, 06:59 AM   #2
vanquisher
Member
 
Registered: Aug 2003
Location: Hyderabad, India
Posts: 126

Rep: Reputation: 15
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?
 
Old 10-25-2003, 10:48 PM   #3
seidren
Member
 
Registered: May 2003
Distribution: Ubuntu, Windows XP
Posts: 90

Original Poster
Rep: Reputation: 16
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 ???
 
Old 10-25-2003, 11:03 PM   #4
vanquisher
Member
 
Registered: Aug 2003
Location: Hyderabad, India
Posts: 126

Rep: Reputation: 15
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.
 
Old 10-27-2003, 10:40 AM   #5
Tafta
Member
 
Registered: Jan 2003
Location: Bandung, Indonesia
Distribution: Mandrake, SUSE, RedHat
Posts: 55

Rep: Reputation: 15
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 ?
 
Old 10-28-2003, 06:24 AM   #6
seidren
Member
 
Registered: May 2003
Distribution: Ubuntu, Windows XP
Posts: 90

Original Poster
Rep: Reputation: 16
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get keystrokes w/o ncurses dogpatch Programming 6 11-27-2005 10:03 PM
Sending keystrokes to a gui lm317t Programming 3 10-11-2005 06:17 PM
Sending Keystrokes lm317t Linux - Software 0 10-10-2005 04:02 PM
Trapping keystrokes in C k4zau Programming 3 03-09-2003 01:13 PM
Second Terminal Keystrokes Guinney Linux - Newbie 2 11-29-2002 08:18 PM


All times are GMT -5. The time now is 09:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration