Sign in to follow this  
Followers 0
torels

Resize window according to mouse pos

6 posts in this topic

Hi there

Here is my script:

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)
$Gui = GuiCreate("aaa",60,60,Default,Default,$WS_POPUP)
GUISetState()
GUISetBkColor(0x000000)
WinSetTrans($Gui,"",150)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_WindowDrag",$Gui)

While 1
    $Win = WinGetPos($Gui)
    If (MouseGetPos(0)>$Win[0]+$Win[2] OR MouseGetPos(0)<$Win[0]) And (MouseGetPos(1)>$Win[1]+$Win[3] OR MouseGetPos(1)<$Win[1]) Then
        If $Win[2]>60 Then
            TrayTip("title","out",10,16)
        For $i = $Win[2] to 60 Step -2
            WinMove($Gui, "", $Win[0], $Win[1],60+$i,60+$i)
        Next
        EndIf
    Else;If (MouseGetPos(0)>$Win[0] And MouseGetPos(0)<$win[0]+$Win[2]) or (MouseGetPos(1)>$Win[1] And MouseGetPos(1)<$win[1]+$Win[3]) Then
        TrayTip("title","in  ",10,16)
        $Width = 120
        If $Win[2]>$Width Then
        For $i = 60 to $Width Step 2
            WinMove($Gui, "", $Win[0], $Win[1],$Width+$i,$Width+$i)
        Next
        EndIf
    EndIf
WEnd


Func _WindowDrag()
    While _IsPressed("01")
        DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
    WEnd
EndFunc  ;==>_WindowDrag

what i want to so is the gui to grow up to $Width whan the mouse is over it and get back to 60x60 when it's outside of it

can anybody help ?

thanks in advance :D


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites



Hi there

Here is my script:

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)
$Gui = GuiCreate("aaa",60,60,Default,Default,$WS_POPUP)
GUISetState()
GUISetBkColor(0x000000)
WinSetTrans($Gui,"",150)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_WindowDrag",$Gui)

While 1
    $Win = WinGetPos($Gui)
    If (MouseGetPos(0)>$Win[0]+$Win[2] OR MouseGetPos(0)<$Win[0]) And (MouseGetPos(1)>$Win[1]+$Win[3] OR MouseGetPos(1)<$Win[1]) Then
        If $Win[2]>60 Then
            TrayTip("title","out",10,16)
        For $i = $Win[2] to 60 Step -2
            WinMove($Gui, "", $Win[0], $Win[1],60+$i,60+$i)
        Next
        EndIf
    Else;If (MouseGetPos(0)>$Win[0] And MouseGetPos(0)<$win[0]+$Win[2]) or (MouseGetPos(1)>$Win[1] And MouseGetPos(1)<$win[1]+$Win[3]) Then
        TrayTip("title","in  ",10,16)
        $Width = 120
        If $Win[2]>$Width Then
        For $i = 60 to $Width Step 2
            WinMove($Gui, "", $Win[0], $Win[1],$Width+$i,$Width+$i)
        Next
        EndIf
    EndIf
WEnd


Func _WindowDrag()
    While _IsPressed("01")
        DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
    WEnd
EndFunc  ;==>_WindowDrag

what i want to so is the gui to grow up to $Width whan the mouse is over it and get back to 60x60 when it's outside of it

can anybody help ?

thanks in advance :D

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)
$Gui = GuiCreate("aaa",60,60,Default,Default,$WS_POPUP)
GUISetState()
GUISetBkColor(0x000000)
WinSetTrans($Gui,"",150)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_WindowDrag",$Gui)
$Big = true
While 1
    $Win = WinGetPos($Gui)
    If (MouseGetPos(0)>$Win[0]+$Win[2] OR MouseGetPos(0)<$Win[0]) or (MouseGetPos(1)>$Win[1]+$Win[3] OR MouseGetPos(1)<$Win[1]) Then
        If not $big Then
            Tooltip("out",10,16)
        For $i = $Win[2] to 60 Step -2
            WinMove($Gui, "", $Win[0], $Win[1],$i,$i)
        Next
        $big = true
        EndIf
    Else;If (MouseGetPos(0)>$Win[0] And MouseGetPos(0)<$win[0]+$Win[2]) or (MouseGetPos(1)>$Win[1] And MouseGetPos(1)<$win[1]+$Win[3]) Then
        Tooltip("in  ",10,16)
        $Width = 120
        If $big Then
        For $i = 60 to $Width Step 2
            WinMove($Gui, "", $Win[0], $Win[1],$Width+$i,$Width+$i)
        Next
        $big = false
        EndIf
    EndIf
WEnd


Func _WindowDrag()
    While _IsPressed("01")
        DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
    WEnd
EndFunc ;==>_WindowDrag

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

nope it isn't working XD

I worked this out:

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)
$Gui = GuiCreate("aaa",61,61,Default,Default,$WS_POPUP)
$Width = 120
GUISetState()
_GuiRoundCorners($Gui, 0,0,4,4)
GUISetBkColor(0x000000)
WinSetTrans($Gui,"",150)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_WindowDrag",$Gui)

While 1
    $Win = WinGetPos($Gui)
    If (MouseGetPos(0)>$Win[0]+$Win[2] OR MouseGetPos(0)<$Win[0]) Then ;out X
        ;:TrayTip("a",MouseGetPos(0)-$win[0]&@CRLF&MouseGetPos(1)-$win[1],10,16)        
        WinMove($Gui, "", $Win[0], $Win[1],60,60)
        ;min($win)
        ContinueLoop
    EndIf
    If (MouseGetPos(1)>$Win[1]+$Win[3] OR MouseGetPos(1)<$Win[1]) Then ;out Y
        ;TrayTip("a",MouseGetPos(0)-$win[0]&@CRLF&MouseGetPos(1)-$win[1],10,16)
        WinMove($Gui, "", $Win[0], $Win[1],60,60)
        ;min($Win)
        ContinueLoop
    EndIf
    If (MouseGetPos(0)>$Win[0] And MouseGetPos(0)<$win[0]+$Win[2]) Then ;in X
        ;TrayTip("a",MouseGetPos(0)-$win[0]&@CRLF&MouseGetPos(1)-$win[1],10,16)
        ;WinMove($Gui, "", $Win[0], $Win[1],$Width,$Width)
        max($Win, $Width)
        ContinueLoop
    EndIf
    If (MouseGetPos(1)>$Win[1] And MouseGetPos(1)<$win[1]+$Win[3]) Then ;in Y
        ;TrayTip("a",MouseGetPos(0)-$win[0]&@CRLF&MouseGetPos(1)-$win[1],10,16)
        ;WinMove($Gui, "", $Win[0], $Win[1],$Width,$Width)
        max($Win, $Width)
        ContinueLoop
     EndIf
WEnd

Func max($aWin, $Size)
    For $i = $aWin[2] to $Size Step 2
        WinMove($Gui, "", $aWin[0], $aWin[1],$aWin[2]+$i,$aWin[2]+$i)
    Next
EndFunc

;Func min($aWin, $Size=70)
    ;For $i = $aWin[2] to $Size Step -2
        ;WinMove($Gui, "", $aWin[0], $aWin[1],$aWin[2]-$i,$aWin[2]-$i)
        ;_GuiRoundCorners($Gui, 0,0,4,4)
    ;Next
;SOME PROBLEM HERE!!!
;EndFunc

Func _WindowDrag()
    While _IsPressed("01")
        DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
    WEnd
EndFunc  ;==>_WindowDrag

It's kind of working... I just need to manage to make the "shrinking" effect work :D

if anyone worked out something better/smaller/faster then post it :D


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

#include <WindowsConstants.au3>
 #include <GuiConstantsEx.au3>
 #include <Misc.au3>
 
 Opt("GUIOnEventMode", 1)
 $Gui = GuiCreate("aaa",60,60,Default,Default,$WS_POPUP)
 GUISetState()
 GUISetBkColor(0x000000)
 WinSetTrans($Gui,"",150)
 
 GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_WindowDrag",$Gui)
 $Big = true
 While 1
     $Win = WinGetPos($Gui)
     If (MouseGetPos(0)>$Win[0]+$Win[2] OR MouseGetPos(0)<$Win[0]) or (MouseGetPos(1)>$Win[1]+$Win[3] OR MouseGetPos(1)<$Win[1]) Then
         If not $big Then
             Tooltip("out",10,16)
         For $i = $Win[2] to 60 Step -2
             WinMove($Gui, "", $Win[0], $Win[1],$i,$i)
         Next
         $big = true
         EndIf
     Else;If (MouseGetPos(0)>$Win[0] And MouseGetPos(0)<$win[0]+$Win[2]) or (MouseGetPos(1)>$Win[1] And MouseGetPos(1)<$win[1]+$Win[3]) Then
         Tooltip("in  ",10,16)
         $Width = 120
         If $big Then
         For $i = 60 to $Width Step 2
             WinMove($Gui, "", $Win[0], $Win[1],$Width+$i,$Width+$i)
         Next
         $big = false
         EndIf
     EndIf
 WEnd
 
 
 Func _WindowDrag()
     While _IsPressed("01")
         DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
     WEnd
 EndFunc;==>_WindowDrag
Works for me, what happens when you try it?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

this is good but it makes your cpu go to 100% anything to fix with that?

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)
$Gui = GuiCreate("aaa",60,60,Default,Default,$WS_POPUP)
GUISetState()
GUISetBkColor(0x000000)
WinSetTrans($Gui,"",150)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_WindowDrag",$Gui)
$Big = true
While 1
    $Win = WinGetPos($Gui)
    If (MouseGetPos(0)>$Win[0]+$Win[2] OR MouseGetPos(0)<$Win[0]) or (MouseGetPos(1)>$Win[1]+$Win[3] OR MouseGetPos(1)<$Win[1]) Then
        If not $big Then
            Tooltip("out",10,16)
        For $i = $Win[2] to 60 Step -2
            WinMove($Gui, "", $Win[0], $Win[1],$i,$i)
        Next
        $big = true
        EndIf
    Else;If (MouseGetPos(0)>$Win[0] And MouseGetPos(0)<$win[0]+$Win[2]) or (MouseGetPos(1)>$Win[1] And MouseGetPos(1)<$win[1]+$Win[3]) Then
        Tooltip("in  ",10,16)
        $Width = 120
        If $big Then
        For $i = 60 to $Width Step 2
            WinMove($Gui, "", $Win[0], $Win[1],$Width+$i,$Width+$i)
        Next
        $big = false
        EndIf
    EndIf
WEnd


Func _WindowDrag()
    While _IsPressed("01")
        DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
    WEnd
EndFunc ;==>_WindowDrag

Share this post


Link to post
Share on other sites

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)
$Gui = GUICreate("aaa", 60, 60, Default, Default, $WS_POPUP)
GUISetState()
GUISetBkColor(0x000000)
WinSetTrans($Gui, "", 150)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_WindowDrag", $Gui)
$Big = True

AdlibRegister("_check_GUI_Pos")

While 1
    sleep(10)
WEnd

Func _check_GUI_Pos()
    $Win = WinGetPos($Gui)
    if _WindowFromPoint() <> $gui then
        If Not $Big Then
            ToolTip("out", 10, 16)
            For $i = $Win[2] To 60 Step -2
                WinMove($Gui, "", $Win[0], $Win[1], $i, $i)
            Next
            $Big = True
        EndIf
    Else
        $Width = 120
        If $Big Then
            For $i = 60 To $Width Step 2
                WinMove($Gui, "", $Win[0], $Win[1], $Width + $i, $Width + $i)
            Next
            $Big = False
        EndIf
    EndIf
EndFunc

Func _WindowDrag()
    While _IsPressed("01")
        DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
    WEnd
EndFunc   ;==>_WindowDrag

Func _WindowFromPoint()
    ; from _GUICtrl_SetOnHover
    ; http://www.autoitscript.com/forum/index.ph...showtopic=55120
    ; by G.Sandler a.k.a MrCreatoR (CreatoR's Lab, http://creator-lab.ucoz.ru)
    Local $Old_Opt_MCM = Opt("MouseCoordMode", 1)
    Local $aRet = DllCall("User32.dll", "int", "WindowFromPoint", _
            "long", MouseGetPos(0), _
            "long", MouseGetPos(1))
    ;$aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $aRet[0])
    Opt("MouseCoordMode", $Old_Opt_MCM)
    Return $aRet[0]
EndFunc   ;==>_WindowFromPoint

Share this post


Link to post
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
Sign in to follow this  
Followers 0