Home > categories > Machinery & Equipment > Press > Auto key press software?
Question:

Auto key press software?

I'm am looking for a software that will press a set combination of letter keys with a specified time gap between the key pressing.

Answer:

I don't know about any programs but this is my Delphi procedure that I use to automate any programs on the computer: procedure SendKey(ControlCode, VKCode, RepeatNum, Delay:Integer; ProgHnd:HWnd); var TempB:Byte; Begin If (Not BringWindowToTop(ProgHnd)) or (Not SetForegroundWindow(ProgHnd)) then Begin MessageDlg('Can''t bring prog window to front.',mtError,[mbOK],0); Halt(0); end; Sleep(10); For TempB:=1 to RepeatNum do begin if ControlCode0 then begin keybd_event(ControlCode,0,2,0); sleep(10); keybd_event(ControlCode,0,0,0); sleep(10); keybd_event(VKCode,0,0,0); sleep(10); keybd_event(VKCode,0,2,0); {2=KEYEVENTF_KEYUP} sleep(10); keybd_event(ControlCode,0,2,0); end else begin keybd_event(VKCode,0,0,0); sleep(10); keybd_event(VKCode,0,2,0); {2=KEYEVENTF_KEYUP} end; end; Sleep(Delay); end; And use a line like this in the program to call it: SendKey(vk_menu,vk_f4,1,100,hndNotepad... VK_MENU = What Windows calls the ALT key. VK_F4 = The scankey code for F4. 1 = Press the key combination once. 100 = Wait 100ms after doing the key combination. hndNotepad = the handle of a notepad window. This will send ALT-F4 to the notepad window defined by hndNotepad. Get hndNotepad with: hndNotepad:=FindWindow(nil,'Untitled - Notepad') Just change 'Untitled - Notepad' to whatever program you want to send the keystrokes to or you can also use: hndProg:=GetForegroundWindow(); This will grab the handle of any window that currently has focus. If you can get even an old version of Delphi, this code should work and you can do a lot more than just sending keystrokes to programs. Controlling the mouse is just as easy and it's fun being able to automate any program on the computer.

Share to: