Sunday, January 13, 2013

SendKeys Method


You could « automate » a program using the SendKeys to another program. Many hacking programs use this technique to cheat games. Unfortunately, most game is now blocking this type of technique.
Here is an example from MSDN. It shows how to get the Windows calculator and simulate key entries: How to: Start an Application and Send it Keystrokes (Visual Basic)


In Visual Basic .NET:
Dim ProcID As Integer
' Start the Calculator application, and store the process id.
ProcID = Shell("CALC.EXE", AppWinStyle.NormalFocus)
' Activate the Calculator application.
AppActivate(ProcID)
' Send the keystrokes to the Calculator application.
My.Computer.Keyboard.SendKeys("22", True)
My.Computer.Keyboard.SendKeys("*", True)
My.Computer.Keyboard.SendKeys("44", True)
My.Computer.Keyboard.SendKeys("=", True)
' The result is 22 * 44 = 968.






In Visual Basic for Application or Visual Basic 6 :
Dim ReturnValue, I
ReturnValue = Shell("CALC.EXE", 1)   ' Run Calculator.
AppActivate ReturnValue    ' Activate the Calculator.
For I = 1 To 100   ' Set up counting loop.
   SendKeys I & "{+}", True   ' Send keystrokes to Calculator
Next I   ' to add each value of I.
SendKeys "=", True   ' Get grand total.
SendKeys "%{F4}", True   ' Send ALT+F4 to close Calculator.

Most programs will not respond to external SendKey. I’ll give you 2 examples for games and MMORPG:
-Prevent robots and spammer to send spam
-Stop Password Generator

I don’t really understand why there are still posts for SendKeys, knowing that the method is not reliable most of the time.

Did you have: Process '{0}' was not found. ?


References

No comments:

Post a Comment