Does anyone know a way of making a program automatically type by itself. Like as soon as you start the program, it starts typing the words instead of just making them appear. I want to put that kind of thing in my program. Does anyone know of a way to do this? I think it would be a nice visual touch. Any examples would be extremely helpul because I have been trying for 3 weeks now to try and implement this using timers and the sleep api and everything.
Posted on 2002-10-01 18:59:10 by resistance_is_futile
I did that once with an EditWindow... All I did was (iirc) this:

Buffer db "This is some automatic typing",0

set up a timer

mov eax,offset Buffer
xor edx,edx
mov ecx,NextLetter
mov dl,b$[eax+ecx]
or edx,edx
jz done:
invoke SendMessage,hEdit,WM_KEYDOWN,edx,???
inc NextLetter
jmp F:
mov NextLetter,0

I don't remember if I also send a WM_KEYUP afterwards... I just played around a bit with the Timer settings and then it looked like someone typed at real speed.
Posted on 2002-10-01 19:14:17 by JimmyClif
you can also use the keybd_event function. this generates an keystroke like pressing a real key
Posted on 2002-10-04 06:28:37 by beaster
@beaster: but then you have to watch out that your control doesn't lose the focus, it's possible that resistance_is_futile wants to use this effect somewhere on his window, independent of what the user is doing...
Posted on 2002-10-06 04:29:24 by NOP-erator

Here is a small example for you,maybe it can be usefull.

.model flat,stdcall
option casemap:none

include \masm32\include\
include \masm32\include\
include \masm32\include\
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

msg db 'Hello my friend!',13,10
db 'What about you?',0
app db 'c:\windows\notepad.exe',0
wndclass db 'Notepad',0
childclass db 'Edit',0

handle dd ?


invoke WinExec,ADDR app,SW_SHOW
call fndhandle
mov edx,offset msg
xor eax,eax
mov al,byte ptr
or al,al
jz finish
push edx
invoke SendMessage,handle,WM_CHAR,eax,0
invoke Sleep,500
pop edx
inc edx
jmp restart
invoke ExitProcess,NULL

fndhandle proc
local temp:dword
invoke FindWindow,addr wndclass,0
mov temp,eax
invoke SetForegroundWindow,eax
invoke FindWindowEx,temp,0,addr childclass,0
mov handle,eax
fndhandle endp

end start
Posted on 2002-10-06 13:52:09 by Vortex