Bi0haZarD Posted March 29, 2006 Posted March 29, 2006 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...")
Lakes Posted March 29, 2006 Posted March 29, 2006 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.
nfwu Posted March 29, 2006 Posted March 29, 2006 he's talkin bout a game window, not an edit control. #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
Lakes Posted March 29, 2006 Posted March 29, 2006 he's talkin bout a game window, not an edit control.#)Sorry... 2015 - Still no flying cars, instead blankets with sleeves.
cdkid Posted March 29, 2006 Posted March 29, 2006 (edited) 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 expandcollapse popupGlobal 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 April 5, 2006 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!
seandisanti Posted March 29, 2006 Posted March 29, 2006 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).
ConsultingJoe Posted March 29, 2006 Posted March 29, 2006 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 Check out ConsultingJoe.com
seandisanti Posted March 29, 2006 Posted March 29, 2006 could you use send keys to a game like CS or unrealI 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 wrongi 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?
ConsultingJoe Posted March 29, 2006 Posted March 29, 2006 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 Check out ConsultingJoe.com
seandisanti Posted March 29, 2006 Posted March 29, 2006 no sorry I don't. I will rewite one and see what happens. thanksno problem. if you run into issues, we're all here to help.
cal Posted March 29, 2006 Posted March 29, 2006 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.
Bi0haZarD Posted March 30, 2006 Author Posted March 30, 2006 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..
cdkid Posted March 30, 2006 Posted March 30, 2006 (edited) 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 March 30, 2006 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now