View previous topic :: View next topic |
Author |
Message |
rooski Master Cheater
Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Sat Jan 30, 2010 10:27 pm Post subject: Sending keys |
|
|
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 |
|
 |
Zurkei Grandmaster Cheater Supreme
Reputation: 0
Joined: 15 Nov 2007 Posts: 1132 Location: Makakilo, Hawaii
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat Jan 30, 2010 10:55 pm Post subject: |
|
|
The Mormon wrote: | http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
<3 MSDN <3 |
that's .NET
|
|
Back to top |
|
 |
rooski Master Cheater
Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Sat Jan 30, 2010 11:01 pm Post subject: |
|
|
yeah ,im looking for c++ not .net
|
|
Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
Back to top |
|
 |
Zurkei Grandmaster Cheater Supreme
Reputation: 0
Joined: 15 Nov 2007 Posts: 1132 Location: Makakilo, Hawaii
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Jan 31, 2010 1:39 am Post subject: |
|
|
Just use SendInput, easy
|
|
Back to top |
|
 |
rooski Master Cheater
Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Sun Jan 31, 2010 10:22 pm Post subject: |
|
|
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 |
|
 |
rooski Master Cheater
Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Mon Feb 01, 2010 8:47 pm Post subject: |
|
|
(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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Feb 01, 2010 9:00 pm Post subject: |
|
|
you can do everything in 1 SendInput call fyi
|
|
Back to top |
|
 |
rooski Master Cheater
Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Mon Feb 01, 2010 10:22 pm Post subject: |
|
|
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.
any ideas?
|
|
Back to top |
|
 |
iPromise Grandmaster Cheater
Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Sat Feb 06, 2010 4:22 pm Post subject: |
|
|
PostMessage, SendMessage
I suggest PostMessage cuz its faster
|
|
Back to top |
|
 |
rooski Master Cheater
Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Sat Feb 06, 2010 4:46 pm Post subject: |
|
|
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?
Description: |
|
Filesize: |
28.59 KB |
Viewed: |
11746 Time(s) |

|
|
|
Back to top |
|
 |
GiaBaoCT How do I cheat?
Reputation: 0
Joined: 11 Sep 2009 Posts: 1
|
Posted: Wed Feb 10, 2010 12:37 am Post subject: |
|
|
How to send a key to a deactive window? some time we cant use SendMessage func (Online Games).
|
|
Back to top |
|
 |
rooski Master Cheater
Reputation: 0
Joined: 31 Oct 2007 Posts: 340 Location: Siberia
|
Posted: Thu Feb 11, 2010 10:39 pm Post subject: |
|
|
@GiaBaoCT
SendInput() should work for you .
also bump.
|
|
Back to top |
|
 |
|