#include <GUIConstantsEx.au3>
Opt("WinWaitDelay", 10)
$hGUI = GUICreate("Test")
GUISetState(@SW_SHOW, $hGUI)
AdlibRegister('_SetOnTopOfDesktop', 10)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _SetOnTopOfDesktop()
If WinActive("[REGEXPCLASS:^(Progman|WorkerW)$]") Then
WinActivate($hGUI)
EndIf
EndFunc
Замени WinActivate($hGUI) на WinSetState($hGUI, '', @SW_RESTORE).невозможно выделить или щелкнуть по элементам рабочего стола
#include <WinAPI.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
Opt("WinWaitDelay", 10)
$hGUI = GUICreate("Test",150,100,500,300,$WS_POPUP, $WS_EX_TOOLWINDOW+$WS_EX_LAYERED)
GUISetBkColor(0x000001)
GUISetState(@SW_SHOW, $hGUI)
$CMD1 = GUICtrlCreateButton("", 0, 0, 70, 60)
_WinAPI_SetLayeredWindowAttributes($hgui, 0x000001, 0, $LWA_COLORKEY)
AdlibRegister('_SetOnTopOfDesktop', 10)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _SetOnTopOfDesktop()
If WinActive("[REGEXPCLASS:^(Progman|WorkerW)$]") Then
WinSetState($hGUI, '', @SW_RESTORE)
EndIf
EndFunc
#include <WinAPI.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
$iFlag = 0
Opt("WinWaitDelay", 10)
$hGUI = GUICreate("Test", 150, 100, 500, 300, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
GUISetBkColor(0x000001)
GUISetState(@SW_SHOW, $hGUI)
$CMD1 = GUICtrlCreateButton("", 0, 0, 70, 60)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0x000001, 0, $LWA_COLORKEY)
AdlibRegister('_SetOnTopOfDesktop', 10)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _SetOnTopOfDesktop()
If Not WinActive("[REGEXPCLASS:^(Progman|WorkerW)$]") And Not WinActive($hGUI) Then
$iFlag = 0
EndIf
If $iFlag = 0 And WinActive("[REGEXPCLASS:^(Progman|WorkerW)$]") Then
$iFlag = 1
WinActivate($hGUI)
EndIf
EndFunc
А попробуйте в этом примере в функции _SetOnTopOfDesktop() заменитьработает только БЕЗ стилей для GUI. В общем, вот так НЕ работает
WinSetState($hGUI, '', @SW_RESTORE)
GUISetState(@SW_RESTORE, $hGUI)
На Win7. Если выбрать "Показать рабочий стол" (или нажать Win+D), а после кликнуть в рабочий стол, то окно пропадает.Можно попробовать ещё так:
#include <WinAPI.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
Opt("WinWaitDelay", 10)
$hGUI = GUICreate("Test",150,100,500,300,$WS_POPUP, $WS_EX_TOOLWINDOW+$WS_EX_LAYERED)
GUISetBkColor(0x000001)
GUISetState(@SW_SHOW, $hGUI)
$CMD1 = GUICtrlCreateButton("", 0, 0, 70, 60)
_WinAPI_SetLayeredWindowAttributes($hgui, 0x000001, 0, $LWA_COLORKEY)
AdlibRegister('_SetOnTopOfDesktop', 10)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _SetOnTopOfDesktop()
If WinActive("[REGEXPCLASS:^(Progman|WorkerW)$]") Then
WinSetState($hGUI, '', @SW_RESTORE)
WinSetOnTop($hGUI, '', 1) ; <-- добавлено
WinSetOnTop($hGUI, '', 0) ; <-- добавлено
EndIf
EndFunc
WinSetState($hGUI, '', @SW_RESTORE)
я сказал про одинаковость , потому что в первом твоем скрипте и во втором функция приводит к одному действиюСовсем не тоже самое
WinActivate($hGUI)
в первом твоем скрипте и во втором функция приводит к одному действию
Вот именно что важно, т.к эти условия предотвращают постоянную активность окна на рабочем столе.и не важно сколько условий написано перед этим.
; поверх только рабочего стола
Func _SetOnTopOfDesktop()
If WinActive("[REGEXPCLASS:^(Progman|WorkerW)$]") Then
GUISetState(@SW_SHOW,$EMPTY)
Sleep(100)
GUISetState(@SW_HIDE,$EMPTY)
EndIf
EndFunc