Jump to content



Photo

_WinAttach()!


  • Please log in to reply
6 replies to this topic

#1 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 13 April 2007 - 11:02 AM

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 :shocked: ).

here we go...

AutoIt         
$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 by MsCreatoR, 21 October 2007 - 10:16 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image 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 ProgramPosted Image UDFs: 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 UDFPosted Image 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team






#2 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 13 April 2007 - 11:11 AM

Sounds awesome! I'm trying it out now. :shocked:

Edit: OMG! this is sooo cool! Great job!

Edited by bert, 13 April 2007 - 11:13 AM.


#3 DirtDBaK

DirtDBaK

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 978 posts

Posted 21 October 2007 - 09:35 PM

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....

Posted Image


#4 JustinReno

JustinReno

    My custom made Vortex.

  • Banned (NOT IN USE)
  • 2,330 posts

Posted 21 October 2007 - 09:42 PM

Its fun to set the $attachrange to 1000.

#5 DirtDBaK

DirtDBaK

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 978 posts

Posted 21 October 2007 - 09:47 PM

....umm....

Posted Image


#6 Achilles

Achilles

    Achilles == Ichigo

  • Active Members
  • PipPipPipPipPipPip
  • 2,897 posts

Posted 21 October 2007 - 09:59 PM

Good work! I had made something like this before... I'll find it and show you so you can see the differences...

#7 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 21 October 2007 - 10:11 PM

All:

Check this topic, there is a solution mutch more better! <_< (thanks to Siao and eltorro).

P.S
Updated first post.

Edited by MsCreatoR, 21 October 2007 - 10:17 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image 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 ProgramPosted Image UDFs: 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 UDFPosted Image 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users