Jump to content



Photo

_GuiSnap()


  • Please log in to reply
9 replies to this topic

#1 billthecreator

billthecreator

    I am The creator

  • Active Members
  • PipPipPipPipPipPip
  • 379 posts

Posted 22 July 2008 - 07:01 PM

Here is a function that allows your gui, or any window to be attached to the walls of your desktop.
AutoIt         
; #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 by billthecreator, 22 July 2008 - 07:43 PM.

My Scripts: From Most recent to least.Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap







#2 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,498 posts

Posted 22 July 2008 - 07:08 PM

Please write an example script.

Edited by Andreik, 22 July 2008 - 07:10 PM.

When the words fail... music speaks

#3 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 22 July 2008 - 07:21 PM

Good :muttley: , but i like this more: http://www.autoitscript.com/forum/index.ph...st&p=399062
An 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 by ProgAndy, 22 July 2008 - 07:22 PM.

*GERMAN* Posted Image [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

#4 billthecreator

billthecreator

    I am The creator

  • Active Members
  • PipPipPipPipPipPip
  • 379 posts

Posted 22 July 2008 - 07:35 PM

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 by billthecreator, 22 July 2008 - 07:36 PM.

My Scripts: From Most recent to least.Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

#5 NELyon

NELyon

    Do you wanna brew my avatar?

  • Active Members
  • PipPipPipPipPipPip
  • 3,526 posts

Posted 22 July 2008 - 07:37 PM

Me likey :muttley:

#6 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,498 posts

Posted 22 July 2008 - 07:38 PM

:muttley: I like your idea.
When the words fail... music speaks

#7 billthecreator

billthecreator

    I am The creator

  • Active Members
  • PipPipPipPipPipPip
  • 379 posts

Posted 22 July 2008 - 07:38 PM

glad to hear it
My Scripts: From Most recent to least.Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

#8 billthecreator

billthecreator

    I am The creator

  • Active Members
  • PipPipPipPipPipPip
  • 379 posts

Posted 22 July 2008 - 07:39 PM

this is what happens when i get bored... ha
My Scripts: From Most recent to least.Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

#9 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 22 July 2008 - 07:40 PM

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* Posted Image [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

#10 billthecreator

billthecreator

    I am The creator

  • Active Members
  • PipPipPipPipPipPip
  • 379 posts

Posted 22 July 2008 - 07:42 PM

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
My Scripts: From Most recent to least.Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users