billthecreator Posted July 22, 2008 Share Posted July 22, 2008 (edited) Here is a function that allows your gui, or any window to be attached to the walls of your desktop. expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _GuiSnap ; Description ...: When the gui window is close the the desktop borders, it snaps the the sides, and corners. ; Syntax.........: _GuiSnap($aTitle[, $hText = ""[, $hDistance = 35[, $sXy = 4[, $TaskBar = 34]]]]) ; Parameters ....: $aTitle - The title of the window . ; $hText - [optional]The text of the window. ; $hDistance - [optional]The distance before the Gui snaps in pixels. Default = 35 ; $sXy - [optional]The x and y placement of the window. Default = 4 ; $TaskBar - [optional]The height of the task bar. Default = 34 ; Return values .: Success - True ; Failure - False ; Author ........: Bill Reithmeyer (billthecreator) ; Modified.......: 07.22.2008 9:07 AM ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GuiSnap($aTitle, $hText = "", $hDistance = 35, $sXy = 4, $TaskBar = 34) Local $wSize If $aTitle = "" Then SetError(1) Else $wSize = WinGetPos($aTitle) If $wSize[0] < $hDistance And $wSize[1] < $hDistance Then ; Top Left Hand Corner WinMove($aTitle, $hText, $sXy, $sXy) ElseIf $wSize[0] < $hDistance Then ; Left Side Of Desktop WinMove($aTitle, $hText, $sXy, $wSize[1]) ElseIf $wSize[1] < $hDistance Then ; Top Of Desktop WinMove($aTitle, $hText, $wSize[0], $sXy) EndIf If $wSize[0] > @DesktopWidth - $hDistance - $wSize[2] And $wSize[1] < $hDistance Then ; Top Right Hand Corner WinMove($aTitle, $hText, @DesktopWidth - $sXy - $wSize[2], $sXy) ElseIf $wSize[0] > @DesktopWidth - $hDistance - $wSize[2] Then ; Right Side Of Desktop WinMove($aTitle, $hText, @DesktopWidth - $sXy - $wSize[2], $wSize[1]) EndIf If $wSize[1] > @DesktopHeight - $hDistance - $TaskBar - $wSize[3] And $wSize[0] < $hDistance Then ; Bottom Left Hand Corner WinMove($aTitle, $hText, $sXy, @DesktopHeight - $TaskBar - $wSize[3]) ElseIf $wSize[1] > @DesktopHeight - $hDistance - $TaskBar - $wSize[3] Then ; Bottom Of Desktop WinMove($aTitle, $hText, $wSize[0], @DesktopHeight - $TaskBar - $wSize[3]) EndIf If $wSize[1] > @DesktopHeight - $hDistance - $TaskBar - $wSize[3] And $wSize[0] > @DesktopWidth - $hDistance - $wSize[2] Then ; Bottom Right Hand Corner WinMove($aTitle, $hText, @DesktopWidth - $sXy - $wSize[2], @DesktopHeight - $TaskBar - $wSize[3]) EndIf EndIf EndFunc ;==>_GuiSnap Edited July 22, 2008 by billthecreator [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
Andreik Posted July 22, 2008 Share Posted July 22, 2008 (edited) Please write an example script. Edited July 22, 2008 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
ProgAndy Posted July 22, 2008 Share Posted July 22, 2008 (edited) Good muttley , but i like this more: http://www.autoitscript.com/forum/index.ph...st&p=399062An example-Script for yours, billthecreator:#include <GUIConstants.au3> $GUI = GUICreate('df') GUISetState() While 1 _GuiSnap($GUI) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Edited July 22, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
billthecreator Posted July 22, 2008 Author Share Posted July 22, 2008 (edited) Sorry, not quiet. here: _GuiSnap("title", '', 35, 4, 34) if you go look at my command prompt example, i have it in there.... be cautious though, its 1800 lines. Edited July 22, 2008 by billthecreator [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
NELyon Posted July 22, 2008 Share Posted July 22, 2008 Me likey muttley Link to comment Share on other sites More sharing options...
Andreik Posted July 22, 2008 Share Posted July 22, 2008 muttley I like your idea. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
billthecreator Posted July 22, 2008 Author Share Posted July 22, 2008 glad to hear it [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
billthecreator Posted July 22, 2008 Author Share Posted July 22, 2008 this is what happens when i get bored... ha [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
ProgAndy Posted July 22, 2008 Share Posted July 22, 2008 Sorry, not quiet. here: _GuiSnap("title", '', 35, 4, 34) if you go look at my command prompt example, i have it in there.... be cautious though, its 1800 lines.The example is right muttley You have made all parameters optional, so u don't have to use them, just put title as GUIHandle, then it works *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
billthecreator Posted July 22, 2008 Author Share Posted July 22, 2008 oh. i actually didnt know that. wow.. ha. in my command prompt one, i need to have it use the title. 'cause the title can change.... ok thanks [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
mesale0077 Posted September 8, 2013 Share Posted September 8, 2013 expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name...........: _GuiSnap ; Description ...: When the gui window is close the the desktop borders, it snaps the the sides, and corners. ; Syntax.........: _GuiSnap($aTitle[, $hText = ""[, $hDistance = 35[, $sXy = 4[, $TaskBar = 34]]]]) ; Parameters ....: $aTitle - The title of the window . ; $hText - [optional]The text of the window. ; $hDistance - [optional]The distance before the Gui snaps in pixels. Default = 35 ; $sXy - [optional]The x and y placement of the window. Default = 4 ; $TaskBar - [optional]The height of the task bar. Default = 34 ; Return values .: Success - True ; Failure - False ; Author ........: Bill Reithmeyer (billthecreator) ; Modified.......: 07.22.2008 9:07 AM ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GuiSnap($aTitle, $hText = "", $hDistance = 35, $sXy = 4, $TaskBar = 34) Local $wSize If $aTitle = "" Then SetError(1) Else $wSize = WinGetPos($aTitle) If $wSize[0] < $hDistance And $wSize[1] < $hDistance Then ; Top Left Hand Corner WinMove($aTitle, $hText, $sXy, $sXy) ElseIf $wSize[0] < $hDistance Then ; Left Side Of Desktop WinMove($aTitle, $hText, $sXy, $wSize[1]) ElseIf $wSize[1] < $hDistance Then ; Top Of Desktop WinMove($aTitle, $hText, $wSize[0], $sXy) EndIf If $wSize[0] > @DesktopWidth - $hDistance - $wSize[2] And $wSize[1] < $hDistance Then ; Top Right Hand Corner WinMove($aTitle, $hText, @DesktopWidth - $sXy - $wSize[2], $sXy) ElseIf $wSize[0] > @DesktopWidth - $hDistance - $wSize[2] Then ; Right Side Of Desktop WinMove($aTitle, $hText, @DesktopWidth - $sXy - $wSize[2], $wSize[1]) EndIf If $wSize[1] > @DesktopHeight - $hDistance - $TaskBar - $wSize[3] And $wSize[0] < $hDistance Then ; Bottom Left Hand Corner WinMove($aTitle, $hText, $sXy, @DesktopHeight - $TaskBar - $wSize[3]) ElseIf $wSize[1] > @DesktopHeight - $hDistance - $TaskBar - $wSize[3] Then ; Bottom Of Desktop WinMove($aTitle, $hText, $wSize[0], @DesktopHeight - $TaskBar - $wSize[3]) EndIf If $wSize[1] > @DesktopHeight - $hDistance - $TaskBar - $wSize[3] And $wSize[0] > @DesktopWidth - $hDistance - $wSize[2] Then ; Bottom Right Hand Corner WinMove($aTitle, $hText, @DesktopWidth - $sXy - $wSize[2], @DesktopHeight - $TaskBar - $wSize[3]) EndIf EndIf EndFunc ;==>_GuiSnap $GUI = GUICreate('df',300,300,10,20) GUISetState() _GuiSnap("df", '', 35, 4, 34) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd dont work why? Link to comment Share on other sites More sharing options...
TheSaint Posted September 9, 2013 Share Posted September 9, 2013 Cough, Cough! Umm ..... check the date. We've had a few updates to AutoIt since then ... updates usually break some old feature/ability. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
guinness Posted September 9, 2013 Share Posted September 9, 2013 It works as expected (despite the code being a little clumsy), I don't know what you expected. The changes that have taken place from 2008 to now wouldn't have really broken the script.So in conclusion, be descriptive with what "doesn't work", what do you expect to happen that didn't? 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Mat Posted September 9, 2013 Share Posted September 9, 2013 Might not work on windows 7+ as there is already the aero snap functionality and they might interfere with each other. AutoIt Project Listing Link to comment Share on other sites More sharing options...
MHz Posted September 9, 2013 Share Posted September 9, 2013 (edited) dont work why? You need to call the function at a regular time interval. The below works for me as I put the function in the loop. $GUI = GUICreate('df',300,300,10,20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect _GuiSnap("df", '', 35, 4, 34) WEnd If you move the window close to the edge of the monitor then it snaps to the edge. Edit: Tested on Win7 with 3 monitors active in non surround mode if that means something to note. Edited September 9, 2013 by MHz Link to comment Share on other sites More sharing options...
guinness Posted September 9, 2013 Share Posted September 9, 2013 Might not work on windows 7+ as there is already the aero snap functionality and they might interfere with each other.I tested on Windows 7. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
TheSaint Posted September 9, 2013 Share Posted September 9, 2013 A lot of replies to someone who has been around long enough, to have provided proper detail in the first place, especially when engaging in Necromancy. Now that I've had a look at the code and seen it is a very simple script, I'm kind of surprised at OP having to ask and providing so little info to give us some helpful clues. He'll probably come back and tell us he solved it himself days ago ... or even forgot he posted it. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) 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