Jump to content

Multiple Windows Open need to get each ID and put into a Variable


Recommended Posts

I wasn't sure on how to go about this as I am very new to AutoIt, but here we go.

The following code below is from another member from a different site who helped me. It allows me to create variables for each program that has multiple instances running.

(Example: 5 Internet Explorer Browsers)

It will prompt me and ask that I hover over the window I wish to use and hit the middle mouse button. Shortly after it will tell me how many of that program is running and ask what I would like to name them.

It allows me to take each instance and give them a name that I can later on call to use.

My problem comes in when this is a AHK code and from what I have seen they are different, but are similar in some ways. As I said I am really new to AutoIt so I'm not sure on how I could convert this properly into a AutoIt code.

Any help would be greatly appreciated.

SetTitleMatchMode, 2
CoordMode, pixel, screen
Coordmode, mouse, screen

; Hover over one of the windows
SoundBeep, 750
tooltip, place mouse over the window you want to identify. press middle mouse button, 100, 0 
; press the middle mouse button to identify that window
keywait, MButton, D
keywait, MButton
mousegetpos, w1mx, w1my, w1id
; then get the window title from the id
wingettitle, w1title, ahk_id %w1id%
msgbox,0x1020, , This window's id and title are`nId:`t%w1id%`ntitle:`t%w1title%
; with that title find all windows that match that title 
WinGet, winlist, List, %w1title%
; make a displayable string showing the list of ids
str =
loop %winlist%
{    thisid := winlist%A_Index%
     str = %str%`n%thisid%
}
msgbox, Number of matching windows = %winlist%%str%
; then to use any window in the list you simply activate it using it's id
;If (winlist)
;{   random, thiswin, 1, %winlist% ;<-- pick a random window from the list
;   wid := winlist%thiswin%
;   msgbox,0x1020,,Activating window#: %thiswin% id: %wid%
;   winactivate, ahk_id %wid%
;   click
;}

str =
Loop %winlist% ;<-- used from the example i posted earlier
{   thisid := winlist%A_Index% ; gets the id
     thisid = ahk_id %thisid%
    winactivate, %thisid%
    Inputbox, choice, ,what name do you want to give this window?
    If (Errorlevel) ;<-- cancel was pressed
    {   choice = NoName%A_Index%
    }
    %choice% = %thisid%
   str = %str%name: %choice%`tid:%thisid%`n
}
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...