Jump to content

How to hook onto a window, winsettitle doesnt work, other ideas?


pileot
 Share

Recommended Posts

Basically, im trying to make a bot for lineage 2. But not an experience bot, a buffbot...

Still with me? Let me explain. The script im working on is supposed to go through three different windows of lineage 2 and activate different skills on my main character. The reasoning behind this is these skills make my main character stronger (more attack speed, more defence, etc.) these skills are called buffs.

The thing is, these buffs run out every so often, depending on what they are and how good they are. 2 minutes, 5 minutes, and 20 minutes are common durations for buffs.

Still there? awesome!

The problem is the game uses an unreal window, and i can't seem to hook onto each seperate window (there are three of them) and send different commands to each seperate window.

Heres the script i was working with:

#include <misc.au3>;For ispressed hotkeyset("{capslock}","Go")
sleep(1000)
Tooltip("select char1's window",0,0)
    Do
    sleep(50)
    until _IsPressed(08) = 1
winsettitle("Lineage II","","Lineage II char1")
sleep(1000)

Tooltip("select char2's window",0,0)
    Do
    sleep(50)
    until _IsPressed(08) = 1
winsettitle("Lineage II","","Lineage II char2")
sleep(1000)

Tooltip("select char3's window",0,0)
    Do
    sleep(50)
    until _IsPressed(08) = 1
winsettitle("Lineage II","","Lineage II char3")
tooltip("")
sleep(2000)


$2minutes = timerinit()
$5minutes = timerinit()
$20minutes = timerinit()


mins5()
mins20()
mins2()

Do
    if timerdiff($2minutes) > ((1000 * 60 * 2)-15000) Then mins2()
    if timerdiff($5minutes) > ((1000 * 60 * 5)-15000) Then mins5()
    if timerdiff($20minutes) > ((1000 * 60 * 20)-15000) Then mins20()
    
    tooltip(timerdiff($2minutes) & " / " & ((1000 * 60 * 2)-15000) & @crlf & timerdiff($5minutes) & " / " & ((1000 * 60 * 5)-15000) & @crlf & timerdiff($20minutes) & " / " & ((1000 * 60 * 20)-15000),0,0)
    sleep(1000)
until 1 = 2


    

func mins2()
    tooltip("2 minute buff round",0,0)
    $2minutes = timerinit()
    controlsend("Lineage II char3","","","/useshortcut 1 7" & "{enter}" ) ;bless sereph 2 minutes
    controlsend("Lineage II char2","","","/useskill Dance of concentration" & "{enter}" )
    sleep(5000)
    controlsend("Lineage II char2","","","/useskill Dance of the mystic" & "{enter}" )
    sleep(5000)
EndFunc

func mins5()
    tooltip("5 minute buff round",0,0)
    $5minutes = timerinit()
    controlsend("Lineage II char1","","","/useskill Prophecy of Water" & "{enter}" )
    sleep(5000)
EndFunc

func mins20()
    tooltip("20 minute buff round",0,0)
    controlsend("Lineage II char1","","","/useskill Improved movement" & "{enter}" )
    controlsend("Lineage II char3","","","/useshortcut 1 8" & "{enter}" ) ;
    sleep(5000)
    controlsend("Lineage II char1","","","/useskill Improved Shield defence" & "{enter}" )
    controlsend("Lineage II char3","","","/useshortcut 1 5" & "{enter}" ) ;bless sereph 2 minutes
    sleep(5000)
    controlsend("Lineage II char1","","","/useskill mana gain" & "{enter}" )
    controlsend("Lineage II char3","","","/useshortcut 1 9" & "{enter}" ) ;
    sleep(5000)
    controlsend("Lineage II char1","","","/useskill clarity" & "{enter}" )
    sleep(5000)
    controlsend("Lineage II char1","","","/useskill unholy resistance" & "{enter}" )
    sleep(5000)
    controlsend("Lineage II char1","","","/useskill divine protection" & "{enter}" )
    sleep(5000)
    controlsend("Lineage II char1","","","/useskill wild magic" & "{enter}" )
    sleep(5000)
    controlsend("Lineage II char1","","","/useskill regeneration" & "{enter}" )
    sleep(5000)
EndFunc

When that was not working, i tried something a LOT simpler. All it did was make my toon stand up and sit down, so i could see the difference or if it was actually doing anything...

hotkeyset("{capslock}","Go")


msgbox(0,"","select char1's window")
sleep(5000)
winsettitle("Lineage II","","Lineage II char1")
$go = 0


sleep(1000)
Do
if $go = 1 Then
    tooltip("Go ")
    controlsend("Lineage II char1","","","{F3}") ;f3 was hotkeyed to sit in game
    sleep(5000)
EndIf
if $go = 0 then tooltip("")
sleep(50)
until 1 = 2




Func go()
    if $go = 0 then
    $go = 1
Else
    $go = 0
EndIf
EndFunc

The result was as long as i kept lineage focused, it would be renamed as desired. However as soon as i lost focus on lineage (which is what i was aiming at) the lineage window would rename itself "Lineage II"

Is there any other way to differentiate between three windows with the same name and then send text to them?

Note:

There are three ways of doing something in game. One is to click the icon (clicking will not work for this, unless you can click inactive windows....)

The second is to use a F1 - F12 key, tied to one of many different actions

The third is to use /useshortcut # # (preset by the player, in this case me) or /useskill skillname

Link to comment
Share on other sites

Oh, before everyone goes "OMG BOTS!" please note that i play on a private server, granted what im doing is not promoted, its nothing that will likely get me banned over. using a bot to go out and level is one thing, using a bot to add buffs while you are actually there active on your chars is completely another. I dont NEED the bot to play, however it would make my life a lot easier, since i dont need to split focus all the time.

Just thought i'd clear that up.

- Edit -

Hey, i just remembered wingethandle... Is there a way i can use that command to do what i want?

- Edit -

Duhhhh i feel retarded >.< ya, wingethandle works even when the window is out of focus. Cool, i guess i answered my own question.

If anyone has any suggestions, feel free to post em here tho, its been forever since i coded, im pretty rusty.

- Edit -

Figured i'd post this in case anyone else has similar queries...

basically i changed

Tooltip("select char1's window",0,0)
    Do
    sleep(50)
    until _IsPressed(08) = 1
winsettitle("Lineage II","","Lineage II char1")
sleep(1000)
to
Tooltip("select char1's window",0,0)
    Do
    sleep(50)
    until _IsPressed(08) = 1
winsettitle("Lineage II","","Lineage II char1")
$char1 = wingethandle("Lineage II char1")
sleep(1000)

and instead of use "lineage II char1" i just use $char1 for defining which window to send the controls to. Pretty basic, dont know why i didnt think of it before...

Edited by pileot
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...