Jump to content

Changing windows?


Recommended Posts

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

Link to comment
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]

Link to comment
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]

Link to comment
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]

Link to comment
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

Link to comment
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]

Link to comment
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]

Link to comment
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.

Link to comment
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]

Link to comment
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}")

Link to comment
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]

Link to comment
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]

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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]

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