Jump to content

Background window


Recommended Posts

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

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

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 by azazul
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...