Jump to content

Script will only run on the active window


Recommended Posts

I have a script that will run, but only when the window is active. If i minimize that window to work on other things, it starts running the script on the window that I have active, not the desired window. Also, I have 2 windows with no unique identifiers (everything is the same), how do I run 2 different scripts at the same time and be able to choose which script runs on which window, and have them both running in the background on those windows so that I can work on other things?

Link to comment
Share on other sites

Thank you for your reply.

I don't want to use this command because I want to minimize and maximize manually without affecting the script.

WinSetState("Untitled - Notepad", "", @SW_MINIMIZE)

The problem I'm having is that I'm running to clients that are exactly the same. I run the script and it works great when the desired window is active. When I open the other window, it starts to run the script on that window. I have tried to differentiate between the two windows, even changing the window title, but to no avail. There is no text either, that will help to distinquish the two. I think the ControlSend command will work for me, but how do i use that and differentiate between the two windows?

Link to comment
Share on other sites

Thanks for replying. The pause key would work to pause the script when I have another window up, but I don't want that script to stop working on that specified window. I want the script to run continuously on the window whether it is the active window or not.

Link to comment
Share on other sites

I did use WinSetTitle to change the title and try to differentiate between the two windows, but I must not have been doing something right. I am running the game Shadowbane and want the script to run continuously on that window.

After I change the title, which Win* command would allow me to run the script in only that window? The WinActivate or WaitWinActive commands with the new title wouldn't work. The script would still switch to whichever window was the active window at the time.

Thanks a bunch for your help, I am a low level newb programmer and your help is much appreciated.

Link to comment
Share on other sites

So you are running 2 shadowbane windows right? Are you doing the same thing in each window? Or are you mouseclicking in one and sending keys in other? Will something like this work, you probably already tried this though.

Run("Notepad.exe")
Run("Notepad.exe")
WinWait("Untitled - Notepad")
WinSetTitle("Untitled - Notepad", "", "Notepad")
WinSetState("Notepad", "", @SW_MINIMIZE)
WinSetState("Untitled - Notepad", "", @SW_MINIMIZE)
ControlSend("Untitled - Notepad", "", "Edit1", "Default window")
ControlSend("Notepad", "", "Edit1", "Changed window name")

Link to comment
Share on other sites

Thanks a ton for your help, that actually solved the problem. I had to change the title in one window, and then use the controlsend function like you suggested. It works no matter what I have going or whether that is minimized or the active window. I am just sending keystrokes to the window to perform certain functions that i set up within the game. Changing the title and using controlsend solved everything. Thanks a ton for your help. Now I can do homework while the game plays without any interference. Thanks.

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