Jump to content

Manually select window?


Recommended Posts

Hi

In the startup of the script I would like to manually (by mouse) select the window where I will be running script. This is because the title of the window will every time be different.

What kind of code is needed to do that?

Thanks!

Link to comment
Share on other sites

It is a my own specific program where the title of the program will be different every time I open it. This is why I have to select window manually, because selecting of the window cannot be automatic.

Link to comment
Share on other sites

1 hour ago, FrancescoDiMuro said:

@USSSR
If the window's title doesn't change completely, but always have a part of it which is constant, then you can use REGEXPTITLE to match the window :)

So I found that there is a one constant thing in the title. It is the word information: "(1/8) - Information - Open 567884 - AG - \\Remote"

How would you make the code to choose this window?

Link to comment
Share on other sites

@USSSR
This could be one of many ways:

Local $hWinHandle = WinGetHandle("[REGEXPTITLE:(?i)^\(\d\/\d\) \- Information \-]")

But, as @Nine stated, try to use the CLASS of the Window, which you can find using the AutoItWindowInfo Tool :)

P.S.: OT, but congrats for the 1k reputation @Nine! :cheer:

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

25 minutes ago, FrancescoDiMuro said:

@USSSR
This could be one of many ways:

Local $hWinHandle = WinGetHandle("[REGEXPTITLE:(?i)^\(\d\/\d\) \- Information \-]")

But, as @Nine stated, try to use the CLASS of the Window, which you can find using the AutoItWindowInfo Tool :)

P.S.: OT, but congrats for the 1k reputation @Nine! :cheer:

I'm a newbie. I cant get the CLASS working.. please help how to use it in my case? :)

Link to comment
Share on other sites

1 minute ago, FrancescoDiMuro said:

@USSSR
Open the 
AutoIt Window Information Tool and use it one the window you are trying to automate;
then, post the content of the Summary tab here, and we'll help you through the development of the code you need :)

Actually I just noticed that CLASS wont work in this case. As I have also other windows with same CLASS.

Link to comment
Share on other sites

@USSSR
Run the code below and post the content of the SciTE console:

FindWindow()

Func FindWindow()
    
    Local $arrWinList
    
    $arrWinList = WinList()
    
    For $i = 1 To $arrWinList[0][0] Step 1
        If StringInStr($arrWinList[$i][0], "Information") Then ConsoleWrite("Title of the " & $i & " window = " & $arrWinList[$i][0] & @CRLF)
    Next
    
EndFunc

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "U:\xxxxxxx
Title of the 58 window =  (1/8) - Information - Open 567884 - AG - \\Remote
>Exit code: 0    Time: 0.4272

 

How to proceed the code to get it pressing button comands? I'm a bit struggling here in the start ;D

Link to comment
Share on other sites

You could use this also :

#include <Constants.au3>
;for testing purpose
GUICreate("(1/8) - Information - Open 567884 - AG - \\Remote")
GUISetState()
;your code starts here
Opt("WinTitleMatchMode", 2)
Local $hWnd = WinGetHandle("- Information -")
ConsoleWrite ($hWnd & @CRLF)
WinActivate($hWnd)
WinWaitActive($hWnd)

 

Link to comment
Share on other sites

@USSSR
Both functions should return the handle of the window you are looking for:

FindWindow()

Func FindWindow()

    Local $arrWinList, _
          $hdlWindow

    $arrWinList = WinList()

    For $i = 1 To $arrWinList[0][0] Step 1
        If StringInStr($arrWinList[$i][0], "Information") Then
            ConsoleWrite("Title of the " & $i & " window = " & $arrWinList[$i][0] & @CRLF)
            $hdlWindow = $arrWinList[$i][1]
            ExitLoop
        EndIf
    Next

    Return $hdlWindow

EndFunc

Func FindWindow()
    Return WinList("[REGEXPTITLE:\(\d+\/\d+\) \- Information \-]")[1][1]
EndFunc

In order to let the script works, you have to comment one of them.
By the way, this is your fishing rod; now it's time for you to make your own fishing and learn something from the help file :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

13 minutes ago, Nine said:

You could use this also :

#include <Constants.au3>
;for testing purpose
GUICreate("(1/8) - Information - Open 567884 - AG - \\Remote")
GUISetState()
;your code starts here
Opt("WinTitleMatchMode", 2)
Local $hWnd = WinGetHandle("- Information -")
ConsoleWrite ($hWnd & @CRLF)
WinActivate($hWnd)
WinWaitActive($hWnd)

 

This one worked :) Thanks thumbs up! Next time different fishing rod...

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