Jump to content

[SOLVED] Prevent GUI disappearance after Win + D


Recommended Posts

Hello AutoIt Forums,

I'm trying to make a GUI similar to those of Windows 7 gadgets, RocketDock and whatnots in which the GUI doesn't disappear when Win + D is pressed.

I had previously started (ages ago) a thread dealing with the same problem < http://autoitscript.com/forum/topic/134945-how-do-i-make-a-gui-un-minimizable/ > though I think it was inappropriately titled because the GUI window isn't exactly minimized when Win + D is pressed, i.e., it just hides behind the desktop (i.e., BitAnd(16, Wingetstate($GUI) yields 0). The only way I know of which can prevent the GUI from hiding is to toggle on the "Always on Top" atttribute of the GUI but I don't want to do just that.

Here's what I did: (I didn't accomplish anything close to what I'd like to do)

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
$hide = GUICreate('')
$show = GUICreate("Test GUI", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_BORDER, $WS_POPUP, $WS_SYSMENU), -1, $hide)
GUISetState(@SW_SHOW, $show)
Opt("GUIOnEventMode",1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
While 1
Sleep(1000)
Local $state = WinGetState($show, "")
If BitAND($state, 16) Then WinSetState($show, '', @SW_RESTORE) ; <<< doesn't restore the GUI when Win + D is pressed.
ToolTip(@SEC & @CRLF & _
   'Exists =' & BitAND($state, 1) & @CRLF & _
   'Visible =' & BitAND($state, 2) & @CRLF & _
   'Enabled =' & BitAND($state, 4) & @CRLF & _
   'Active =' & BitAND($state, 8) & @CRLF & _
   'minimized =' & BitAND($state, 16) & @CRLF & _
   'Maximized =' & BitAND($state, 32), 0, 0)
WEnd
Func _exit()
Exit
EndFunc   ;==>_Exit

Help please? Thanks.

Edit: Fixed thread link.

Edit 2: Thread title - added [sOLVED]. Thanks funkey!

Edited by Lilbert
Link to comment
Share on other sites

It took me quite long to find this solution!

I hope this is what you want!

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Global $hDesktop = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
Global $hGui = GUICreate("Non Minimizable", 500, 500, -1, -1, $WS_MAXIMIZEBOX)
_WinAPI_SetWindowLong($hGui, $GWL_HWNDPARENT, $hDesktop)

GUISetState()

Do
Until GUIGetMsg() = -3
Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Nice find funkey.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Why not just do something simple, like this?:

#include <WindowsConstants.au3>

HotKeySet("{ESC}", "Terminate")
GUICreate("Example", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
While 1
 If Not WinActive("Example") Then
 WinActivate("Example")
 EndIf
Wend
Func Terminate()
 Exit
EndFunc

Press ESC to exit.

Link to comment
Share on other sites

Why not just do something simple, like this?

If you change the width and height then funkey's approach is better.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Why not just do something simple, like this?:

#include <WindowsConstants.au3>

HotKeySet("{ESC}", "Terminate")
GUICreate("Example", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
While 1
If Not WinActive("Example") Then
WinActivate("Example")
EndIf
Wend
Func Terminate()
Exit
EndFunc

Press ESC to exit.

But I don't like my GUI to be always above the other windows.

It took me quite long to find this solution!

I hope this is what you want!

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Global $hDesktop = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
Global $hGui = GUICreate("Non Minimizable", 500, 500, -1, -1, $WS_MAXIMIZEBOX)
_WinAPI_SetWindowLong($hGui, $GWL_HWNDPARENT, $hDesktop)

GUISetState()

Do
Until GUIGetMsg() = -3

Brilliant. Thanks funkey!
Link to comment
Share on other sites

  • 4 years later...
On 09.05.2012 at 1:42 PM, funkey said:

It took me quite long to find this solution!

I hope this is what you want!

 

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Global $hDesktop = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
Global $hGui = GUICreate("Non Minimizable", 500, 500, -1, -1, $WS_MAXIMIZEBOX)
_WinAPI_SetWindowLong($hGui, $GWL_HWNDPARENT, $hDesktop)

GUISetState()

Do
Until GUIGetMsg() = -3

 

Win 10, this does not work.

Link to comment
Share on other sites

  • Moderators

Seeing as the post is almost 5 years old, that is not surprising. In the future, please do not resurrect old posts; I am sure there are plenty of scripts out there for XP that no longer work too, but we don't need to know about every one. If you are encountering an issue, please start a new thread and (as the OP in this thread intelligently did) post a link to the previous thread for background if necessary.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...