MrCreatoR Posted April 13, 2007 Share Posted April 13, 2007 (edited) Hi all, This example is show, that window can be "attached" (like magnetic) to edges of the screen (or other app)...But there is one(?) problem - when you drag the window, the script is paused, so you will see the results (of "attaching" process) only after release the mouse (ending of draging).If this will be fixed(?), then not only this function will be much usefull, and more others (in fact, all our scripts will be much productive and practical ).here we go...expandcollapse popup$AttachRange = 70 $AttachSpeed = 100 $HwndGui = GUICreate("Attach Window GUI to screen edges") GUICtrlCreateLabel("Drag me to the edges of your screen ;-) ", 50, 50, 350) GUICtrlSetFont(-1, 14) GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = -3 Then Exit _WinAttach($HwndGui, $AttachRange, $AttachSpeed) WEnd Func _WinAttach($hWnd, $AttachRange=20, $AttachSpeed=3) Local $OldOpt = Opt("WinTitleMatchMode", 4) Local $WinPosArr = WinGetPos($hWnd) Local $WidthHeightArr = WinGetClientSize($hWnd) If IsArray($WinPosArr) And IsArray($WidthHeightArr) Then Local $xPos = $WinPosArr[0] Local $yPos = $WinPosArr[1] Local $Width = $WidthHeightArr[0] Local $Height = $WinPosArr[3] Local $TrayPosHeight = WinGetPos("classname=Shell_TrayWnd") If IsArray($TrayPosHeight) Then $TrayPosHeight = $TrayPosHeight[3] If $xPos >= (@DesktopWidth-($Width+$AttachRange)) And ($xPos+$Width-15) < (@DesktopWidth-22) Then Local $xDestPos = @DesktopWidth-$Width While $xPos < $xDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $xPos += 5 WEnd EndIf If $xPos <= $AttachRange And $xPos > 8 Then Local $xDestPos = -2 While $xPos > $xDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $xPos -= 5 WEnd EndIf If $yPos >= (@DesktopHeight-($TrayPosHeight+$Height+$AttachRange)) And _ ($TrayPosHeight+$yPos+$Height-15) < (@DesktopHeight-22) Then Local $yDestPos = @DesktopHeight-$Height-$TrayPosHeight+4 While $yPos < $yDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $yPos += 5 WEnd EndIf If $yPos <= $AttachRange And $yPos > 8 Then Local $yDestPos = -2 While $yPos > $yDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $yPos -= 5 WEnd EndIf EndIf Opt("WinTitleMatchMode", $OldOpt) EndFunc Edited October 21, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
BrettF Posted April 13, 2007 Share Posted April 13, 2007 (edited) Sounds awesome! I'm trying it out now. Edit: OMG! this is sooo cool! Great job! Edited April 13, 2007 by bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DirtDBaK Posted October 21, 2007 Share Posted October 21, 2007 Very nice but... It doesn't attach to other GUI's if you could send a parameter that was just an array with all of the other gui's it should be magnetic to that would make it better... kinda like... $array[0] = 2 ; I have two other gui's that it should attach too $array[1] = $Hwnd1 $array[2] = $HWnd2 _WinAttach( $Hwnd3, 20, 3, $array ) thus making hwnd3 'magnetic' or 'sticky' to hwnd1 & hwnd2.... [center][/center] Link to comment Share on other sites More sharing options...
JustinReno Posted October 21, 2007 Share Posted October 21, 2007 Its fun to set the $attachrange to 1000. Link to comment Share on other sites More sharing options...
DirtDBaK Posted October 21, 2007 Share Posted October 21, 2007 ....umm.... [center][/center] Link to comment Share on other sites More sharing options...
Achilles Posted October 21, 2007 Share Posted October 21, 2007 Good work! I had made something like this before... I'll find it and show you so you can see the differences... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
MrCreatoR Posted October 21, 2007 Author Share Posted October 21, 2007 (edited) All:Check this topic, there is a solution mutch more better! (thanks to Siao and eltorro).P.SUpdated first post. Edited October 21, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team 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