Search the Community
Showing results for tags '_taskbarset'.
-
I took some time to make something that will cover both monitors as to watch a movie on one and not have the other monitor shining. You may have a similar setup and like it. #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_type=a3x #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> #include <WinAPI.au3> Opt("MustDeclareVars", 1) Opt("GUICloseOnESC", 0) Opt("WinTitleMatchMode", 3) If _WinAPI_GetVersion() < '6.0' Then MsgBox(0, 'Error', 'Require Windows Vista or later.') Exit EndIf If WinExists("CoverScreen2") Then Exit ; this should never happen anyways Global $sTitle = "CoverScreen1" Global $iLeft = -1 If WinExists($sTitle) Then $iLeft = @DesktopWidth + 1000 ; my 2nd monitor is there $sTitle = "CoverScreen2" EndIf ; AppBar States Global Const $ABS_NORMAL = 0x0 Global Const $ABS_AUTOHIDE = 0x1 Global Const $ABS_ALWAYSONTOP = 0x2 Global Const $ABS_AUTOHIDEANDONTOP = 0x3 Global $IsTaskbarHidden = _IsTaskbarHidden() Global $_iDisplayState = -1 Global $Form2, $bgColor, $exit, $onTop, $minimize, $winMenu, $nMsg, $bttn_Taskbar $Form2 = GUICreate($sTitle, 557, 367, $iLeft, -1, BitOR($WS_SYSMENU, $WS_POPUP)) GUISetBkColor(0x000000) $bgColor = 0x404040 If @HOUR > 6 And @HOUR < 19 Then $bgColor = 0xB0B0B0 ; ..can't see the buttons during the day $exit = GUICtrlCreateLabel("X", 512, 11, 28, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 0, "Courier New") GUICtrlSetColor(-1, $bgColor) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $onTop = GUICtrlCreateLabel("o", 480, 12, 28, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 800, 0, "Courier New") GUICtrlSetColor(-1, $bgColor) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $minimize = GUICtrlCreateLabel("_", 451, 7, 28, 25, $SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Courier New") GUICtrlSetColor(-1, $bgColor) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $winMenu = GUICtrlCreateLabel("M", 14, 290, 28, 25, $SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Courier New") GUICtrlSetColor(-1, $bgColor) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $bttn_Taskbar = GUICtrlCreateLabel("T", 422, 11, 28, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 0, "Courier New") GUICtrlSetColor(-1, $bgColor) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) Local $iRestoreTaskbar = 0 Local $iRestoreTaskbarFirstState = $IsTaskbarHidden If $IsTaskbarHidden Then GUICtrlSetData($bttn_Taskbar, "t") EndIf GUISetState(@SW_MAXIMIZE) WinSetOnTop($Form2, "", 0) GUISetState(@SW_SHOWMINNOACTIVE) If $sTitle = "CoverScreen1" Then ShellExecute(@ScriptFullPath) ; <--- i have 2 monitors, this is to cover the 2nd screen, ; could have made just 1 big GUI ( WinGetPos("Program Manager") ) but, this is the way I did it. _DisplayState($Form2) ; this will tell the GUI to exit if the monitor is off, ; so when I wake the monitors this cover foreground won't be there. EndIf GUICtrlSetTip($exit, "close these windows") GUICtrlSetTip($onTop, "set these as topmost, or not") GUICtrlSetTip($minimize, "minimize this") GUICtrlSetTip($winMenu, "click the ""Start"" button") GUICtrlSetTip($bttn_Taskbar, "set taskbar to auto hide or normal") While 1 If $sTitle = "CoverScreen1" Then If MouseGetPos(1) > @DesktopHeight - 2 Then If MouseGetPos(0) > 10 Then WinActivate("[CLASS:Shell_TrayWnd;]", "") EndIf EndIf EndIf $nMsg = GUIGetMsg() If $_iDisplayState = 0 Then $nMsg = $GUI_EVENT_CLOSE $iRestoreTaskbar = 1 ; because, that's the way it was and the user did not choose to close it now EndIf Switch $nMsg Case $GUI_EVENT_CLOSE, $exit GUICtrlSetColor($exit, $bgColor - 0x202020) If $sTitle = "CoverScreen1" Then ControlClick("[CLASS:AutoIt v3 GUI; Title:CoverScreen2;]", "", "[CLASS:Static; INSTANCE:1]") Else ControlClick("[CLASS:AutoIt v3 GUI; Title:CoverScreen1;]", "", "[CLASS:Static; INSTANCE:1]") EndIf GUIDelete($Form2) If $iRestoreTaskbar Then If $iRestoreTaskbarFirstState Then _TaskBarSet($ABS_AUTOHIDEANDONTOP) Else _TaskBarSet($ABS_ALWAYSONTOP) EndIf EndIf ExitLoop Case $minimize GUICtrlSetColor($minimize, $bgColor + 0x202020) GUISetState(@SW_MINIMIZE) Sleep(200) GUICtrlSetColor($minimize, $bgColor) Case $onTop GUICtrlSetColor($onTop, $bgColor + 0x202020) If GUICtrlRead($onTop) == "O" Then WinSetOnTop($Form2, "", 0) GUICtrlSetData($onTop, 'o') Else WinSetOnTop($Form2, "", 1) GUICtrlSetData($onTop, 'O') EndIf Sleep(200) GUICtrlSetColor($onTop, $bgColor) Case $winMenu GUICtrlSetColor($winMenu, $bgColor - 0x202020) Send("^{ESC}") Sleep(200) GUICtrlSetColor($winMenu, $bgColor) Case $bttn_Taskbar GUICtrlSetColor($bttn_Taskbar, $bgColor - 0x202020) $IsTaskbarHidden = _IsTaskbarHidden() If $IsTaskbarHidden Then _TaskBarSet($ABS_ALWAYSONTOP) GUICtrlSetData($bttn_Taskbar, "T") Else _TaskBarSet($ABS_AUTOHIDEANDONTOP) GUICtrlSetData($bttn_Taskbar, "t") EndIf GUICtrlSetColor($bttn_Taskbar, $bgColor) If $sTitle = "CoverScreen1" Then ControlSetText("[CLASS:AutoIt v3 GUI; Title:CoverScreen2;]", "", "[CLASS:Static; INSTANCE:5]", GUICtrlRead($bttn_Taskbar)) Else ControlSetText("[CLASS:AutoIt v3 GUI; Title:CoverScreen1;]", "", "[CLASS:Static; INSTANCE:5]", GUICtrlRead($bttn_Taskbar)) EndIf EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DisplayState ; Description ...: Checks if a display is on or off. ; Syntax ........: _DisplayState() ; Parameters ....: GUI handle, or not, see remarks ; Return values..: Success - 1 = screen is on ; 0 = screen is off ; Failure - -1 and sets the @error flag to non-zero. ; Author ........: syk3s ; Modified ......: argumentum on 2015.05.26 ; Remarks .......: when a GUI handle is passed, the function will return "-2" and will remain resident. The state is held by Global $_iDisplayState ; Related .......: PG13, works on Win Vista and newer ; Link ..........: @@MsdnLink@@ RegisterPowerSettingNotification ; Example .......: No ; Original post..: https://www.autoitscript.com/forum/topic/152393-getdisplaystate-udf/#comment-1093495 ; =============================================================================================================================== Func _DisplayState($hWndGUI = 0, $MsgID = 0, $WParam = 0, $LParam = 0) ; ConsoleWrite('+ Func _DisplayState(' & $hWndGUI & ', ' & $MsgID & ', ' & $WParam & ', ' & $LParam & ' )' & @CRLF) Local Const $_GUID_MONITOR_POWER_ON = '{02731015-4510-4526-99E6-E5A17EBD1AEA}' Local Const $_tagGUID = "ulong Data1;ushort Data2;ushort Data3;byte Data4[8]" If IsDeclared($_iDisplayState) = 0 Then Global $_iDisplayState = -1 If $WParam = 0 And $LParam = 0 And $MsgID = 0 Then Global $_iDisplayState = -1 Local Const $_WM_POWERBROADCAST = 0x0218 Local $hTemp, $tGUID, $Ret If $hWndGUI Then $hTemp = $hWndGUI ; your Gui and stay resident. $_iDisplayState holds the value Else $hTemp = GUICreate("Display state temporary GUI") EndIf If IsHWnd($hTemp) = 0 Then Return SetError(1, 0, -1) EndIf If GUIRegisterMsg($_WM_POWERBROADCAST, "_DisplayState") = 0 Then Return SetError(2, 0, -1) EndIf ;register for a display state broadcast $tGUID = DllStructCreate($_tagGUID) If @error Then Return SetError(3, 0, -1) EndIf $Ret = DllCall('ole32.dll', 'uint', 'CLSIDFromString', 'wstr', $_GUID_MONITOR_POWER_ON, 'ptr', DllStructGetPtr($tGUID)) If (@error) Or ($Ret[0]) Then Return SetError(4, 0, -1) EndIf $Ret = DllCall('user32.dll', 'ptr', 'RegisterPowerSettingNotification', 'hwnd', $hTemp, 'ptr', DllStructGetPtr($tGUID), 'dword', 0) ;register for the event If (@error) Or (Not $Ret[0]) Then Return SetError(5, 0, -1) EndIf If $hWndGUI = 0 Then DllCall('user32.dll', 'int', 'UnregisterPowerSettingNotification', 'ptr', $Ret[0]) ;unregister GUIDelete($hTemp) Else Return SetError(0, 0, -2) EndIf If $_iDisplayState <> 0 And $_iDisplayState <> 1 Then Return SetError(6, 0, -1) Else Return $_iDisplayState EndIf Else Local $stPOWERBROADCAST_SETTING = DllStructCreate($_tagGUID & ";DWORD;byte[1]", $LParam) Local $aResult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", DllStructGetPtr($stPOWERBROADCAST_SETTING), "wstr", "", "int", 40) ;get string GUID back If $aResult[2] = $_GUID_MONITOR_POWER_ON Then $_iDisplayState = DllStructGetData($stPOWERBROADCAST_SETTING, 6, 1) EndIf EndIf EndFunc ;==>_DisplayState ; Detect whether the taskbar is hidden or not. Func _IsTaskbarHidden() ; https://www.autoitscript.com/wiki/Snippets_%28_Windows_Information_%29 ; Local Const $ABS_AUTOHIDE = 0x01, Local Const $ABM_GETSTATE = 0x00000004 Local $aReturn = DllCall('shell32.dll', 'uint', 'SHAppBarMessage', 'dword', $ABM_GETSTATE, 'ptr*', 0) If @error Then Return SetError(1, 0, 0) EndIf Return BitAND($aReturn[0], $ABS_AUTOHIDE) = $ABS_AUTOHIDE EndFunc ;==>_IsTaskbarHidden Func _TaskBarSet($iState) ; https://www.autoitscript.com/forum/topic/164237-multi-monitor-and-auto-hide-taskbar-interferes-with-script/ Local Const $ABM_SETSTATE = 0xA ; Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes. Local $tStruct = DllStructCreate("dword;int;uint;uint;int;int;int;int;int") DllStructSetData($tStruct, 1, DllStructGetSize($tStruct)) DllStructSetData($tStruct, 2, ControlGetHandle("Start", "", "Shell_TrayWnd")) DllStructSetData($tStruct, 9, $iState) Local $aRet = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", $ABM_SETSTATE, "ptr", DllStructGetPtr($tStruct)) If Not @error And $aRet[0] Then Return $aRet[0] EndIf Return SetError(1, 0, 0) EndFunc ;==>_TaskBarSet if you have a better idea, post it. Thanks PS: to hide the mouse, move it all the way to the right. All the way to the bottom will popup the taskbar.
- 1 reply
-
- _istaskbarhidden
- _displaystate
-
(and 2 more)
Tagged with: