azazul Posted April 26, 2009 Share Posted April 26, 2009 Hi, All. Sorry for noob question, but I'm new to AutoIT. Here is my script. It's a basic buffing bot for RF Online. I want it to press keys when game window is NOT active, but script works only in active one. Help me find the problem please. AutoItSetOption("WinTitleMatchMode", 4) $handle = WinGetHandle("RF Online - 1") If WinExists($handle) Then While 1 $i = 0 ControlSend($handle, "", "", "{F7}");press F7 Sleep(500) While $i <= 121 ControlSend($handle, "", "", "{F6}");press F6 every second for 2 minutes Sleep(1000) $i = $i + 1 WEnd ControlSend($handle, "", "", "{F7}");press F7 Sleep(500) ControlSend($handle, "", "", "{F8}");press F8 Sleep(500) ControlSend($handle, "", "", "{F9}");press F9 Sleep(500) WEnd EndIf Link to comment Share on other sites More sharing options...
dantay9 Posted April 26, 2009 Share Posted April 26, 2009 You could use winactivate() before the controlsend to activate the window. Link to comment Share on other sites More sharing options...
azazul Posted April 26, 2009 Author Share Posted April 26, 2009 As I already mentioned, I want it to press keys when game window is NOT active I don't want to activate window. It works just fine when game window is active. The point is to make it work when game is in the backgrond.Switching between active/background windowstates is also not an option. I want to surf, watch video, work, whatever, - while bot is working in background window. Link to comment Share on other sites More sharing options...
FreeFry Posted April 27, 2009 Share Posted April 27, 2009 (edited) If it works fine when active, maybe the game window ignores key-presses when it's not active... In that case you're sorta stuck to keeping it active. :/ Edited April 27, 2009 by FreeFry Link to comment Share on other sites More sharing options...
azazul Posted April 27, 2009 Author Share Posted April 27, 2009 (edited) Found kind of solution. #Include <WinAPI.au3> AutoItSetOption("WinTitleMatchMode", 4) Global $handle = WinGetHandle("RF Online - 1") If WinExists($handle) Then While 1 $i = 0 Stroke("{F7}") Sleep(1000) While $i <= 120 Stroke("{F6}") Sleep(1000) $i = $i + 1 WEnd Stroke("{F7}") Sleep(1000) Stroke("{F8}") Sleep(1000) Stroke("{F9}") Sleep(1000) WEnd EndIf Func Stroke($key) _SendMessage($handle, 0x6, 0x1) ControlSend($handle, "", "", $key) _SendMessage($handle, 0x6, 0x1) EndFunc It seems to work OK, when game window is NOT hidden, but in background (not active). The only problem is arrow keys: if I press them - my character lurks around, but I'm OK with that, 'cause I almost do not use them Edited April 27, 2009 by azazul Link to comment Share on other sites More sharing options...
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