USSSR Posted March 9, 2021 Share Posted March 9, 2021 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 More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 @USSSR Could you please tell us which application are you trying to select? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 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 More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 @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 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Nine Posted March 9, 2021 Share Posted March 9, 2021 Use CLASS (see Title special definition in WinGetHandle of help file) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 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 More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 (edited) @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! Edited March 9, 2021 by FrancescoDiMuro Nine 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 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! 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 More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 @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 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 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 More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 @USSSR Did you try the REGEXPTITLE method then? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 Just now, FrancescoDiMuro said: @USSSR Did you try the REGEXPTITLE method then? YES and your example does not activate the window. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 @USSSR Post the code and please, don't quote the answer everytime Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 First in the code I have just this: Local $hWinHandle = WinGetHandle("[REGEXPTITLE:(?i)^\(\d\/\d\) \- Information \-]") Then CTRL+T Send("^{t}"); Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 @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: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 >"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 More sharing options...
Nine Posted March 9, 2021 Share Posted March 9, 2021 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) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 9, 2021 Share Posted March 9, 2021 @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: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
USSSR Posted March 9, 2021 Author Share Posted March 9, 2021 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now