Shiny Doom Forum Forum Index Shiny Doom Forum
Forum content does NOT necessarily reflect the views of the Admins of this forum. Read at your own risk.
Doom doom doom doom doom doom doom doom DOOM doom doom doom
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help - Mouse to keyboard input converter???

 
Post new topic   Reply to topic    Shiny Doom Forum Forum Index -> Things of interest
View previous topic :: View next topic  
Author Message
rklee
Uber-Karma
Uber-Karma


Joined: 11 Sep 2003
Posts: 495
Location: Malvern, PA Pittsburgh, PA

PostPosted: Sun Oct 26, 2003 11:47 am    Post subject: Help - Mouse to keyboard input converter??? Reply with quote

I currently control my robot usiong terminal. 2 sets of 4 commands one for movements and one for camera pan tilt. Ideally I'd like to use a Counterstrike/Unreal type of control. using mouse to control camera and the keyboard to control the movement ( Ideally the forward movement will actually be a turning type of movement towards the direction of viewing..) but basically I Could do with just a programming running in the background that changes my mouse moivements to text... like if I move my mouse left it will output in terminal (as keybaord inputs) LLLLLLLLL or if it's right RRRRRRRRR or if it's left and tiny bit upwards LLTLLTLLTLLT....etc. If anyone can help let me know please.
_________________
"My Heart Is In the Work" - Andrew Carnegie
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Trool
Good Karma
Good Karma


Joined: 12 Sep 2003
Posts: 1486

PostPosted: Mon Oct 27, 2003 9:00 am    Post subject: Reply with quote

How r u talking to ur bot?? using hyperteminal or did u write ur own thing. What language r u doing this in also??

What i can suggest is u can probably use win api to pol mouse movements, but a more elegent way would be to set up a normal interupt type of things where on mouse move events u can send messages directly to the robot...But both win api and interupts are annoying to do and i think r slightly language spesific...
_________________
The most exciting phrase to hear in science, the one that heralds new discoveries, isn't 'Eureka!' but rather 'hmm....that's funny.'

--Isaac Asimov
Back to top
View user's profile Send private message Send e-mail AIM Address
rklee
Uber-Karma
Uber-Karma


Joined: 11 Sep 2003
Posts: 495
Location: Malvern, PA Pittsburgh, PA

PostPosted: Mon Oct 27, 2003 9:23 am    Post subject: Reply with quote

sorry, I mean I need the mouse text to appear as keyboard input in hyperterminal. I'm using hyperterminal. Sending asci text I believe.
_________________
"My Heart Is In the Work" - Andrew Carnegie
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Trool
Good Karma
Good Karma


Joined: 12 Sep 2003
Posts: 1486

PostPosted: Mon Oct 27, 2003 5:09 pm    Post subject: Reply with quote

ahh....i think that is doable, but i'll have to search for it....it might be just simpler to write ur own mini hyperterminal or get code from somewhere else for one and modify it to do what u want...but i'll check into sending events to the hyperterminal...i know u can do it since it's a normal window and has it's own ID...u can send events to it then...but i'm not sure if it's possible to find out the id...i'll check it out tomorrow if i get time...this is interesting now...lol
_________________
The most exciting phrase to hear in science, the one that heralds new discoveries, isn't 'Eureka!' but rather 'hmm....that's funny.'

--Isaac Asimov
Back to top
View user's profile Send private message Send e-mail AIM Address
Trool
Good Karma
Good Karma


Joined: 12 Sep 2003
Posts: 1486

PostPosted: Tue Oct 28, 2003 4:12 pm    Post subject: Reply with quote

I found something that might help....though i haven't been able to test this with hyperterminal since when your not connected to anything it doesn't show you if u press any keys, but this works with notepad and telnet fine...here's the code




using namespace std;

void main(){

char cMe;

HWND hWND;
HWND ed;


//this finds a handle to a window the first value is the window's class
//if null then all classes are searched, the second is I think what appears in
//the title bar of the window. You can have both or one of these parameters
hWND = FindWindowA("SESSION_WINDOW", NULL);

//check if got a handle to a screen
if(!hWND)
{
cout<<"WRONG HANDLE"< return;
}

//some programs have inner windows like things, for example notepad...i'm
//not totaly sure what this does, I'm not sure weather this new handle or the
//hWND handle is what you need to type to the terminal, it might be either
//so try compiling the PostMessage function with this handle first and if that
//doesn't work try it with the hWND instead
ed = FindWindowEx(hWND, 0, "Term Class", "");

//check if got a handle to a screen
if(!ed)
{
cout<"WRONG HANDLE"< return;
}
//this will actualy send the message, first param is the handle of the window u
//wana send the message to, second param is the type of message, in this case
//a character, the thrid param is the message, and the fourth i don't think
//is used
PostMessage(ed,WM_CHAR,'a',0);

//just to print out success and get one character so the prog doesn't die
//without displaying the message.
cout<"SUCCESS"< cin>>cMe;

}

This doesn't do anything with mouse movements, but it should send a character to something...this is normal c++ and it works for me when compiled with VS6.0 please test this and if it works i'll look into finding the mouse movement code...good luck hope this helps...
_________________
The most exciting phrase to hear in science, the one that heralds new discoveries, isn't 'Eureka!' but rather 'hmm....that's funny.'

--Isaac Asimov
Back to top
View user's profile Send private message Send e-mail AIM Address
rklee
Uber-Karma
Uber-Karma


Joined: 11 Sep 2003
Posts: 495
Location: Malvern, PA Pittsburgh, PA

PostPosted: Tue Oct 28, 2003 9:32 pm    Post subject: Reply with quote

sorry I don't understand this doesn't do mouse movements right? so it's a program that sends txt to another program?
_________________
"My Heart Is In the Work" - Andrew Carnegie
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Mogri
Uber-Karma
Uber-Karma


Joined: 12 Sep 2003
Posts: 535
Location: Malvern & Philadelphia, PA

PostPosted: Wed Oct 29, 2003 6:40 am    Post subject: Reply with quote

If you have a fancy mouse and install its software, you'll notice the mouse can emit keystrokes to any application. This is probably the best way to handle something like this, unless you know the inner-workings of hyperterminal, because sending it messages is probably a lot of trial and error. As to how to do either, I don't know. A Windows service is ideal, but I have no clue how to get a service to monitor mouse movements.
_________________
"A club without the right direction, is a misguided stick."
-- Master Wham
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Mogri
Uber-Karma
Uber-Karma


Joined: 12 Sep 2003
Posts: 535
Location: Malvern & Philadelphia, PA

PostPosted: Wed Oct 29, 2003 6:42 am    Post subject: Reply with quote

After looking at that C++ code, I think I know what it's trying to accomplish, but what handle is it trying to get? I know it's searching to acquire a window handle, but how do you specify which window you're looking for?
_________________
"A club without the right direction, is a misguided stick."
-- Master Wham
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Trool
Good Karma
Good Karma


Joined: 12 Sep 2003
Posts: 1486

PostPosted: Wed Oct 29, 2003 8:19 am    Post subject: Reply with quote

when u create a window u get to give is a class name and a title...if u launch spy++ that came with visual studio when u have stuff opened u'll get a huge list of everything that's running currently on the system, from task bars to buttons....with this system u can get access to every small button anywhere as long as u know it's class name or the title....it's pretty neat system that alows u to nicely hack just about anything...but this also has great advantages in testing...since u can send messages to anything u can write a little testing prog that will just keep sending messages to ur own program and see if any of the combinations keep crashing...windows is designed so that anything can easily talk to just about anything...i don't know how nice it is for security reasons, but it makes coding these kinds of apps pretty easy once u figure out how....that part took a bit....

The neat thing is if u launch spy++ u get to see just how much windows stuff is really open and running right this minute...it's a bit hard to read, but once u understand what each thing sais it's not so bad....btw it doesn't auto refresh so if u changed something u'll have to launch a new spy window within the prog...i think it does more then just that, but this is the basic thing i found about it online....

right now the prog i posted should just send 'a' to hyperterminal...i'm gona try to find a way to get hyperterminal to connect to something so i can test it better, but at the moment i can't...ohh well...
_________________
The most exciting phrase to hear in science, the one that heralds new discoveries, isn't 'Eureka!' but rather 'hmm....that's funny.'

--Isaac Asimov
Back to top
View user's profile Send private message Send e-mail AIM Address
Trool
Good Karma
Good Karma


Joined: 12 Sep 2003
Posts: 1486

PostPosted: Thu Oct 30, 2003 8:46 am    Post subject: Reply with quote

yay i found u some mouse code....this is a full prog that should write output to an opened notepad window...the hyperterminal code is commented out so if u wana write to hyperterminal just comment out the notepad code and uncomment the hyperteminal one...the one that gets handle to the windows...also if u need to make it more sensitive then just change the difference value needed inside the loop...hope all this helps good luck and tell me how it goes...








using namespace std;

void main(){

char cMe;

HWND hWND;
HWND ed;

POINT old_pos;
POINT cur_pos;

GetCursorPos(&old_pos);



//this finds a handle to a window the first value is the window's class
//if null then all classes are searched, the second is I think what appears in
//the title bar of the window. You can have both or one of these parameters

//------HYPER TERMINAL CODE--------------------------------------------
// hWND = FindWindowA("SESSION_WINDOW", NULL);
//---------------------------------------------------------------------
hWND = FindWindowA("Notepad", NULL);

//check if got a handle to a screen
if(!hWND)
{
cout<<"WRONG HANDLE"< return;
}

//some programs have inner windows like things, for example notepad...i'm
//not totaly sure what this does, I'm not sure weather this new handle or the
//hWND handle is what you need to type to the terminal, it might be either
//so try compiling the PostMessage function with this handle first and if that
//doesn't work try it with the hWND instead


//------HYPER TERMINAL CODE--------------------------------------------
// ed = FindWindowEx(hWND, 0, "Term Class", "");
//---------------------------------------------------------------------
ed = FindWindowEx(hWND, 0, "Edit", "");

//check if got a handle to a screen
if(!ed)
{
cout<"WRONG HANDLE"< return;
}
//this will actualy send the message, first param is the handle of the window u
//wana send the message to, second param is the type of message, in this case
//a character, the thrid param is the message, and the fourth i don't think
//is used
PostMessage(ed,WM_CHAR,'a',0);

while(TRUE){
GetCursorPos(&cur_pos);
if((cur_pos.x - old_pos.x) > 10)
PostMessage(ed,WM_CHAR,'r',0);
else if((cur_pos.x - old_pos.x) < -10)
PostMessage(ed,WM_CHAR,'l',0);

if((cur_pos.y - old_pos.y) > 10)
PostMessage(ed,WM_CHAR,'d',0);
else if((cur_pos.y - old_pos.y) < -10)
PostMessage(ed,WM_CHAR,'u',0);
old_pos = cur_pos;
}

//just to print out success and get one character so the prog doesn't die
//without displaying the message.
cout<<"SUCCESS"< cin>>cMe;

}
_________________
The most exciting phrase to hear in science, the one that heralds new discoveries, isn't 'Eureka!' but rather 'hmm....that's funny.'

--Isaac Asimov


Last edited by Trool on Fri Oct 31, 2003 7:43 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail AIM Address
rklee
Uber-Karma
Uber-Karma


Joined: 11 Sep 2003
Posts: 495
Location: Malvern, PA Pittsburgh, PA

PostPosted: Fri Oct 31, 2003 1:43 am    Post subject: Reply with quote

What language is this in? could I get a compiled version also?
_________________
"My Heart Is In the Work" - Andrew Carnegie
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Mogri
Uber-Karma
Uber-Karma


Joined: 12 Sep 2003
Posts: 535
Location: Malvern & Philadelphia, PA

PostPosted: Fri Oct 31, 2003 6:46 am    Post subject: Reply with quote

Looks like a standard C++ program. Stick it in VS6 and compile. You may also like to go into the edit screen of the post because things within < and > appear to be censored in the message board (i.e. < windows.h >).

It compiles and works for me. If you need a compiled version, let me know.

You may also want to take out the 10-pixel margin in detecting mouse movement (i.e. instead of lines such as if((cur_pos.y - old_pos.y) > 10), simply detect if cur_pos is different than old_pos).

The only draw back is that while loop... which will take 100% of available processor time.
_________________
"A club without the right direction, is a misguided stick."
-- Master Wham
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Trool
Good Karma
Good Karma


Joined: 12 Sep 2003
Posts: 1486

PostPosted: Fri Oct 31, 2003 7:44 am    Post subject: Reply with quote

thnks for pointing out my lack of <> i fixed that...Morgi's right this is just c++ and u can make is in vs6.0 I can probably also find a more event driven version of this if u find that this takes over ur processor too much, but this was a good test to see if u can send to hyperterminal and if i got the class names right or not...
_________________
The most exciting phrase to hear in science, the one that heralds new discoveries, isn't 'Eureka!' but rather 'hmm....that's funny.'

--Isaac Asimov
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Shiny Doom Forum Forum Index -> Things of interest All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group