Simulating a keypress-Autotyping

Blitz3D Forums/Blitz3D Beginners Area/Simulating a keypress-Autotyping

Nike(Posted 2011) [#1]
Hello, I would like to create an auto typing program, and I have no idea how to make blitz3d press a key on its own. I do not want to type to appear in the window, but in whatever is the front one. For example, if I had the notepad program running in front of all my other programs, I would like the text to appear on that. Does anyone know how to make blitz3d type?


Warner(Posted 2011) [#2]
You need to create a userlib with the function api_keybd_event.
First, save this code as "keybd.decls" in "c:\program files\blitz3d\userlibs"
.lib "user32.dll" 

api_keybd_event%(bVk%, bScan%, dwFlags%, dwExtraInfo%) : "keybd_event" 


Then, execute this file and set the focus to the Notepad window:

It now presses the "A" key. You can find other keycodes in this list here:
http://msdn.microsoft.com/en-us/library/dd375731(v=vs.85).aspx

Last edited 2011


Nike(Posted 2011) [#3]
Thank you!


Nike(Posted 2011) [#4]
This is the autotyper I made 20 char limit, and it has a bug that I cannot find. It is also 666 lines, and thats kinda a bad number for two reasons. 1st, its A LOT more then a simple program like this should be, and 2nd, it means that the devil is going to kill me. Can anyone show me how to shorten this or find the bug? Thanks.



Last edited 2011


Matty(Posted 2011) [#5]
Learn to use loops. A simple "for" loop from the start of the input string to the end of the input string would shorten this as a basic starting point.


Charrua(Posted 2011) [#6]
try something like this:

AppTitle "Auto Typer V.1"
Graphics 400,200,16,2
Print "Welcome to the Auto Typer."
Print ""
Print "What would you like to be autotyped?"
ainput$ = Input("")
blen$ = Len(ainput$)

time$ = Input("Repeat per seconds (ex. 1 sec = 1000): ")
a1$ = Mid$(ainput$,1,1)

For i=1 To blen
	CharToType = Asc(Mid(ainput,i,1))
	Print CharToType + " " + Chr(CharToType)
	api_keybd_event(CharToType,0,0,0)
	api_keybd_event(CharToType,0,2,0)
	Delay time$
Next

End


there have no limit on the Len of the string
the loop (For..Next) get each of the "Mid" characters using the "i" variable as an index in the ainput string
the Asc() function is used to convet the string with one character returned by Mid$ to an Ascii number required by api_keybd_event.
the print sentence is present only to see what is happening, if you exclude this sentence then ONLY 6 instructions are required to do the job

YES LOOPS ARE GOOD!

Juan


Rob the Great(Posted 2011) [#7]
Kind of a noob question, but what's an auto typer? All that I can find on Google is that it's a program that repeats a message you type in. Is there some sort of advantage or cheat you can get with being able to repeat a string? A lot of the searches tied into RuneScape, but I'm not seeing how an auto typer could give anyone the upper edge in a game.


Kryzon(Posted 2011) [#8]
It could be used to scare someone. Like they are writing in Word or something and it starts typing an automatic message "Hey [name], you are the chosen one. Welcome to the matrix."


Rob the Great(Posted 2011) [#9]
Oh, I get it. It's not a text inserter, it's a program that similates typing. Haha, the matrix idea is pretty clever. I might have to try that one of these days.


Kryzon(Posted 2011) [#10]
I don't know. I had it done to me and it wasn't a pleasurable experience - forgot I left UltraVNC on and my dad and sis thought it'd be funny.

Another funny text to trick the person could be "... hello? is anyone there? I'm trapped in the computer!"