Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Sending keys
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sat Jan 30, 2010 10:27 pm    Post subject: Sending keys Reply with quote

ive been searching for a way to send keys to a program, but whatever i try it wont work , all the methods will send the keys to notepad just fine but not the program im trying to get them to.
the program is a snes emulator , so i know its not protected in anyway.

i am doing this in c++.

any help would be great.
Back to top
View user's profile Send private message
Zurkei
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Nov 2007
Posts: 1132
Location: Makakilo, Hawaii

PostPosted: Sat Jan 30, 2010 10:44 pm    Post subject: Reply with quote

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
<3 MSDN <3
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Jan 30, 2010 10:55 pm    Post subject: Reply with quote

The Mormon wrote:
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
<3 MSDN <3


that's .NET
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sat Jan 30, 2010 11:01 pm    Post subject: Reply with quote

yeah ,im looking for c++ not .net
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jan 31, 2010 12:36 am    Post subject: Reply with quote

PostMessage / SendMessage
http://msdn.microsoft.com/en-us/library/ms644944%28VS.85%29.aspx
Back to top
View user's profile Send private message
Zurkei
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Nov 2007
Posts: 1132
Location: Makakilo, Hawaii

PostPosted: Sun Jan 31, 2010 12:55 am    Post subject: Reply with quote

My bad, wasn't thinking.
I searched google and I found this thread http://www.rohitab.com/discuss/index.php?showtopic=23656
Post 3 is what I found, ignore the second post.
It is using the keybd_event API
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Jan 31, 2010 1:39 am    Post subject: Reply with quote

Just use SendInput, easy
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sun Jan 31, 2010 10:22 pm    Post subject: Reply with quote

i have tried keybd_event and it doesnt send to snes9x, and i tried sendinput , and it was sending the keys to notepad but not snes9x .


EDIT________________________________
since i couldnt get anything to work properly i searched a little deeper and found that vista blocks sendinput(), and that it doesnt generate any errors either(which is why i couldnt figure out what was going wrong) , and so far i havent found a fix.

so if anyone has successfully used sendinput() on vista , please post how here.
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Mon Feb 01, 2010 8:47 pm    Post subject: Reply with quote

(i know double post , but its better than starting a new thread)

any ways , using this code to send keys

Code:
void Key ( int vk , BOOL bExtended)
{
  KEYBDINPUT  kb={0};
  INPUT    Input={0};
  // generate down
  if ( bExtended )
    kb.dwFlags  = KEYEVENTF_EXTENDEDKEY;
  kb.wVk  = vk; 
  Input.type  = INPUT_KEYBOARD;

  Input.ki  = kb;
  SendInput(1,&Input,sizeof(Input));

  // generate up
  ZeroMemory(&kb,sizeof(KEYBDINPUT));
  ZeroMemory(&Input,sizeof(INPUT));
  kb.dwFlags  =  KEYEVENTF_KEYUP;
  if ( bExtended )
    kb.dwFlags  |= KEYEVENTF_EXTENDEDKEY;

  kb.wVk    =  vk;
  Input.type  =  INPUT_KEYBOARD;
  Input.ki  =  kb;
  SendInput(1,&Input,sizeof(Input));
}


works only if im holding the key down (say 'c' which is jump for mario)
if im holding it down and its sent by the program then mario does jump . but if im not holding it down then he doesnt . so im thinking that the code for key down is wrong , while key up is fine and working.

so if you spot something wrong post it.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Feb 01, 2010 9:00 pm    Post subject: Reply with quote

you can do everything in 1 SendInput call fyi
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Mon Feb 01, 2010 10:22 pm    Post subject: Reply with quote

yeah , i know that , but im pressing the keys based on a generated string from 0-9 , and its easier to just press the keys 1 at a time.

turns out its a directinput issue , and i have no idea where to go from here.

EDIT______________

maybe not , even sending keys using direct input scancodes doesnt work.

mario just wont fucking move. Crying or Very sad

any ideas?
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Sat Feb 06, 2010 4:22 pm    Post subject: Reply with quote

PostMessage, SendMessage

I suggest PostMessage cuz its faster
Back to top
View user's profile Send private message MSN Messenger
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sat Feb 06, 2010 4:46 pm    Post subject: Reply with quote

using post/send message i cant even get keys to send to notepad.

using spy++ i looked at what the keyboard was sending and what my program was sending (image below) and the scancodes are different.
also repeat for wm_char is 0f ?

im guessing that it matters?



ScanCode.jpg
 Description:
scancodes
 Filesize:  28.59 KB
 Viewed:  11743 Time(s)

ScanCode.jpg


Back to top
View user's profile Send private message
GiaBaoCT
How do I cheat?
Reputation: 0

Joined: 11 Sep 2009
Posts: 1

PostPosted: Wed Feb 10, 2010 12:37 am    Post subject: Reply with quote

How to send a key to a deactive window? some time we cant use SendMessage func (Online Games).
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Thu Feb 11, 2010 10:39 pm    Post subject: Reply with quote

@GiaBaoCT

SendInput() should work for you .

also bump.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites