Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Tontow on April 08, 2005, 05:52 PM

Title: simulateing key pressing
Post by: Tontow on April 08, 2005, 05:52 PM
How do you simulate a key press? (ie: left and right arrow keys)
Title: Re: simulateing key pressing
Post by: Blaze on April 08, 2005, 07:37 PM
The SendKeys Function might be what you are looking for.
Title: Re: simulateing key pressing
Post by: effect on April 09, 2005, 01:15 AM
You might have to select the window u want to send them to aswell?
Title: Re: simulateing key pressing
Post by: Stealth on April 09, 2005, 01:14 PM
If they're inside your own program, just call the _KeyPress or _KeyDown event for the object you want the keys to be pressed on. You may need to experiment (ie Debug.Print KeyAscii) to figure out what the arguments should be.
Title: Re: simulateing key pressing
Post by: Yegg on April 09, 2005, 01:20 PM
Quote from: effect on April 09, 2005, 01:15 AM
You might have to select the window u want to send them to aswell?
The SendKeys function will work like a macro, it just sends keys to the computer as if you were typing them in through your keyboard. What window is being focused on will be the one that receives the keys.
Title: Re: simulateing key pressing
Post by: Adron on April 09, 2005, 01:27 PM
If you want to send keys to non-active windows, you can sometimes use SendMessage or PostMessage with WM_KEYDOWN, WM_KEYUP and/or WM_CHAR.
Title: Re: simulateing key pressing
Post by: Yegg on April 10, 2005, 06:21 PM
It just matters on what the purpose of his program is. Whether it be built to send key strokes to specific programs, or if it functions like a macro.
Title: Re: simulateing key pressing
Post by: Grok on April 11, 2005, 02:51 PM
Tontow did anyone answer your question?  Some asked for more information.  How about do the community a favor and say you got your answer (maybe even which method you chose) or answer their questions so they can help you.
Title: Re: simulateing key pressing
Post by: NetNX on April 20, 2005, 09:43 AM
Alot of programs(games) protect agienst bots and that nature by disabling the sendkeys function in their program... not sure about those other methods but maybe you could create a fake keyboard device and make a program that causes this fake device to send keys ( just a though ) i mean like not a physical device i mean like a driver that can be manipulated by a program
Title: Re: simulateing key pressing
Post by: Yegg on April 20, 2005, 01:37 PM
Even though many games (Runescape, Eternal Lands) have protection from automated tasks by 3rd party programs, I highly doubt that they can stop the SendKeys function from your program. SendKeys sends keys directly to the computer as if you were typong them through your keyboard. Nothing can detect if you are typing or if it is a program.
Title: Re: simulateing key pressing
Post by: NetNX on April 21, 2005, 09:41 AM
Quote from: Yegg on April 20, 2005, 01:37 PM
Even though many games (Runescape, Eternal Lands) have protection from automated tasks by 3rd party programs, I highly doubt that they can stop the SendKeys function from your program. SendKeys sends keys directly to the computer as if you were typong them through your keyboard. Nothing can detect if you are typing or if it is a program.

You oviously dont know what your talking about then... We will use something i recently worked on as an example Guildwars you can download the client from their site http://guildwars.com make a code that will log you in completely and prove me wrong using only the sendkeys api
Title: Re: simulateing key pressing
Post by: Yegg on April 21, 2005, 10:26 AM
Why would I want to waste my time proving you wrong? I'm working on other projects.
Title: Re: simulateing key pressing
Post by: Adron on April 21, 2005, 12:21 PM
Quote from: Yegg on April 21, 2005, 10:26 AM
Why would I want to waste my time proving you wrong? I'm working on other projects.

Maybe you are wrong. Maybe you're ignorant. Maybe you lose?
Title: Re: simulateing key pressing
Post by: Yegg on April 22, 2005, 08:46 AM
Maybe not?
Title: Re: simulateing key pressing
Post by: Warrior on April 22, 2005, 09:24 AM
Since you're not going to take your time I guesss you will never know and will be assume wrong :p
Title: Re: simulateing key pressing
Post by: LivedKrad on April 22, 2005, 07:08 PM
Failure to answer a challenge based off of a previous statement made by yourself makes you wrong?

Well, my Algebra 2 teacher is in for some exciting new interpretations of our conversations. Thanks for the tip, Adron.
Title: Re: simulateing key pressing
Post by: Ban on April 25, 2005, 09:52 AM
Um, what?
Title: Re: simulateing key pressing
Post by: Adron on April 25, 2005, 10:02 AM
Quote from: LivedKrad on April 22, 2005, 07:08 PM
Failure to answer a challenge based off of a previous statement made by yourself makes you wrong?

Well, my Algebra 2 teacher is in for some exciting new interpretations of our conversations. Thanks for the tip, Adron.

Absolutely. A math teacher should be able to prove all the theorems being taught or be able to point to existing proofs if the proof is too long to write on the blackboard. Math teachers should never rely on saying: "This is the way it, because I say so", because then they're turning math into something as vague as religion - based on belief and speculation.
Title: Re: simulateing key pressing
Post by: QwertyMonster on April 25, 2005, 10:30 AM
In my maths lesson, im the best in it :P

The teacher explains it, but then i go into more detail than she can, and the class listen carefully, and say "No i dont understand what the teacher says", but when i explain they say, "Yes i kind of understand this".

If i feel my teacher hasn't explained it well, i will explain it back to her in more detail. My maths teacher (Is a she) is actually very good.
Title: Re: simulateing key pressing
Post by: Yegg on April 27, 2005, 03:24 PM
I learn more from http://math.com than school math classes.
Title: Re: simulateing key pressing
Post by: LivedKrad on April 27, 2005, 03:58 PM
Quote from: Adron on April 25, 2005, 10:02 AM
Quote from: LivedKrad on April 22, 2005, 07:08 PM
Failure to answer a challenge based off of a previous statement made by yourself makes you wrong?

Well, my Algebra 2 teacher is in for some exciting new interpretations of our conversations. Thanks for the tip, Adron.

Absolutely. A math teacher should be able to prove all the theorems being taught or be able to point to existing proofs if the proof is too long to write on the blackboard. Math teachers should never rely on saying: "This is the way it, because I say so", because then they're turning math into something as vague as religion - based on belief and speculation.

My Chemistry teacher frequently says such things. Apparently, if we get an answer wrong on the test but the answer book says otherwise, weare completely wrong and there is no room for discussion or for proving the answer false.

"I thought you said the delta H of a substance was its exothermic or endothermic temperature change.."

"The answer is A, damnit!"
Title: Re: simulateing key pressing
Post by: Adron on April 27, 2005, 09:30 PM
Sounds like you've been given simplified explanations. Besides, there's a huge difference between math and chemistry!
Title: Re: simulateing key pressing
Post by: LivedKrad on April 27, 2005, 10:01 PM
Agreed. There is a substantial difference between math and chemistry in most areas, however the teaching styles at my school for chemistry and math are one in the same: don't ask don't tell.
Title: Re: simulateing key pressing
Post by: Adron on April 28, 2005, 08:49 AM
You should try asking your math teacher for more proofs. Since math is based purely on theory, you can generally prove things. Unlike chemistry which is somewhat empirical.
Title: Re: simulateing key pressing
Post by: Tontow on May 09, 2005, 03:17 PM
How would I send the keys to a single program regardless of weather it was full screen or minimized?

What about data injection? - (Note: I have no clue what data injection is)

BTW, I'm not makeing a cheating micro bot, I'm trying to make a tourney program that can interface with and send text through any or most game clients, but I'm focusing on getting it to work with starcraft first. - kinda like that one program that truned your starcraft into a moderation bot.
Title: Re: simulateing key pressing
Post by: MyndFyre on May 09, 2005, 04:52 PM
Quote from: Tontow on May 09, 2005, 03:17 PM
How would I send the keys to a single program regardless of weather it was full screen or minimized?

What about data injection? - (Note: I have no clue what data injection is)

BTW, I'm not makeing a cheating micro bot, I'm trying to make a tourney program that can interface with and send text through any or most game clients, but I'm focusing on getting it to work with starcraft first. - kinda like that one program that truned your starcraft into a moderation bot.

Quote from: Adron on April 09, 2005, 01:27 PM
If you want to send keys to non-active windows, you can sometimes use SendMessage or PostMessage with WM_KEYDOWN, WM_KEYUP and/or WM_CHAR.

(I realize that this thread has gone way off-topic, but you could have looked through the responses ;))
Both SendMessage (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/sendmessage.asp) and PostMessage (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/sendmessage.asp) are documented in MSDN.
Title: Re: simulateing key pressing
Post by: Yegg on May 09, 2005, 10:00 PM
I'm sure pscode.com and vbcode.com have some perfect examples on doing this.