Jump to content

Multiple Windows Question


Michri
 Share

Recommended Posts

I'm attempting to make a basic script to send a keystroke to a background window.

The problem I am having is, when I run two instances of the same program, it will only send it to the instance which was most recently focused on. I either want to send it to both, or a specific one of the multiple instances - but the only entry I get when using the window info tool is "Handle". Is there anywhere in the ControlSend command that will accept Handle, so I can specify which window? If not, is there another command I should look into using in my script?

Link to comment
Share on other sites

I'm attempting to make a basic script to send a keystroke to a background window.

The problem I am having is, when I run two instances of the same program, it will only send it to the instance which was most recently focused on. I either want to send it to both, or a specific one of the multiple instances - but the only entry I get when using the window info tool is "Handle". Is there anywhere in the ControlSend command that will accept Handle, so I can specify which window? If not, is there another command I should look into using in my script?

I would ensure that each instance has a different title. Here's one way to do it.

$Title0 = "Title "
$Inst = 0
Do
    $Inst += 1
    $Title = $Title0 & $Inst
Until not WinExists($Title)

$MyGui = GUICreate($Title, ....
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I would ensure that each instance has a different title. Here's one way to do it.

$Title0 = "Title "
$Inst = 0
Do
    $Inst += 1
    $Title = $Title0 & $Inst
Until not WinExists($Title)

$MyGui = GUICreate($Title, ....
I'm somewhat new at this. Could you possibly walk me through what that script will do?

Essentially, my goal is to be able to send a keystroke to one instance of a game, to macro an ability on one character, while I play another character. The window title is the same in both instances of the game, and the only thing that shows up in the window info program is the handle, and window title (which are both the same, and dont seem to be of any use).

Link to comment
Share on other sites

The way I read it you are trying to use ControlSend with handles.

All "title" parameters in AutoIt accept a few things. Handles are one of them.. So if you just: ControlSend($hWnd,....) you're done. :)

So, if for example, the window handle was 0x001B05DE (taken from my active firefox window atm), and I want to send the keystroke "0", where would I put it in the handle in the line, exactly?

CODE
ControlSend("", "", "", "0")

Which of the 3 blank areas?

Link to comment
Share on other sites

So, if for example, the window handle was 0x001B05DE (taken from my active firefox window atm), and I want to send the keystroke "0", where would I put it in the handle in the line, exactly?

CODE
ControlSend("", "", "", "0")

Which of the 3 blank areas?

Title parameter, which is the first.

ControlSend(0x001B05DE, "", "", "0")

Link to comment
Share on other sites

Just to explain:

The handle of a window will be different everytime it is created, so you can't use a static value in your script. Using Manadar's code above will retrieve the handle to a window that exists and if you continue to use this handle (in the $hwnd variable) it will always refer to that specific window.

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