Jump to content

Sending Text To A Game Window Faster...


Recommended Posts

probably been answered before, but i can't find it anywhere.

I have an autoit script that i want to use the Send() Command to Send text to a game, but insted of sending the keystrokes fast, it send it with about a 750milisecond per letter..

i Currently have:

Opt("SendKeyDelay", 0)
WinActivate("Game Name")
sleep(500)
Send("{ENTER}")
Send("My Text Here...")
Link to comment
Share on other sites

probably been answered before, but i can't find it anywhere.

I have an autoit script that i want to use the Send() Command to Send text to a game, but insted of sending the keystrokes fast, it send it with about a 750milisecond per letter..

i Currently have:

Opt("SendKeyDelay", 0)
WinActivate("Game Name")
sleep(500)
Send("{ENTER}")
Send("My Text Here...")
I don`t know if this is any help to you but i have found that the editpaste function works alot faster than Send or ControlSend.

$Title = "Game Name"
$Text = "My Text Here..."
$LF = Chr(10)
$CR = Chr(13)
ControlCommand($Title, "", $EditBox, "EditPaste", $Text &$CR &$LF)

Maybe you can adapt it more...

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

This should send them instantly, to use it use

$hwnd = WinGetHandle("Game Title")
_SendKeys($hwnd, "{ENTER}keys{ENTER}")
_ArrowKey($hwnd, "up")

And here are the functions

Global Const $VK_OEM_PLUS = 0xBB
Global Const $VK_OEM_MINUS = 0xBD
Global Const $VK_OEM_3 = 0xC0
Global Const $VK_TAB = 0x9
Global Const $VK_ESC = 0x1B
Global Const $VK_F5 = 0x74
Global Const $VK_F12 = 0x7B

Func _SendKeys($hWnd, $keys)
    If $hWnd <= 0 Or StringLen($keys) = 0 Then
        SetError(-1)
        Return False
    EndIf
    $keys = StringUpper($keys)
    $keys = StringReplace($keys, "`", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "~", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "-", Chr($VK_OEM_MINUS))
    $keys = StringReplace($keys, "=", Chr($VK_OEM_PLUS))
    $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
    $keys = StringReplace($keys, "{TAB}", Chr(0x9))
    $keys = StringReplace($keys, "{ESC}", Chr($VK_ESC))
    $keys = StringReplace($keys, "{F5}", Chr($VK_F5))
    $keys = StringReplace($keys, "{F12}", Chr($VK_F12))
    $keys = StringReplace($keys, "{SHIFT}", "+")
    Local $i, $ret
    Local $shiftdown = False
    For $i = 1 To StringLen($keys)
        If StringMid($keys, $i, 1) = "+" Then
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
            $shiftdown = True
            Sleep(1)
            ContinueLoop
        Else
            
            $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
            If IsArray($ret) Then
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
                Sleep(1)
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
            EndIf
        EndIf
        If $shiftdown Then
            Sleep(1)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
            $shiftdown = False
        EndIf
    Next
    Return True
EndFunc 

Func _ArrowKey($hWnd, $key)
    If $hWnd <= 0 Or ($key <> "left" And $key <> "right" And $key <> "up" And $key <> "down") Then
        SetError(-1)
        Return
    EndIf
    Local $wParam, $lParam, $ret
    If $key = "left" Then
        $wParam = 0x25
        $lParam = 0x14B0001
    ElseIf $key = "right" Then
        $wParam = 0x27
        $lParam = 0x14D0001
    ElseIf $key = "down" Then
        $wParam = 0x28
        $lParam = 0x1500001
    ElseIf $key = "up" Then
        $wParam = 0x26
        $lParam = 0x1480001
    EndIf
    $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", $wParam, "int", $lParam)
    If $ret[0] = 0 Then
        MsgBox(16, "_ArrowKey Error", "There was an error posting the WM_KEYDOWN message")
        SetError(-2)
        Return
    EndIf
    Sleep(2)
    $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", $wParam, "int", ($lParam + 0xC0000000))
    If $ret[0] = 0 Then
        MsgBox(16, "_ArrowKey Error", "There was an error posting the WM_KEYUP message")
        SetError(-3)
        Return
    EndIf
EndFunc

(I didn't write them, dont know who did)

ps: also works minimized

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

probably been answered before, but i can't find it anywhere.

I have an autoit script that i want to use the Send() Command to Send text to a game, but insted of sending the keystrokes fast, it send it with about a 750milisecond per letter..

i Currently have:

Opt("SendKeyDelay", 0)
WinActivate("Game Name")
sleep(500)
Send("{ENTER}")
Send("My Text Here...")
2 options to set... pay attention to extra note...

SendKeyDelay Alters the the length of the brief pause in between sent keystrokes.

Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead.

SendKeyDownDelay Alters the length of time a key is held down before released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default.

Time in milliseconds to pause (default=1).

Link to comment
Share on other sites

could you use send keys to a game like CS or unreal

I think I tried it before and it just wouldn't send them the game window. it would send to the desktop. is that an anti-hac or am I doing it wrong

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

could you use send keys to a game like CS or unreal

I think I tried it before and it just wouldn't send them the game window. it would send to the desktop. is that an anti-hac or am I doing it wrong

i haven't tried automating either of those games, but typically the anti-hacks consist of trapping the hotkeys to trigger the script, not actually re-directing input. my money would be on the chance that you're doing something incorrectly. do you still have the script?
Link to comment
Share on other sites

i haven't tried automating either of those games, but typically the anti-hacks consist of trapping the hotkeys to trigger the script, not actually re-directing input. my money would be on the chance that you're doing something incorrectly. do you still have the script?

no sorry I don't. I will rewite one and see what happens. thanks

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

SendKeyDelay Alters the the length of the brief pause in between sent keystrokes.

Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead.

SendKeyDownDelay Alters the length of time a key is held down before released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default.

Time in milliseconds to pause (default=1).

I had to play with these two values to get GTA working. I can't remember the numbers offhand but it was something like under 20 would not register and over 100 caused other issues.

You may need to play around with the values untill you get a combo that the game will accept.

Link to comment
Share on other sites

hmm changed the sendkeydelay from 0 to 1 after i made this topic, and seems like it sends a little faster. also changed the sendkeydowndelay and still running alittle slow.

tried the solution posted by cdkid, and got errors on unknown string of "$VK_OEM_3" so temporarily commented those lines out, and ended up with unknown function of _MakeLong..

Link to comment
Share on other sites

Sorry, i forgot the _MakeLong function... one second, i'll post it.

Edit

**here it is**

Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...