Jump to content

howto determine mouse on gui with exLayer&transparency


Recommended Posts

I have a long script to determine mouse on borderless exlayered GUI, when it loses focus on window.

any way to do this with $GUI_EVENT?

 

#include <GuiConstantsEx.au3>
#include <GUIConstants.au3>
    ;- 
    Opt("GUIOnEventMode", 1)
    ;
    Global $_cGUI_Visible, $_nTimer,$nMX,$nMY,$_cDrag,$_cGUI_Collapsed=false
    Global $nGuiXLeft=400,$nGuiYTop=100,$nGui_Width=400,$nGui_Height=200,$RET=false
    Global $ParentWin_mn=20,$_nBkColor_Shield=0x000001, $_nBkColor_RayBan=0xfff000
    ;
#REGION hGUI_OSKMenu
    Global $hGUI_OSKMenu = GUICreate("",$nGui_Width,$nGui_Height,$nGuiXLeft,$nGuiYTop, _
                $WS_POPUP,BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST));<===== since EX_LAYERED
        GUISetBkColor($_nBkColor_RayBan, $hGUI_OSKMenu) ;==>Set GUI Colour
        ;GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "_EXIT") does not work here
        Global $_LGUI_OSK_logo= GUICtrlCreateLabel("AUTOIT ROCKS", 10, 0, 180, 20, -1, $GUI_WS_EX_PARENTDRAG)
            GUICtrlSetOnEvent($_LGUI_OSK_logo, "_HGUI_POSITION")
        Global $_LGUI_OSK_Drag= GUICtrlCreateLabel("This is text on" & @CRLF & _
            "a transparent Layered", 10, 0, 180, 40, -1, $GUI_WS_EX_PARENTDRAG)
            GUICtrlSetOnEvent($_LGUI_OSK_Drag, "_HGUI_POSITION")
        Global $idButton = GUICtrlCreateButton("Click Me!", 150, 135, 100, 30)
            GUICtrlSetOnEvent($idButton, "_BUTTON")
    GUISetState()
#ENDREGION

#REGION MAIN
    ;GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "OnEvents_Gui_OSKMenu")    ;<<<<<<< nope IT BELONGS GUI drag.
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")                ; Call a common GUI close function
    ;==>
    AdlibRegister ( '_CheckMouseOver' )
    ;==>
    _ShowStuff()
    ;==>
    While 1
    WEnd 
    ;
    Func _exit()
        Exit    
    EndFunc
    ;
    Func _BUTTON()
    MsgBox(64, "Button", "You clicked the button!", 3)
    EndFunc 
    ;
#ENDREGION

#REGION _CheckMouseOver
    Func _HGUI_POSITION()   ;==>guipos if moved
        Local $aGuiPos = WinGetPos($hGUI_OSKMenu)
        $nGuiXLeft=$aGuiPos[0]
        $nGuiYTop=$aGuiPos[1]
        $nGui_Width=$aGuiPos[2]
        $nGui_Height=$aGuiPos[3]
    EndFunc
    ;
    Func _CheckMouseOver()  ;==>_CheckMouseOver=active??=mouse<>gui IF RETURN   
            Local $aMousePos = MouseGetPos()
            $nMX=$aMousePos[0]
            $nMY=$aMousePos[1]
            If ($nMX > $nGuiXLeft) And ($nMX < ($nGuiXLeft + $nGui_Width)) And _
              ($nMY > $nGuiYTop) And ($nMY < ($nGuiYTop + $nGui_Height)) Then   ;mouse over
                If $RET Then Return $RET    ;stop recurse
                IF $_cGUI_Collapsed And ($nMY > ($nGuiYTop + $ParentWin_mn)) Then RETURN
                msgbox(0,0,"MOUSE in <"&$nMX-$nGuiXLeft&"_"&$nMY-$nGuiYTop&">IN<"&$nGuiXLeft&"_"&$nGuiYTop&")("&$nGui_Width&"_"&$nGui_Height,1)
                WinActivate($hGUI_OSKMenu)
                sleep(100)
                _ShowStuff()
                $RET = True
            Else
                If Not $RET Then  Return $RET   ;stop recurse
                msgbox(0,0,"MOUSE out<",.5)
                _HideStuff()
                $RET = False
            EndIf
        Return $RET
    EndFunc 
    ;
    Func _ShowStuff()       ;==>_ShowStuff
        $_cGUI_Visible = True
        $_nTimer = 0
        GUICtrlSetState($idButton, $GUI_SHOW)
        GUICtrlSetState($idButton, $GUI_ENABLE)
            GUICtrlSetState($_LGUI_OSK_Drag, $GUI_SHOW)
            GUICtrlSetState($_LGUI_OSK_Drag, $GUI_ENABLE)
        WinSetTrans($hGUI_OSKMenu, "", 255)
        GUISetBkColor($_nBkColor_RayBan, $hGUI_OSKMenu) ;==>Set GUI Colour
        _Expand()
    EndFunc 
    Func _Expand()
        Local $win_pos = WinGetPos($hGUI_OSKMenu)
        If $win_pos[3] = $ParentWin_mn Then
            For $i = $ParentWin_mn To $nGui_Height Step 5
                WinMove($hGUI_OSKMenu, "", $win_pos[0], $win_pos[1], $win_pos[2], $i)
            Next
        EndIf
        $_cGUI_Collapsed=true
    EndFunc
    ;
    Func _HideStuff()           ;==>_HideStuff
        IF NOT $RET THEN RETURN
        $_cGUI_Visible = False
        $_nTimer = 0
        GUICtrlSetState($idButton, $GUI_DISABLE)
        GUICtrlSetState($idButton, $GUI_HIDE)
        WinSetTrans($hGUI_OSKMenu, "", 150)
        My_Collapse()
            GUICtrlSetState($_LGUI_OSK_Drag, $GUI_DISABLE)
            GUICtrlSetState($_LGUI_OSK_Drag, $GUI_HIDE)
            ;
            GUICtrlSetState($_LGUI_OSK_logo, $GUI_SHOW)
            GUICtrlSetState($_LGUI_OSK_logo, $GUI_ENABLE)
            ;ControlMove($hGUI_OSKMenu, "", $_LGUI_OSK_logo, 0, 0)
    EndFunc
    Func My_Collapse()
        Local $win_pos = WinGetPos($hGUI_OSKMenu)
        If $win_pos[3] > $ParentWin_mn Then
            For $i = $nGui_Height To $ParentWin_mn Step - 5
                WinMove($hGUI_OSKMenu, "", $win_pos[0], $win_pos[1], $win_pos[2], $i)    ;WinMove ( "title", "text", x, y [, width [, height[, speed]]] )
            Next
        EndIF
        $_cGUI_Collapsed=true
    EndFunc
    ;
#ENDREGION

 

Link to comment
Share on other sites

i have conclude All those GUI EVENTS needs activation.

Goal is Activate GUI when mouse hovers.

i guess obligated to use mouse coordinate messages. GUI events wont help.

I use that only determine new position of GUI. 

Link to comment
Share on other sites

I tried before posting and it works fine. Gui position is updated every time the primary mouse button was released. So func _CheckMouseOver works with the correct positiom of your GUI. 

#include <GuiConstantsEx.au3>
#include <GUIConstants.au3>
;-
Opt("GUIOnEventMode", 1)
;
Global $_cGUI_Visible, $_nTimer, $nMX, $nMY, $_cDrag, $_cGUI_Collapsed = False
Global $nGuiXLeft = 400, $nGuiYTop = 100, $nGui_Width = 400, $nGui_Height = 200, $RET = False
Global $ParentWin_mn = 20, $_nBkColor_Shield = 0x000001, $_nBkColor_RayBan = 0xfff000
;
#Region hGUI_OSKMenu
Global $hGUI_OSKMenu = GUICreate("", $nGui_Width, $nGui_Height, $nGuiXLeft, $nGuiYTop, _
        $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST));<===== since EX_LAYERED
GUISetBkColor($_nBkColor_RayBan, $hGUI_OSKMenu) ;==>Set GUI Colour
;GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "_EXIT") does not work here
Global $_LGUI_OSK_logo = GUICtrlCreateLabel("AUTOIT ROCKS", 10, 0, 180, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetOnEvent($_LGUI_OSK_logo, "_HGUI_POSITION")
Global $_LGUI_OSK_Drag = GUICtrlCreateLabel("This is text on" & @CRLF & _
        "a transparent Layered", 10, 0, 180, 40, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetOnEvent($_LGUI_OSK_Drag, "_HGUI_POSITION")
Global $idButton = GUICtrlCreateButton("Click Me!", 150, 135, 100, 30)
GUICtrlSetOnEvent($idButton, "_BUTTON")
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_HGUI_POSITION")
GUISetState()
#EndRegion hGUI_OSKMenu

#Region MAIN
;GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "OnEvents_Gui_OSKMenu")    ;<<<<<<< nope IT BELONGS GUI drag.
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") ; Call a common GUI close function
;==>
AdlibRegister('_CheckMouseOver')
;==>
_ShowStuff()
;==>
While 1
WEnd
;
Func _exit()
    Exit
EndFunc   ;==>_exit
;
Func _BUTTON()
    MsgBox(64, "Button", "You clicked the button!", 3)
EndFunc   ;==>_BUTTON
;
#EndRegion MAIN

#Region _CheckMouseOver
Func _HGUI_POSITION() ;==>guipos if moved
    ConsoleWrite('_HGUI_POSITION'&@CRLF)
    Local $aGuiPos = WinGetPos($hGUI_OSKMenu)
    $nGuiXLeft = $aGuiPos[0]
    $nGuiYTop = $aGuiPos[1]
    $nGui_Width = $aGuiPos[2]
    $nGui_Height = $aGuiPos[3]
EndFunc   ;==>_HGUI_POSITION
;
Func _CheckMouseOver() ;==>_CheckMouseOver=active??=mouse<>gui IF RETURN
    Local $aMousePos = MouseGetPos()
    $nMX = $aMousePos[0]
    $nMY = $aMousePos[1]
    If ($nMX > $nGuiXLeft) And ($nMX < ($nGuiXLeft + $nGui_Width)) And _
            ($nMY > $nGuiYTop) And ($nMY < ($nGuiYTop + $nGui_Height)) Then ;mouse over
        If $RET Then Return $RET ;stop recurse
        If $_cGUI_Collapsed And ($nMY > ($nGuiYTop + $ParentWin_mn)) Then Return
        MsgBox(0, 0, "MOUSE in <" & $nMX - $nGuiXLeft & "_" & $nMY - $nGuiYTop & ">IN<" & $nGuiXLeft & "_" & $nGuiYTop & ")(" & $nGui_Width & "_" & $nGui_Height, 1)
        WinActivate($hGUI_OSKMenu)
        Sleep(100)
        _ShowStuff()
        $RET = True
    Else
        If Not $RET Then Return $RET ;stop recurse
        MsgBox(0, 0, "MOUSE out<", .5)
        _HideStuff()
        $RET = False
    EndIf
    Return $RET
EndFunc   ;==>_CheckMouseOver
;
Func _ShowStuff() ;==>_ShowStuff
    ConsoleWrite('_ShowStuff'&@CRLF)
    $_cGUI_Visible = True
    $_nTimer = 0
    GUICtrlSetState($idButton, $GUI_SHOW)
    GUICtrlSetState($idButton, $GUI_ENABLE)
    GUICtrlSetState($_LGUI_OSK_Drag, $GUI_SHOW)
    GUICtrlSetState($_LGUI_OSK_Drag, $GUI_ENABLE)
    WinSetTrans($hGUI_OSKMenu, "", 255)
    GUISetBkColor($_nBkColor_RayBan, $hGUI_OSKMenu) ;==>Set GUI Colour
    _Expand()
EndFunc   ;==>_ShowStuff
Func _Expand()
    ConsoleWrite('_Expand'&@CRLF)
    Local $win_pos = WinGetPos($hGUI_OSKMenu)
    If $win_pos[3] = $ParentWin_mn Then
        For $i = $ParentWin_mn To $nGui_Height Step 5
            WinMove($hGUI_OSKMenu, "", $win_pos[0], $win_pos[1], $win_pos[2], $i)
        Next
    EndIf
    $_cGUI_Collapsed = True
EndFunc   ;==>_Expand
;
Func _HideStuff() ;==>_HideStuff
    If Not $RET Then Return
    $_cGUI_Visible = False
    $_nTimer = 0
    GUICtrlSetState($idButton, $GUI_DISABLE)
    GUICtrlSetState($idButton, $GUI_HIDE)
    WinSetTrans($hGUI_OSKMenu, "", 150)
    My_Collapse()
    GUICtrlSetState($_LGUI_OSK_Drag, $GUI_DISABLE)
    GUICtrlSetState($_LGUI_OSK_Drag, $GUI_HIDE)
    ;
    GUICtrlSetState($_LGUI_OSK_logo, $GUI_SHOW)
    GUICtrlSetState($_LGUI_OSK_logo, $GUI_ENABLE)
    ;ControlMove($hGUI_OSKMenu, "", $_LGUI_OSK_logo, 0, 0)
EndFunc   ;==>_HideStuff
Func My_Collapse()
    Local $win_pos = WinGetPos($hGUI_OSKMenu)
    If $win_pos[3] > $ParentWin_mn Then
        For $i = $nGui_Height To $ParentWin_mn Step -5
            WinMove($hGUI_OSKMenu, "", $win_pos[0], $win_pos[1], $win_pos[2], $i) ;WinMove ( "title", "text", x, y [, width [, height[, speed]]] )
        Next
    EndIf
    $_cGUI_Collapsed = True
EndFunc   ;==>My_Collapse
;
#EndRegion _CheckMouseOver

but there is a bug in your script, sometimes _Expand don't work.

Edited by AutoBert
Link to comment
Share on other sites

Looks like you're trying to expand/contract your GUI. This is my attempt, it's kind of buggy and invalidates the button after it's contracted and then expanded but it's a bit cleaner, faster, and easier to fllow.

#include <GuiConstantsEx.au3>
#include <GUIConstants.au3>
#include <WinAPISys.au3>
#include <WinAPI.au3>
#include <WinAPIMisc.au3>
#include <WinAPIShellEx.au3>
;-
Opt("GUIOnEventMode", 1)

Global $hNewWindowProc = DllCallbackRegister("NewWindowProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
Global $pNewWindowProc = DllCallbackGetPtr($hNewWindowProc)
Global $_cGUI_Visible, $_nTimer, $nMX, $nMY, $_cDrag, $_cGUI_Collapsed = False
Global $nGuiXLeft = 400, $nGuiYTop = 100, $nGui_Width = 400, $nGui_Height = 200, $RET = False
Global $ParentWin_mn = 20, $_nBkColor_Shield = 0x000001, $_nBkColor_RayBan = 0xfff000
;
#Region hGUI_OSKMenu
Global $hGUI_OSKMenu = GUICreate("", $nGui_Width, $nGui_Height, $nGuiXLeft, $nGuiYTop, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) ;<===== since EX_LAYERED

Global $_LGUI_OSK_logo = GUICtrlCreateLabel("AUTOIT ROCKS", 10, 0, 180, 20, -1, $GUI_WS_EX_PARENTDRAG)

Global $_LGUI_OSK_Drag = GUICtrlCreateLabel("This is text on" & @CRLF & "a transparent Layered", 10, 0, 180, 40, -1, $GUI_WS_EX_PARENTDRAG)

Global $idButton = GUICtrlCreateButton("Click Me!", 150, 135, 100, 30)
GUICtrlSetOnEvent($idButton, "_BUTTON")

WinSetTrans($hGUI_OSKMenu, "", 255)
GUISetBkColor($_nBkColor_RayBan, $hGUI_OSKMenu) ;==>Set GUI Colour
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") ; Call a common GUI close function
GUISetState(@SW_SHOW, $hGUI_OSKMenu)

_WinAPI_SetWindowSubclass($hGUI_OSKMenu, $pNewWindowProc, 9999)
_WinAPI_TrackMouseEvent($hGUI_OSKMenu, $TME_LEAVE)

While 1
    Sleep(100)
WEnd

Func _exit()
    _WinAPI_RemoveWindowSubclass($hGUI_OSKMenu, $pNewWindowProc, 9999)
    Exit
EndFunc   ;==>_exit

Func _BUTTON()
    MsgBox(64, "Button", "You clicked the button!", 3)
EndFunc   ;==>_BUTTON

Func NewWindowProc($hWnd, $iMsg, $wParam, $lParam, $uIdSubclass, $dwRefData)
    #forceref $hWnd, $iMsg, $wParam, $lParam, $uIdSubclass, $dwRefData
    Local Static $bExpanded = True
    Local $tWindowPos = Null

    Switch ($iMsg)
        Case $WM_MOUSEMOVE
            If (Not $bExpanded) Then
                $bExpanded = True
                $tWindowPos = _WinAPI_GetWindowRect($hWnd)
                $nGuiXLeft = DllStructGetData($tWindowPos, 1)
                $nGuiYTop = DllStructGetData($tWindowPos, 2)
                WinMove($hWnd, "", $nGuiXLeft, $nGuiYTop, $nGui_Width, $nGui_Height)
                WinSetTrans($hGUI_OSKMenu, "", 255)
                $tWindowPos = Null
                Return _WinAPI_TrackMouseEvent($hGUI_OSKMenu, $TME_LEAVE)
            EndIf

        Case $WM_MOUSELEAVE
            If ($bExpanded) Then
                Local $tMousePos = _WinAPI_GetMousePos()
                $tWindowPos = _WinAPI_GetWindowRect($hWnd)
                If (Not _WinAPI_PtInRect($tWindowPos, $tMousePos)) Then
                    $bExpanded = False
                    $nGuiXLeft = DllStructGetData($tWindowPos, 1)
                    $nGuiYTop = DllStructGetData($tWindowPos, 2)
                    WinMove($hWnd, "", $nGuiXLeft, $nGuiYTop, $nGui_Width, 40)
                    WinSetTrans($hGUI_OSKMenu, "", 150)
                    $tWindowPos = Null
                    $tMousePos = Null
                    Return True
                Else
                    _WinAPI_TrackMouseEvent($hGUI_OSKMenu, $TME_LEAVE)
                EndIf

                $tWindowPos = Null
                $tMousePos = Null
            EndIf

        Case $WM_WINDOWPOSCHANGED
            $tWindowPos = DllStructCreate($tagWINDOWPOS, $lParam)
            $nGuiXLeft = DllStructGetData($tWindowPos, "x")
            $nGuiYTop = DllStructGetData($tWindowPos, "y")
            $tWindowPos = Null
    EndSwitch

    Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc

 

Link to comment
Share on other sites

Double post, server lagged right after I pressed submit :(

Edit: half an hour later, this seems like a good spot to put this

#include <GuiConstantsEx.au3>
#include <GUIConstants.au3>
#include <WinAPISys.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1)

Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo"
Global $hMouseHook = DllCallbackRegister("MouseHook", "long", "int;wparam;lparam")
Global $hMod = Null
Global $g_hHook = Null
Global $_cGUI_Visible, $_nTimer, $nMX, $nMY, $_cDrag, $_cGUI_Collapsed = False
Global $nGuiXLeft = 400, $nGuiYTop = 100, $nGui_Width = 400, $nGui_Height = 200, $RET = False
Global $ParentWin_mn = 20, $_nBkColor_Shield = 0x000001, $_nBkColor_RayBan = 0xfff000
Global $tWindowPos = _WinAPI_CreateRect($nGuiXLeft, $nGuiYTop, $nGuiXLeft + $nGui_Width, $nGuiYTop + 40)

#Region hGUI_OSKMenu
Global $hGUI_OSKMenu = GUICreate("", $nGui_Width, $nGui_Height, $nGuiXLeft, $nGuiYTop, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) ;<===== since EX_LAYERED

Global $_LGUI_OSK_logo = GUICtrlCreateLabel("AUTOIT ROCKS", 10, 0, 180, 20, -1, $GUI_WS_EX_PARENTDRAG)

Global $_LGUI_OSK_Drag = GUICtrlCreateLabel("This is text on" & @CRLF & "a transparent Layered", 10, 0, 180, 40, -1, $GUI_WS_EX_PARENTDRAG)

Global $idButton = GUICtrlCreateButton("Click Me!", 150, 135, 100, 30)
GUICtrlSetOnEvent($idButton, "_BUTTON")

WinSetTrans($hGUI_OSKMenu, "", 255)
GUISetBkColor($_nBkColor_RayBan, $hGUI_OSKMenu) ;==>Set GUI Colour
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") ; Call a common GUI close function
GUISetState(@SW_SHOW, $hGUI_OSKMenu)
GUIRegisterMsg($WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGED)

$hMod = _WinAPI_GetModuleHandle(0)
$g_hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseHook), $hMod)

While 1

WEnd

Func _exit()
    _WinAPI_UnhookWindowsHookEx($g_hHook)
    DllCallbackFree($hMouseHook)
    Exit
EndFunc   ;==>_exit

Func _BUTTON()
    MsgBox(64, "Button", "You clicked the button!", 3)
EndFunc   ;==>_BUTTON

Func MouseHook($nCode, $wParam, $lParam)
    Local Static $bExpanded = True
    Local Static $tMouseInfo = Null
    Local $tKeyInfo = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If ($nCode < 0) Then
        $tKeyInfo = Null
        Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
    EndIf
    Switch ($wParam)
        Case $WM_MOUSEMOVE
            $tMouseInfo = DllStructCreate($MSLLHOOKSTRUCT, $lParam)
            $tMousePos = _WinAPI_CreatePoint(DllStructGetData($tMouseInfo, 1), DllStructGetData($tMouseInfo, 2))
            If (Not $bExpanded and _WinAPI_PtInRect($tWindowPos, $tMousePos)) Then
                $bExpanded = True
                DllStructSetData($tWindowPos, 4, $nGuiYTop + $nGui_Height)
                WinMove($hGUI_OSKMenu, "", $nGuiXLeft, $nGuiYTop, $nGui_Width, $nGui_Height)
                WinSetTrans($hGUI_OSKMenu, "", 255)
            ElseIf ($bExpanded and Not _WinAPI_PtInRect($tWindowPos, $tMousePos)) Then
                $bExpanded = False
                DllStructSetData($tWindowPos, 4, $nGuiYTop + 40)
                WinMove($hGUI_OSKMenu, "", $nGuiXLeft, $nGuiYTop, $nGui_Width, 40)
                WinSetTrans($hGUI_OSKMenu, "", 150)
            EndIf

            $tMouseInfo = Null
            $tMousePos = Null
    EndSwitch

    Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
EndFunc   ;==>MouseHook

Func WM_WINDOWPOSCHANGED($hWnd, $iMsg, $wParam, $lParam)
    Local $tNewWinPos = DllStructCreate($tagWINDOWPOS, $lParam)
    Local $iOldWidth = (DllStructGetData($tWindowPos, 4) - $nGuiYTop)
    $nGuiXLeft = DllStructGetData($tNewWinPos, "x")
    $nGuiYTop = DllStructGetData($tNewWinPos, "y")
    DllStructSetData($tWindowPos, 1, $nGuiXLeft)
    DllStructSetData($tWindowPos, 2, $nGuiYTop)
    DllStructSetData($tWindowPos, 3, $nGuiXLeft + $nGui_Width)
    DllStructSetData($tWindowPos, 4, $nGuiYTop + $iOldWidth)
    $tNewWinPos = Null

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_WINDOWPOSCHANGED

This works very well. Faster, cleaner, and pretty easy to follow. I'd opt to use just the $tWindowPos to keep track of the window's X and Y position and just get rid of $nGuiXLeft and $nGuiYTop all together, but I left them in there for this. Just don't put a sleep in your While loop, it causes the ouse to move very slowly and poorly (This is a hook after all ;)).

Edited by InunoTaishou
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...