wesleyhw Posted September 13 Share Posted September 13 I have a application run on the system with minimized window state, and I want to restoring it then minimized when execute the AutoIt script, but I had try it WinSetState restore but not works, (please check the Example2() function) I also try Notepad.exe the default application in windows, and it works well, (please check the Example() function) Is it the application limitation? or does there any suggestion thanks in advance for any reply. expandcollapse popupFunc Example() WinActivate("[TITLE:Notepad]") Local $hWndNote = WinWait("[CLASS:Notepad]", "", 3) Sleep(500) Local $state = WinGetState("MPTool") If BitAND($state, 4) Then ConsoleWrite("MPTool is SW_MINIMIZE" & @CRLF) Else ConsoleWrite("MPTool is not SW_MINIMIZE" & @CRLF) EndIf WinSetState($hWndNote, "", @SW_RESTORE) ConsoleWrite("Notepad SW_RESTORE" & @CRLF) Sleep(500) WinSetState($hWndNote, "", @SW_MINIMIZE) ConsoleWrite("Notepad SW_MINIMIZE" & @CRLF) Sleep(500) EndFunc Func Example2() WinActivate("[TITLE:MyTool]") Local $hWndTool = WinWait("[TITLE:MyTool]", "", 3) Sleep(500) Local $state = WinGetState("MyTool") If BitAND($state, 4) Then ConsoleWrite("MyTool is SW_MINIMIZE" & @CRLF) WinSetState($hWndTool, "", @SW_RESTORE) Else ConsoleWrite("MyTool is not SW_MINIMIZE" & @CRLF) EndIf Local $windowHandle = WinGetHandle("MyTool") If $windowHandle <> "" Then WinSetState($windowHandle, "", @SW_RESTORE) ConsoleWrite("MyTool SW_RESTORE >>>" & @CRLF) Else ConsoleWrite("MyTool does not exist") EndIf WinSetState($hWndTool, "", @SW_RESTORE) ConsoleWrite("MPTool SW_RESTORE" & @CRLF) Sleep(500) WinSetState($hWndTool, "", @SW_MINIMIZE) ConsoleWrite("MyTool SW_MINIMIZE" & @CRLF) Sleep(500) EndFunc Example() Example2() Link to comment Share on other sites More sharing options...
ioa747 Posted September 13 Share Posted September 13 (edited) expandcollapse popupExample() Func Example() Local $hWndNote = WinWait("[CLASS:Notepad]", "", 3) WinActivate($hWndNote) ConsoleWrite("- Notepad WinActivate" & @CRLF) _WinShowState($hWndNote) Sleep(3000) WinSetState($hWndNote, "", @SW_MINIMIZE) ConsoleWrite("- Notepad SW_MINIMIZE" & @CRLF) _WinShowState($hWndNote) Sleep(3000) WinActivate($hWndNote) ConsoleWrite("- Notepad WinActivate" & @CRLF) ;~ WinSetState($hWndNote, "", @SW_RESTORE) ;~ ConsoleWrite("- Notepad @SW_RESTORE" & @CRLF) _WinShowState($hWndNote) Sleep(3000) EndFunc ;==>Example Func _WinShowState($hWnd) $state = WinGetState($hWnd) ConsoleWrite("$state=" & $state) If BitAND($state, 16) Then ConsoleWrite(" is minimized" & @CRLF) Else ConsoleWrite(" not minimized" & @CRLF) EndIf ConsoleWrite("" & @CRLF) EndFunc ;~ $WIN_STATE_EXISTS (1) = Window exists ;~ $WIN_STATE_VISIBLE (2) = Window is visible ;~ $WIN_STATE_ENABLED (4) = Window is enabled ;~ $WIN_STATE_ACTIVE (8) = Window is active ;~ $WIN_STATE_MINIMIZED (16) = Window is minimized ;~ $WIN_STATE_MAXIMIZED (32) = Window is maximized Edit: use WinActivate($hWndNote) to restore Edited September 13 by ioa747 wesleyhw 1 I know that I know nothing Link to comment Share on other sites More sharing options...
wesleyhw Posted September 13 Author Share Posted September 13 thanks for the example cpde, I had modified my code as below, If BitAND($state, 16) make sure its under minimize state, but still only could restore Notepad.exe, does not work on my tool Link to comment Share on other sites More sharing options...
ioa747 Posted September 13 Share Posted September 13 use WinActivate($hWndNote) to restore I know that I know nothing Link to comment Share on other sites More sharing options...
wesleyhw Posted September 13 Author Share Posted September 13 yes, I tried it as well, If BitAND($state, 16) Then ConsoleWrite("MPTool is SW_MINIMIZE >>>" & @CRLF) WinSetState($hWndTool, "", @SW_RESTORE) Local $hWndNote = WinWait("[TITLE:MPTool]", "", 3) WinActivate($hWndNote) ConsoleWrite("MPTool is SW_MINIMIZE <<<" & @CRLF) Else ConsoleWrite("MPTool is not SW_MINIMIZE" & @CRLF) EndIf doesn't work on my tool, its wired .. Link to comment Share on other sites More sharing options...
Solution ioa747 Posted September 13 Solution Share Posted September 13 if MPTool is running with elevated privileges then the script will #RequireAdmin at the top wesleyhw and pixelsearch 2 I know that I know nothing Link to comment Share on other sites More sharing options...
wesleyhw Posted September 13 Author Share Posted September 13 omg, this works, #RequireAdmin thank you so much ioa747 1 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