Sign in to follow this  
Followers 0
MiniPlop

Send keys to an inactive window

2 posts in this topic

FYI, I used the search fuction but I wasn't unable to find a solution. Sorry.

 

Hello, I'd like to know how can I convert my script in order to work on an Inactive Window so I can do other stuff while the script if ruining in the specific window/program and doesn't need to be focused. I saw the you have to use a ControlSend function, when I replace the "Send" functions of my script to "ControlSend" it just crashes, an error window pops up. Any help will be aprecciate it. Thanks in Advance

WinActivate("CS")
Opt("SendKeyDownDelay", 100)
Global $Runner

HotKeySet("{F10}", "start")
HotKeySet("{F11}", "stop")

While 1
    Sleep(500)
WEnd

; -------- Functions -------------------

Func start()
    $Runner = Not $Runner

    While $Runner
        Send("{LEFT down}")
sleep(2500)
Send("{LEFT up}")
sleep(1000)
Send("{LCTRL 350}")
sleep(1000)
Send("{LEFT down}")
sleep(3500)
Send("{LEFT up}")
sleep(2000)
Send("{DOWN down}")
Send("{LALT}")
Send("{DOWN up}")
sleep(2000)
Send("{LEFT down}")
sleep(1000)
Send("{LEFT up}")
sleep(1000)
Send("{RIGHT down}")
sleep(3000)
Send("{RIGHT up}")
sleep(1000)
Send("{LCTRL 350}")
sleep(1000)
Send("{RIGHT down}")
sleep(3000)
Send("{RIGHT up}")
sleep(5000)
Send("{RIGHT down}")
sleep(2000)
Send("{RIGHT up}")
sleep(1000)
Send("{UP down}")
Send("{d}")
Send("{UP up}")
sleep(1000)

    WEnd
EndFunc   ;==>start


Func stop()
    Exit
EndFunc   ;==>stop

 

Share this post


Link to post
Share on other sites



@MiniPlop, welcome to the forum. Take a look at the Window Info Tool, in the same directory where you installed AutoIt. If you can get information on the window's controls you would like to interact with, you can then use commands like ControlSend and ControlClick to target the window specifically, whether it is active or not.


√-1 2^3 ∑ π, and it was delicious!

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