Sign in to follow this  
Followers 0
RunningBot

Changing windows?

21 posts in this topic

Ok when i got my script running for a bot for a game i want the script to keep running while i leave the window it will still run? How would i do this?

this is the script i use. i kind of new to the sort of stuff and try looking on the forum for my answer but not luck

While 1

Sleep(45000)

MouseClick("left", 515, 680) ;Auto Start

;Resets ball

Send("{d down}")

Sleep(4000)

Send("{d up}")

Send("{s down}")

Sleep(4000)

Send("{s up}")

Send("{w down}")

Sleep(2700)

Send("{w up}")

Send("{a down}")

Sleep(1400)

send("{a up}")

Send("{w down}")

Sleep(4850)

Send("{w up}")

Send("{d down}")

Sleep(1300)

Send("{d up}")

Send("{a down}")

Sleep(1300)

Send("{a up}")

Send("{s down}")

Sleep(6000)

Send("{s up}")

;No Auto Kick

Send("{c down}")

Sleep(1810000)

Send("{c up}")

WEnd

Share this post


Link to post
Share on other sites



Look at ControlClick and ControlSend.

MouseClick and Send only works on the active window.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

So if i add this and replace the sent parts with control part i can run the script without the window being active?

Share this post


Link to post
Share on other sites

Yes. You will need to get control handles though. You can use ControlSend with just a window handle as well.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

Process handle i tryed looking for it not much info on it could you explain what it does and where i might find info on it?

Share this post


Link to post
Share on other sites

See WinGetHandle and ControlGetHandle then Controls in the help file.

From there you should be able to send keys to an inactive window using ControlSend.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

this is what i got so far i can get it to click start find controlclick works now it just the controlsent i can't and adding a delay to key like 5 seocnds

While 1

Sleep(2000)

$hWin = WinGetHandle("[CLASS:S4 Client; TITLE:S4 Client]")

ControlClick($hWin, "", "", "Left", 2, 510, 670)

;Resets ball

$handle = ControlGetHandle("[CLASS:S4 Client]", "", "")

ControlSend($handle, "", "", "d")

Send("{s down}")

Sleep(4000)

Send("{s up}")

Send("{w down}")

Sleep(2700)

Send("{w up}")

Send("{a down}")

Sleep(1400)

send("{a up}")

Send("{w down}")

Sleep(4850)

Send("{w up}")

Send("{d down}")

Sleep(1300)

Send("{d up}")

Send("{a down}")

Sleep(1300)

Send("{a up}")

Send("{s down}")

Sleep(6000)

Send("{s up}")

;No Auto Kick

Send("{c down}")

Sleep(1810000)

Send("{c up}")

WEnd

Share this post


Link to post
Share on other sites

Something like

Opt("SendKeyDelay", 5000) ; adds 5 seconds between key strokes. You may not ned the sleeps

While 1
    Sleep(2000)
    $hWin = WinGetHandle("[CLASS:S4 Client; TITLE:S4 Client]")
    ControlClick($hWin, "", "", "Left", 2, 510, 670)

    ;Resets ball
    $handle = ControlGetHandle("[CLASS:S4 Client]", "", "")
    ControlSend($handle, "", "", "d")

    ControlSend($handle, "", "", "{s down}")
    Sleep(4000)
    ControlSend($handle, "", "", "{s up}")

    ControlSend($handle, "", "", "{w down}")
    Sleep(2700)
    ControlSend($handle, "", "", "{w up}")

    ControlSend($handle, "", "", "{a down}")
    Sleep(1400)
    ControlSend($handle, "", "", "{a up}")

    ControlSend($handle, "", "", "{w down}")
    Sleep(4850)
    ControlSend($handle, "", "", "{w up}")

    ControlSend($handle, "", "", "{d down}")
    Sleep(1300)
    ControlSend($handle, "", "", "{d up}")

    ControlSend($handle, "", "", "{a down}")
    Sleep(1300)
    ControlSend($handle, "", "", "{a up}")

    ControlSend($handle, "", "", "{s down}")
    Sleep(6000)
    ControlSend($handle, "", "", "{s up}")

    ;No Auto Kick
    ControlSend($handle, "", "", "{c down}")
    Sleep(1810000)
    ControlSend($handle, "", "", "{c up}")
WEnd


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

how do i add it so it different delays for the keys ? so like {s down} is 4 seconds and {w down} is 6 seconds

Share this post


Link to post
Share on other sites

Not sure how to do that other than sleep calls like you already have. The SendKeyDelay (Option), SendKeyDownDelay (Option) apply to the whole script.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

Not sure how to do that other than sleep calls like you already have. The SendKeyDelay (Option), SendKeyDownDelay (Option) apply to the whole script.

so is there another type of command ? So i want it to send keystroke at different times.

Share this post


Link to post
Share on other sites

Not that I know of.

You could do something like

;~  ControlSendWait(handle, "string", delay)
Func ControlSendWait($handle, $string, $delay = 0)
    ControlSend($handle, "", "", $string)
    Sleep($delay)
EndFunc   ;==>ControlSendWait

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

on my script the keys are not being send to the window the click works fine it just the keystrokes r not.

;Resets ball

$handle = ControlGetHandle("[CLASS:S4 Client TITLE:S4 Client]" , "" , "")

ControlSend($handle, "", "{d down}", "")

Sleep(4000)

ControlSend($handle, "", "{d down}", "")

ControlSend($handle, "", "", "{s down}")

Sleep(4000)

ControlSend($handle, "", "", "{s up}")

ControlSend($handle, "", "", "{w down}")

Sleep(2700)

ControlSend($handle, "", "", "{w up}")

ControlSend($handle, "", "", "{a down}")

Sleep(1400)

ControlSend($handle, "", "", "{a up}")

ControlSend($handle, "", "", "{w down}")

Sleep(4850)

ControlSend($handle, "", "", "{w up}")

ControlSend($handle, "", "", "{d down}")

Sleep(1300)

ControlSend($handle, "", "", "{d up}")

ControlSend($handle, "", "", "{a down}")

Sleep(1300)

ControlSend($handle, "", "", "{a up}")

ControlSend($handle, "", "", "{s down}")

Sleep(6000)

ControlSend($handle, "", "", "{s up}")

;No Auto Kick

ControlSend($handle, "", "", "{c down}")

Sleep(1810000)

ControlSend($handle, "", "", "{c up}")

Share this post


Link to post
Share on other sites

does $handle = ControlGetHandle("[CLASS:S4 Client TITLE:S4 Client]" , "" , "") return the correct handle? Use the info tool and ConsoleWrite to check.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

does $handle = ControlGetHandle("[CLASS:S4 Client TITLE:S4 Client]" , "" , "") return the correct handle? Use the info tool and ConsoleWrite to check.

do you mean if i used the right CLASS AND title then yes i have

Share this post


Link to post
Share on other sites

No, is $handle correct according to the Info tool. Start the program then make sure what ControlGetHandle returns is the same as what the info tool gives.

Also, does ControlSend commands have to go to the control, or does ControlSend($hWin, "", "{d down}", "") work?


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

No, is $handle correct according to the Info tool. Start the program then make sure what ControlGetHandle returns is the same as what the info tool gives.

Also, does ControlSend commands have to go to the control, or does ControlSend($hWin, "", "{d down}", "") work?

ok the handle to the window is :0x001E029E and i try that part ControlSend($hWin, "", "{d down}", "") and it did not work.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Ok i can't get the ControlSent to work i can get controlclick to work but not controlsent am i missing something?

While 1
    Sleep(2000)
    $hWin = WinGetHandle("S4 Client")
    ControlClick($hWin, "", "", "Left", 2, 510, 670)
    
    ;Resets ball

    ControlSend($hWin, "", "", "{d down}")
    Sleep(4000)
    ControlSend($hWin, "", "", "{d up}")
    
    ControlSend($hWin, "", "", "{s down}")
    Sleep(4000)
    ControlSend($hWin, "", "", "{s up}")

    ControlSend($hWin, "", "", "{w down}")
    Sleep(2700)
    ControlSend($hWin, "", "", "{w up}")

    ControlSend($hWin, "", "", "{a down}")
    Sleep(1400)
    ControlSend($hWin, "", "", "{a up}")

    ControlSend($hWin, "", "", "{w down}")
    Sleep(4850)
    ControlSend($hWin, "", "", "{w up}")

    ControlSend($hWin, "", "", "{d down}")
    Sleep(1300)
    ControlSend($hWin, "", "", "{d up}")

    ControlSend($hWin, "", "", "{a down}")
    Sleep(1300)
    ControlSend($hWin, "", "", "{a up}")

    ControlSend($hWin, "", "", "{s down}")
    Sleep(6000)
    ControlSend($hWin, "", "", "{s up}")

    ;No Auto Kick
    ControlSend($hWin, "", "", "{c down}")
    Sleep(1810000)
    ControlSend($hWin, "", "", "{c up}")
WEnd
Edited by RunningBot

Share this post


Link to post
Share on other sites

As the help file indicates, controlsend does not work all the time and sometimes the control does require focus. I have used ContolSend to send controls to a window and control before.

Looking and your keys, I don't think "{d down}" is correct. With send, try "d{down}". See Send or Send Key List for more info.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

Send("{a down}") ;Holds the A key down

Function Send

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
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
Sign in to follow this  
Followers 0