Silent Typing Function [Source]

Discussion in 'Programming General' started by Covey, Apr 25, 2008.

Thread Status:
Not open for further replies.
Silent Typing Function [Source]
  1. Unread #1 - Apr 25, 2008 at 11:37 AM
  2. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Silent Typing Function [Source]

    Well since im about to move on from VB6 i don't see the point on keeping this too myself. (even though its not that great).

    Note
    This should only be used with RuneScape, if you try to use this for another program / game. It will not work correctly due to the Universal Charater conversion function.
    And to those that want to know what the meaning of "Silent" is, well it simply sends the text to the given handle without actually having to have it as your Desktop Window.

    Code:
    Option Explicit
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long
    Private Declare Function GetVersion Lib "kernel32" () As Long
    Private Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" (ByVal cChar As Byte) As Integer
    Private Declare Function VkKeyScanW Lib "user32" (ByVal cChar As Integer) As Integer
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
    Private Const WM_KEYDOWN = &H100
    Private Const WM_KEYUP = &H101
    Private Const WM_CHAR = &H102
    Private Const WM_SETFOCUS = &H7
    Private Const WM_ACTIVATE = &H6
    
    Private Sub Wait(TimeOut As Long)
        Dim TimeNow As Long
        TimeNow = GetTickCount
        Do
            DoEvents
        Loop While TimeNow + TimeOut > GetTickCount
    End Sub
    
    Private Function KeyCode(ByVal sChar As String) As KeyCodeConstants
        Dim bNt As Boolean
        Dim iKeyCode As Integer
        Dim b() As Byte
        Dim iKey As Integer
        Dim vKey As KeyCodeConstants
        Dim iShift As ShiftConstants
        bNt = ((GetVersion() And &H80000000) = 0)
        If (bNt) Then
           b = sChar
           CopyMemory iKey, b(0), 2
           iKeyCode = VkKeyScanW(iKey)
        Else
           b = StrConv(sChar, vbFromUnicode)
           iKeyCode = VkKeyScan(b(0))
        End If
        KeyCode = (iKeyCode And &HFF&)
    End Function
    
    Public Sub SendText(wText As String, ByVal wHandle As Long, sTypeSpeed As Long)
        Dim strChr As String
        Dim wCount As Long
        Dim wLen As Long
        wLen = Len(wText)
        Call SendMessage(wHandle, WM_SETFOCUS, True, ByVal 0&)
        Do Until wCount >= wLen
            Randomize
            wCount = wCount + 1
            strChr = Mid$(wText, wCount, 1)
            Call SendMessage(wHandle, WM_KEYDOWN, KeyCode(strChr), ByVal 0&)
            Call SendMessage(wHandle, WM_CHAR, KeyCode(strChr), ByVal 0&)
            Wait Int(Rnd * 3) + 2
            Call SendMessage(wHandle, WM_KEYUP, KeyCode(strChr), ByVal 0&)
            Wait sTypeSpeed
        Loop
        Call SendMessage(wHandle, WM_KEYDOWN, KeyCode(Chr$(13)), ByVal 0&)
        Call SendMessage(wHandle, WM_CHAR, KeyCode(Chr$(13)), ByVal 0&)
        Wait Int(Rnd * 3) + 2
        Call SendMessage(wHandle, WM_KEYUP, KeyCode(Chr$(13)), ByVal 0&)
        Call SendMessage(wHandle, WM_ACTIVATE, True, ByVal 0&)
    End Sub
    Credits:
    Jazz - KeyCode(ByVal sChar As String) Function
    Cruel - Wait(TimeOut As Long) Sub
     
  3. Unread #2 - Apr 25, 2008 at 7:50 PM
  4. dgameman1
    Joined:
    May 25, 2006
    Posts:
    122
    Referrals:
    0
    Sythe Gold:
    0

    dgameman1 Active Member
    Banned

    Silent Typing Function [Source]

    Thanks for giving this to me oh and, what are you moving onto?
     
  5. Unread #3 - Apr 25, 2008 at 8:33 PM
  6. SidStudios
    Joined:
    Mar 14, 2007
    Posts:
    201
    Referrals:
    0
    Sythe Gold:
    0

    SidStudios Active Member

    Silent Typing Function [Source]

    Perhaps he is going to move on to Delphi ;)
     
  7. Unread #4 - Apr 25, 2008 at 11:45 PM
  8. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Silent Typing Function [Source]

    No, he's moving onto .Net 2008.

    Thanks for posting Covey, now I can leech it and make a 1337 Auto Typer. :D
     
  9. Unread #5 - Apr 26, 2008 at 3:34 AM
  10. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Silent Typing Function [Source]

    haha, yer thats the engine that i've used in the upcoming auto talker in EliteSwitch v2.72.
    I'll also be making a silent clicking function for the auto clicker which i will also post when i finish coding it, it will be basically the same but with the WM_Leftclick etc constants.
     
  11. Unread #6 - Apr 26, 2008 at 8:30 PM
  12. jdsfighter
    Joined:
    Jan 21, 2007
    Posts:
    603
    Referrals:
    0
    Sythe Gold:
    0

    jdsfighter Forum Addict
    Visual Basic Programmers

    Silent Typing Function [Source]

    I don't really get the point of the silent typing covey :) I understand that it keeps focus on the runescape applet which is a good thing, but sendkeys works aswell, also sendkeys DOES work on vista.
     
  13. Unread #7 - Apr 27, 2008 at 6:29 AM
  14. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Silent Typing Function [Source]

    I guess you're missing the point.
    You can type in the RuneScape appet while it is minimized or you have another page over the top of it.
     
  15. Unread #8 - May 6, 2008 at 10:36 PM
  16. demonavenger
    Joined:
    Feb 25, 2007
    Posts:
    536
    Referrals:
    0
    Sythe Gold:
    0

    demonavenger Forum Addict
    $5 USD Donor

    Silent Typing Function [Source]

    JD he had it already posted it on his first post

     
  17. Unread #9 - May 7, 2008 at 9:21 PM
  18. jdsfighter
    Joined:
    Jan 21, 2007
    Posts:
    603
    Referrals:
    0
    Sythe Gold:
    0

    jdsfighter Forum Addict
    Visual Basic Programmers

    Silent Typing Function [Source]

    I understand that you don't have to have focus, but not many uses for it, silent clicking, now that is a different story
     
  19. Unread #10 - May 8, 2008 at 7:35 PM
  20. demonavenger
    Joined:
    Feb 25, 2007
    Posts:
    536
    Referrals:
    0
    Sythe Gold:
    0

    demonavenger Forum Addict
    $5 USD Donor

    Silent Typing Function [Source]

    Hmm, yeah...

    By the way, cant jagex detect silent clicks? and would they detect the silent typing as well?
     
  21. Unread #11 - May 9, 2008 at 12:17 AM
  22. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Silent Typing Function [Source]

    They can "detect" everything.
    Whether or not you fool them as to thinking it's a person typing is a different matter.
     
  23. Unread #12 - May 9, 2008 at 8:15 AM
  24. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    Silent Typing Function [Source]

    Mind showing an example or two on how to use this? Noobs like blupig don't know what a wHandle is for instance. Fucking hWnds and hDCs, I've got no idea what the hell they are :I
     
  25. Unread #13 - May 9, 2008 at 8:27 AM
  26. jdsfighter
    Joined:
    Jan 21, 2007
    Posts:
    603
    Referrals:
    0
    Sythe Gold:
    0

    jdsfighter Forum Addict
    Visual Basic Programmers

    Silent Typing Function [Source]

    Every window has a hWnd (Window Handle) and a hDC (Handle of Device Context). Pretty much hWnd can get where an object is located and can provide some info, but I believe hDC is much more in dept and more powerful (not positive)

    But the way to use the function is you use an api to get the window handle you want to type to (FindWindow, FindWindowEx, WindowfromPoint, etc)

    I don't feel like explaining how to use the api's, but once you get the object's hwnd you call the function

    Code:
    SendText "Hello", hWnd, 100
    
     
  27. Unread #14 - May 9, 2008 at 10:40 AM
  28. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Silent Typing Function [Source]

    Should tell you guys that, that code is bugged.
    If you use it, it will freeze the RuneScape window. You are still able to click on it, but you can't type in the RuneScape window.

    You can fix it by removing the last SendMessage line and replacing it with:
    Code:
    call putfocus(whandle)
    Then you need to add the PutFocus API to the declarations.
     
  29. Unread #15 - May 9, 2008 at 11:17 AM
  30. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    Silent Typing Function [Source]

    So if I want to use this, what would I put as the wHandle to look for a .jar based client?
     
  31. Unread #16 - May 10, 2008 at 2:23 AM
  32. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Silent Typing Function [Source]

    This is really only made for RuneScape, so you would need the RuneScape handle, you can get it by using StealRS to switch worlds or by digging up my RuneHwnd code.
     
  33. Unread #17 - Jul 22, 2008 at 11:52 PM
  34. The True Gears
    Referrals:
    1

    The True Gears Guest
    $5 USD Donor

    Silent Typing Function [Source]

    How about you paste the silent version with vb.net :D
     
  35. Unread #18 - Jul 23, 2008 at 12:49 AM
  36. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    Silent Typing Function [Source]

    How about you stop grave digging? O:
     
< Installed vb 2005 - Confused. | RSC botmaking tutorials? >

Users viewing this thread
1 guest
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site