Mustafa23 Posted November 10, 2020 Posted November 10, 2020 Hello all, FYI - I'm not a programmer, but sometimes I like to force myself to learn something new. So, I'm trying to do few tasks on multiple applications. run applications if not exist close duplicated windows of the applications disable Title bar buttons ( Minimize, Maximize, and Close) auto login to the first application. organize the windows Window1 = Maximized WinMove($window2, "", 563, 387, 725, 295) WinMove($window3, "", 563, 61, 725, 365) script keep checking (Loop). I hope that you will be able to provide me with better script. thank you, expandcollapse popup#include <GuiMenu.au3> While 1 ;list new all the windows with assign variable local $window1 = WinGetHandle("CVPSnet - Version 2.0") local $window2 = WinGetHandle("CVPSnet - Parking Monitor Main Page") local $window3 = WinGetHandle("CVPSnet - Requests Main Page") local $window4 = WinGetHandle("STS Request Light") local $window5 = WinGetHandle("On-Screen Keyboard") ;list all the windows in this line to close duplicated windows ---- Not working ;$aPID = WinList ("[REGEXPTITLE:(?i)(.*STS Request Light.*|.*CVPSnet - Requests Main Page.*|.*CVPSnet - Parking Monitor Main Page.*)]") ;close duplicated windows ;for $i = 2 to $aPID[0][0] ;WinClose($aPID[$i][0]) ;Next ;start app if not started. If NOT WinExists($window1) Then Run("C:\Program Files\cvpsNET\Bin\cvpsnet.exe") EndIf ;WinWait($window1) If NOT WinExists($window2) Then Run('"C:\Program Files\cvpsNET\RequestMonitor\Bin\CVPS_RequestMonitor.exe" "parking"') EndIf ;WinWait($window2) If NOT WinExists($window3) Then Run("C:\Program Files\cvpsNET\RequestMonitor\Bin\CVPS_RequestMonitor.exe") EndIf ;WinWait($window3) If NOT WinExists($window4) Then Run("C:\Program Files\STSRequestLight\STSRequestLight.exe") EndIf ;WinWait($window4) If @OSArch = "x64" Then DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turns On 64 Bit Redirection If NOT WinExists($window5) Then ShellExecute("osk.exe") EndIf DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turns Off 64 Bit Redirection EndIf ;window size and location WinMove($window2, "", 563, 387, 725, 295) WinMove($window3, "", 563, 61, 725, 365) ;disable title bar buttons and menu ConsoleWrite('+ Window Handle: ' & $window1 & @CRLF) DisableButton($window1, $SC_CLOSE) DisableButton($window1, $SC_RESTORE) DisableButton($window1, $SC_MOVE) DisableButton($window1, $SC_MINIMIZE) DisableButton($window1, $SC_size) WinSetState($window1,"", @SW_MAXIMIZE) ;window2 ConsoleWrite('+ Window Handle: ' & $window2 & @CRLF) DisableButton($window2, $SC_CLOSE) DisableButton($window2, $SC_MAXIMIZE) DisableButton($window2, $SC_RESTORE) DisableButton($window2, $SC_MOVE) DisableButton($window2, $SC_MINIMIZE) DisableButton($window2, $SC_size) WinSetState($window2,"", @SW_RESTORE ) WinSetOnTop($window2, "", $WINDOWS_ONTOP) ;window3 ConsoleWrite('+ Window Handle: ' & $window3 & @CRLF) DisableButton($window3, $SC_CLOSE) DisableButton($window3, $SC_MAXIMIZE) DisableButton($window3, $SC_RESTORE) DisableButton($window3, $SC_MOVE) DisableButton($window3, $SC_MINIMIZE) DisableButton($window3, $SC_size) WinSetState($window3,"", @SW_RESTORE) WinSetOnTop($window3, "", $WINDOWS_ONTOP) ;window4 ConsoleWrite('+ Window Handle: ' & $window4 & @CRLF) DisableButton($window4, $SC_CLOSE) DisableButton($window4, $SC_MAXIMIZE) DisableButton($window4, $SC_RESTORE) DisableButton($window4, $SC_MOVE) DisableButton($window4, $SC_MINIMIZE) DisableButton($window4, $SC_size) WinSetState($window4,"", @SW_MINIMIZE ) ;window5 ConsoleWrite('+ Window Handle: ' & $window5 & @CRLF) DisableButton($window5, $SC_CLOSE) DisableButton($window5, $SC_MAXIMIZE) DisableButton($window5, $SC_RESTORE) ;DisableButton($window5, $SC_MOVE) ;DisableButton($window5, $SC_MINIMIZE) ;DisableButton($window5, $SC_size) WinSetState($window5,"", @SW_RESTORE ) Sleep (2500) WEnd ;Do Not Change (Window settings) Func DisableButton($hWnd, $iButton) $hSysMenu = _GUICtrlMenu_GetSystemMenu($hWnd, 0) _GUICtrlMenu_RemoveMenu($hSysMenu, $iButton, False) _GUICtrlMenu_DrawMenuBar($hWnd) EndFunc Func EnableButton($hWnd, $iButton) $hSysMenu = _GUICtrlMenu_GetSystemMenu($hWnd, 1) _GUICtrlMenu_RemoveMenu($hSysMenu, $iButton, False) _GUICtrlMenu_DrawMenuBar($hWnd) EndFunc
Mustafa23 Posted November 10, 2020 Author Posted November 10, 2020 Currently the script above is opening the applications with no issues and setting the windows the way how i want, but no auto login to the application with username and password and the 2 small windows should be always above the main application not above everything as showing in the 2nd pic
abberration Posted November 10, 2020 Posted November 10, 2020 I don't know if this would work, but perhaps use WinActivate to make the windows active in the correct order - Window 1, then 2, 3 and 4, added to the end of your script. Something like: For $i = 1 To 5 WinActivate(Eval("window" & $i)) Next (not tested, just an idea). Easy MP3 | Software Installer | Password Manager
Mustafa23 Posted November 11, 2020 Author Posted November 11, 2020 1 hour ago, abberration said: I don't know if this would work, but perhaps use WinActivate to make the windows active in the correct order - Window 1, then 2, 3 and 4, added to the end of your script. Something like: For $i = 1 To 5 WinActivate(Eval("window" & $i)) Next (not tested, just an idea). I have tested it and it worked but since there is "While" on the script it it will keep doing the same task over and over and the windows will be always on top. perhaps you can take a look to restructure the tasks?
Mustafa23 Posted November 11, 2020 Author Posted November 11, 2020 3 hours ago, abberration said: I don't know if this would work, but perhaps use WinActivate to make the windows active in the correct order - Window 1, then 2, 3 and 4, added to the end of your script. Something like: For $i = 1 To 5 WinActivate(Eval("window" & $i)) Next (not tested, just an idea). Thank you for giving me the idea of "For $i = 1 To 5" I did some cleanup. expandcollapse popup#include <GuiMenu.au3> While 1 ;list new all the windows with assign variable local $window1 = WinGetHandle("CVPSnet - Version 2.0") local $window2 = WinGetHandle("CVPSnet - Parking Monitor Main Page") local $window3 = WinGetHandle("CVPSnet - Requests Main Page") local $window4 = WinGetHandle("STS Request Light") local $window5 = WinGetHandle("On-Screen Keyboard") ;start app if not started. If NOT WinExists($window1) Then Run("C:\Program Files\cvpsNET\Bin\cvpsnet.exe") EndIf If NOT WinExists($window2) Then Run('"C:\Program Files\cvpsNET\RequestMonitor\Bin\CVPS_RequestMonitor.exe" "parking"') EndIf If NOT WinExists($window3) Then Run("C:\Program Files\cvpsNET\RequestMonitor\Bin\CVPS_RequestMonitor.exe") EndIf If NOT WinExists($window4) Then Run("C:\Program Files\STSRequestLight\STSRequestLight.exe", "", @SW_HIDE, BitOr($WS_POPUP,$WS_DLGFRAME)) EndIf If @OSArch = "x64" Then DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turns On 64 Bit Redirection If NOT WinExists($window5) Then ShellExecute("osk.exe") EndIf DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turns Off 64 Bit Redirection EndIf ;window size and location WinMove($window2, "", 563, 387, 725, 295) WinMove($window3, "", 563, 61, 725, 365) For $i = 1 To 4 ConsoleWrite('+ Window Handle: ' & ("window" & $i)& @CRLF) DisableButton(Eval("window" & $i),$SC_CLOSE) DisableButton(Eval("window" & $i),$SC_RESTORE) DisableButton(Eval("window" & $i),$SC_MOVE) DisableButton(Eval("window" & $i),$SC_MINIMIZE) DisableButton(Eval("window" & $i),$SC_size) DisableButton(Eval("window" & $i),$SC_MAXIMIZE) Next For $n = 5 to 5 ConsoleWrite('+ Window Handle: ' & ("window" & $n)& @CRLF) DisableButton(Eval("window" & $n),$SC_CLOSE) DisableButton(Eval("window" & $n),$SC_RESTORE) DisableButton(Eval("window" & $n),$SC_MINIMIZE) DisableButton(Eval("window" & $n),$SC_size) Next For $w = 2 To 3 WinActivate(Eval("window" & $w)) Next Sleep (2500) WEnd ;Do Not Change (Window settings) Func DisableButton($hWnd, $iButton) $hSysMenu = _GUICtrlMenu_GetSystemMenu($hWnd, 0) _GUICtrlMenu_RemoveMenu($hSysMenu, $iButton, False) _GUICtrlMenu_DrawMenuBar($hWnd) EndFunc
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