HurleyShanabarger Posted March 17, 2022 Posted March 17, 2022 Hello, I want to check if a the same script is already running and if so I would like to restore the application window and focus on the main or better said currently active window. Using _Singleton or _SingletonPID will help me to get the PID of the running process. When trying to get the handle of the window using a combination of WinList and WinGetProcess I am getting a list of windows for a process and I can filter to get the enabled, existing and visible windows only. Up to here everything works fine, but if the application window is minimized, I am not able to detect the active window. For know I would solve this using a hidden label within the script, and register $WM_SETTEXT using GUIRegisterMsg20 and chaning the text of the label from the second instance. A change of the label text will then trigger the restore/focus event on the first instance on the script. But my gut tells me, there must be an easier way...
Nine Posted March 17, 2022 Posted March 17, 2022 Post a runable example using your strategy so we can see exactly what you want to achieve. “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Solution HurleyShanabarger Posted March 17, 2022 Author Solution Posted March 17, 2022 Found the solution, which is working for me! Func _WinRestoreByPid(Const $iPid) Local $arWndw = _ProcessGetWinList($iPid, 1) If @error Then Return SetError(0x01) For $iWndw = 1 To UBound($arWndw) - 1 WinSetState($arWndw[$iWndw][1], "", @SW_RESTORE) WinActivate($arWndw[$iWndw][1]) Next EndFunc ;==>_WinRestoreByPid
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