Jump to content

_WinAPI_DrawLine()


JohnOne
 Share

Recommended Posts

Not getting a clean rectangle as I expected, I think Im missing something I need to delete in the loop. I tried redrawing the whole window in the loop except it causes terrible flicker.

Its just supposed to draw a clean rectange on screen, and the code is modified helpfile code. But it leaves previous lines and so forth.

Any tips how to keep the rect clean?

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Include <Misc.au3>

While 1
    Sleep(10)
    If _IsPressed("01") Then
        _rect()
    EndIf
    If _IsPressed("02") Then
        Exit
    EndIf
WEnd

Func _rect()
    Local $hDC, $hPen, $obj_orig
    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x00ff)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
    Local $sPos = MouseGetPos() ; rect start pos
    Local $ePos
    While _IsPressed("01")
        $ePos = MouseGetPos() ; rect current/end pos
        _WinAPI_DrawLine($hDC, $sPos[0], $sPos[1], $ePos[0], $sPos[1]) ;top x
        _WinAPI_DrawLine($hDC, $sPos[0], $sPos[1], $sPos[0], $ePos[1]) ;left y
        _WinAPI_DrawLine($hDC, $sPos[0], $ePos[1], $ePos[0], $ePos[1]) ;bottom x
        _WinAPI_DrawLine($hDC, $ePos[0], $ePos[1], $ePos[0], $sPos[1]) ;right y
        Sleep(10)
    WEnd
    Sleep(3000)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    ; clear resources
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

If you want to draw a rectangle on the desktop have a look here: http://www.autoitscript.com/forum/index.php?showtopic=106744&view=findpost&p=75

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

#Include <GDIPlus.au3>
#Include <Misc.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Opt('WinWaitDelay', 0)

_GDIPlus_Startup()

Global $hForm, $hPic, $Msg, $Mouse, $Point, $Pos[2], $Dim[2], $Show = False

$hForm = GUICreate('', -1, -1, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), GUICreate('', -1, -1, -1, -1, -1, $WS_EX_TOOLWINDOW))
$hPic = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\red.png')
_SetBitmap($hForm, 1, 1, 0)
GUISetState()

While 1
    Sleep(10)
    If _IsPressed('1B') Then
        Exit
    EndIf
    If _IsPressed('01') Then
        If $Show Then
            $Mouse = MouseGetPos()
            If ($Mouse[0] = $Point[0]) And ($Mouse[1] = $Point[1]) Then
                ContinueLoop
            EndIf
            For $i = 0 To 1
                Select
                    Case $Mouse[$i] < $Point[$i]
                        $Pos[$i] = $Mouse[$i]
                        $Dim[$i] = $Point[$i] - $Mouse[$i] + 1
                    Case $Mouse[$i] > $Point[$i]
                        $Pos[$i] = $Point[$i]
                        $Dim[$i] = $Mouse[$i] - $Point[$i] + 1
                    Case $Mouse[$i] = $Point[$i]
                        $Pos[$i] = $Point[$i]
                        $Dim[$i] = 1
                EndSelect
            Next
            _SetBitmap($hForm, $Dim[0], $Dim[1], 255)
            WinMove($hForm, '', $Pos[0], $Pos[1])
        ELse
            $Point = MouseGetPos()
            WinMove($hForm, '', $Point[0], $Point[1])
            _SetBitmap($hForm, 1, 1, 255)
            $Show = True
        EndIf
    Else
        If $Show Then
            _SetBitmap($hForm, 1, 1, 0)
            $Show = False
        EndIf
    EndIf
WEnd

_GDIPlus_Shutdown()

Func _SetBitmap($hWnd, $iWidth, $iHeight, $iAlpha = 255)

    Local $hBitmap, $hImage, $hGraphic, $hPen

    $hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr', 0, 'ptr', 0)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage[4])
    $hPen = _GDIPlus_PenCreate(0x60FF0000)
    _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $iWidth - 1, $iHeight - 1, $hPen)
    _GDIPlus_PenDispose($hPen)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage[4])
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage[4])
    _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iAlpha, 1)
EndFunc   ;==>_SetBitmap

Func _WinAPI_GetBitmapDimension($hBitmap)

    Local $tObj = DllStructCreate('long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits')
    Local $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj))

    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf

    Local $tSIZE = DllStructCreate($tagSIZE)

    DllStructSetData($tSIZE, 1, DllStructGetData($tObj, 'bmWidth'))
    DllStructSetData($tSIZE, 2, DllStructGetData($tObj, 'bmHeight'))

    Return $tSIZE
EndFunc   ;==>_WinAPI_GetBitmapDimension

Func _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iOpacity = 255, $fDelete = 0)

    Local $Ret, $tSIZE, $tPOINT, $tBLENDFUNCTION, $hDC, $hDestDC, $hDestSv

    $Ret = DllCall('user32.dll', 'hwnd', 'GetDC', 'hwnd', $hWnd)
    $hDC = $Ret[0]
    $Ret = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleDC', 'hwnd', $hDC)
    $hDestDC = $Ret[0]
    $Ret = DllCall('gdi32.dll', 'hwnd', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hBitmap)
    $hDestSv = $Ret[0]
    $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
    $tPOINT = DllStructCreate($tagPOINT)
    $tBLENDFUNCTION = DllStructCreate($tagBLENDFUNCTION)
    DllStructSetData($tBLENDFUNCTION, 'Alpha', $iOpacity)
    DllStructSetData($tBLENDFUNCTION, 'Format', 1)
    $Ret = DllCall('user32.dll', 'int', 'UpdateLayeredWindow', 'hwnd', $hWnd, 'hwnd', $hDC, 'ptr', 0, 'ptr', DllStructGetPtr($tSIZE), 'hwnd', $hDestDC, 'ptr', DllStructGetPtr($tPOINT), 'dword', 0, 'ptr', DllStructGetPtr($tBLENDFUNCTION), 'dword', 0x02)
    DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $hWnd, 'hwnd', $hDC)
    DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hDestSv)
    DllCall('gdi32.dll', 'int', 'DeleteDC', 'hwnd', $hDestDC)
    If Not $Ret[0] Then
        Return SetError(1, 0, 0)
    EndIf
    If $fDelete Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_UpdateLayeredWindowEx

post-42455-0-38554300-1289415184_thumb.p - red.png

Edited by Yashied
Link to comment
Share on other sites

Woh, Yashied thats superb, its like the windows 7 desktop thing.

Way over my head too, but I'm still going to use it if you dont mind, for visuality, then I can just draw the lines I need once from the generated co-ords.

Thanks a basket.

Still open to Ideas on how to obtain my desired effect with the somwhat simple code in the first post though.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Here an alternative:

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

Mark_Area()

Func Mark_Area($disable_aero = False); coded by UEZ 2010
    ;http://msdn.microsoft.com/en-us/library/aa969510%28VS.85%29.aspx
    Local Const $hDwmApiDll = DllOpen("dwmapi.dll")
    Local $sChkAero = DllStructCreate("int;")
    DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
    Local $aero_on = DllStructGetData($sChkAero, 1)
    If $aero_on And $disable_aero Then DllCall($hDwmApiDll, "int", "DwmEnableComposition", "uint", False)
    $sChkAero = 0
    Sleep(500)

    Local Const $user32_dll = DllOpen("user32.dll")
    Local $w, $h, $mpos = MouseGetPos()

    Local $hGUI_Cross = GUICreate("", 30, 30,  $mpos[0], $mpos[1], $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
    GUISetState(@SW_SHOW, $hGUI_Cross)
    WinSetTrans($hGUI_Cross, "", 1)


    While Not _IsPressed("01", $user32_dll)
        GUISetCursor(3, 1, $hGUI_Cross)
        $mpos = MouseGetPos()
        WinMove($hGUI_Cross, "", $mpos[0] - 15, $mpos[1] - 15)
        ToolTip("Please mark area" & @CRLF & _
                "on your desktop!" & @CRLF & _
                "ESC to abort")
        Sleep(50)
    WEnd
    ToolTip("")

    $mpos = MouseGetPos()
    Local $m_startx = $mpos[0]
    Local $m_starty = $mpos[1]

    Local $hGUI = GUICreate("", 0, 0, $m_startx, $m_starty, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
    GUISetBkColor(0x000040)
    Local $size = 1

    If @OSVersion = "WIN_XP" Then
        $label = GUICtrlCreateLabel("", $size, $size, 0, 0, Default, $WS_EX_COMPOSITED) ;$WS_EX_COMPOSITED is not working with AERO properly
    Else
        $label = GUICtrlCreateLabel("", $size, $size, 0, 0) ;$WS_EX_COMPOSITED is not working with AERO properly
    EndIf

    GUICtrlSetBkColor($label, 0xFFD0A0)
    GUISetState(@SW_SHOW, $hGUI)
    WinSetTrans($hGUI, "", 0x40)
    WinActivate($hGUI)

    #cs
     -------
    | 1 | 3 |
     ---x---
    | 2 | 4 |
     -------
    x = start position of mouse
    #ce
    Do
        GUISetCursor(3, 1, $hGUI_Cross)
        $mpos = MouseGetPos()
        If $mpos[0] < $m_startx And $mpos[1] < $m_starty Then ;1
            $w = $m_startx - $mpos[0]
            $h = $m_starty - $mpos[1]
            WinMove($hGUI, "", $mpos[0], $mpos[1], $w, $h, 1)
            ToolTip($w & "x" & $h, $mpos[0] - 30, $mpos[1] - 30)
        ElseIf $mpos[0] < $m_startx And $mpos[1] > $m_starty Then ;2
            $w = $m_startx - $mpos[0]
            $h = $mpos[1] - $m_starty
            WinMove($hGUI, "", $mpos[0], $m_starty, $m_startx - $mpos[0], $mpos[1] - $m_starty, 1)
            ToolTip($w & "x" & $h)
        ElseIf $mpos[0] > $m_startx And $mpos[1] < $m_starty Then ;3
            $w = $mpos[0] - $m_startx
            $h = $m_starty - $mpos[1]
            WinMove($hGUI, "", $m_startx, $mpos[1], $mpos[0] - $m_startx, $m_starty - $mpos[1], 1)
            ToolTip($w & "x" & $h)
        Else ;4
            $w = $mpos[0] - $m_startx
            $h = $mpos[1] - $m_starty
            WinMove($hGUI, "", $m_startx, $m_starty, $mpos[0] - $m_startx, $mpos[1] - $m_starty, 1)
            ToolTip($w & "x" & $h)
        EndIf
        WinMove($hGUI_Cross, "", $mpos[0] - 15, $mpos[1] - 15)
        GUICtrlSetPos($label, $size, $size, $w - 2 * $size, $h - 2 * $size)
        Sleep(50)
    Until Not _IsPressed("01", $user32_dll)

    DllClose($user32_dll)
    GUIDelete($hGUI_Cross)
    Local $Win_Coord = WinGetPos($hGUI) ;x,y,width,height
    GUIDelete($hGUI)

    If $aero_on Then
        DllCall($hDwmApiDll, "int", "DwmEnableComposition", "uint", True)
    EndIf
    DllClose($hDwmApiDll)
    Sleep(500)
EndFunc

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I need once from the generated co-ords.

It's simple.

#Include <GDIPlus.au3>
#Include <Misc.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Opt('WinWaitDelay', 0)

_GDIPlus_Startup()

Global $hForm, $hPic, $Msg, $Mouse, $Prev, $Point = MouseGetPos(), $Pos[2], $Dim[2]
Global $Draw = False, $Show = False

$hForm = GUICreate('', -1, -1, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), GUICreate('', -1, -1, -1, -1, -1, $WS_EX_TOOLWINDOW))
$hPic = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\red.png')
_SetBitmap($hForm, 1, 1, 0)
GUISetState()

While 1
    Sleep(10)
    If _IsPressed('1B') Then
        Exit
    EndIf
    If _IsPressed('01') Then
        If $Show Then
            $Mouse = MouseGetPos()
            If ($Mouse[0] = $Prev[0]) And ($Mouse[1] = $Prev[1]) Then
                ContinueLoop
            EndIf
            $Prev = $Mouse
            For $i = 0 To 1
                Select
                    Case $Mouse[$i] < $Point[$i]
                        $Pos[$i] = $Mouse[$i]
                        $Dim[$i] = $Point[$i] - $Mouse[$i] + 1
                    Case $Mouse[$i] > $Point[$i]
                        $Pos[$i] = $Point[$i]
                        $Dim[$i] = $Mouse[$i] - $Point[$i] + 1
                    Case $Mouse[$i] = $Point[$i]
                        $Pos[$i] = $Point[$i]
                        $Dim[$i] = 1
                EndSelect
            Next
            If ($Dim[0] = 1) Or ($Dim[1] = 1) Then
                _SetBitmap($hForm, 1, 1, 0)
            Else
                _SetBitmap($hForm, $Dim[0], $Dim[1], 255)
            EndIf
            WinMove($hForm, '', $Pos[0], $Pos[1])
            $Draw = True
        Else
            $Point = MouseGetPos()
            $Prev = $Point
            $Show = True
        EndIf
    Else
        _SetBitmap($hForm, 1, 1, 0)
        If $Draw Then
            MsgBox(0x00040000, '', '(' & $Pos[0] & ', ' & $Pos[1] & ') - (' & ($Pos[0] + $Dim[0] - 1) & ', ' & ($Pos[1] + $Dim[1] - 1) & ')')
        EndIf
        $Draw = False
        $Show = False
    EndIf
WEnd

_GDIPlus_Shutdown()

Func _SetBitmap($hWnd, $iWidth, $iHeight, $iAlpha = 255)

    Local $hBitmap, $hImage, $hGraphic, $hPen

    $hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr', 0, 'ptr', 0)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage[4])
    $hPen = _GDIPlus_PenCreate(0x60FF0000)
    _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $iWidth - 1, $iHeight - 1, $hPen)
    _GDIPlus_PenDispose($hPen)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage[4])
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage[4])
    _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iAlpha, 1)
EndFunc   ;==>_SetBitmap

Func _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iOpacity = 255, $fDelete = 0)

    Local $Ret, $tBlend, $tObj, $tPoint, $hDC, $hDestDC, $hDestSv

    $tObj = DllStructCreate('long;long;long;long;ushort;ushort;ptr')
    $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj))
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    $Ret = DllCall('user32.dll', 'hwnd', 'GetDC', 'hwnd', $hWnd)
    $hDC = $Ret[0]
    $Ret = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleDC', 'hwnd', $hDC)
    $hDestDC = $Ret[0]
    $Ret = DllCall('gdi32.dll', 'hwnd', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hBitmap)
    $hDestSv = $Ret[0]
    $tPoint = DllStructCreate($tagPOINT)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    DllStructSetData($tBlend, 'Alpha', $iOpacity)
    DllStructSetData($tBlend, 'Format', 1)
    $Ret = DllCall('user32.dll', 'int', 'UpdateLayeredWindow', 'hwnd', $hWnd, 'hwnd', $hDC, 'ptr', 0, 'ptr', DllStructGetPtr($tObj, 2), 'hwnd', $hDestDC, 'ptr', DllStructGetPtr($tPoint), 'dword', 0, 'ptr', DllStructGetPtr($tBlend), 'dword', 2)
    DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $hWnd, 'hwnd', $hDC)
    DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hDestSv)
    DllCall('gdi32.dll', 'int', 'DeleteDC', 'hwnd', $hDestDC)
    If Not $Ret[0] Then
        Return SetError(1, 0, 0)
    EndIf
    If $fDelete Then
        DllCall('gdi32.dll', 'int', 'DeleteObject', 'ptr', $hBitmap)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_UpdateLayeredWindowEx
Link to comment
Share on other sites

I don't know why everyone goes to extremes for something so simple. All you need is a GUI with no title or border.

In this simple example, 'Home' sets start, 'End' sets end, 'Escape' exits:

; ===============================================================================================================================
; <_BoxSelection.au3>
;
; Author: Ascend4nt
; ===============================================================================================================================
Global $hBoxGUI,$bStarted=False,$iStartX,$iStartY
Func _StartAnchor()
    If $bStarted Then Return
    $bStarted=True
    Local $aPos=MouseGetPos()
    $iStartX=$aPos[0]
    $iStartY=$aPos[1]
    WinSetTrans($hBoxGUI,'',100)
EndFunc

Func _EndSelect()
    $bStarted=False
EndFunc

#include <Misc.au3>
Local $aLastPos[2]=[-1,-1],$aPos,$iX1,$iY1,$iWidth,$iHeight,$iTmp
;   Styles: Basic: WS_POPUP (0x80000000), Extended: WS_EX_NOACTIVATE 0x08000000 $WS_EX_TOOLWINDOW (0x80)
$hBoxGUI=GUICreate("",1,1,1,1,0x80000000,0x08000080)
GUISetBkColor(0xFF,$hBoxGUI)
WinSetTrans($hBoxGUI,'',0)
WinSetState($hBoxGUI,'',@SW_SHOWNOACTIVATE)
HotKeySet("{HOME}","_StartAnchor")
HotKeySet("{END}","_EndSelect")
While Not _IsPressed("1B")
    If $bStarted Then
        $aPos=MouseGetPos()
        If $aPos[0]<>$aLastPos[0] Or $aPos[1]<>$aLastPos[1] Then
            $iWidth=Abs($aPos[0]-$iStartX)+1
            $iHeight=Abs($aPos[1]-$iStartY)+1
            If $aPos[0]<$iStartX Then
                $iX1=$aPos[0]
            Else
                $iX1=$iStartX
            EndIf
            If $aPos[1]<$iStartY Then
                $iY1=$aPos[1]
            Else
                $iY1=$iStartY
            EndIf
            WinMove($hBoxGUI,'',$iX1,$iY1,$iWidth,$iHeight)
            $aLastPos=$aPos
        EndIf
    EndIf
    Sleep(10)
WEnd

You could also check out my _GUIBox UDF for creating just framed boxes.

*edit: If you want a frame around the above box, just change the GUI creation to this:

$hBoxGUI=GUICreate("",1,1,1,1,0x80000000,0x08000081)
Edited by Ascend4nt
Link to comment
Share on other sites

@Ascend4nt. Indeed, your window calculation is much simplier than what I did. :graduated:

Well done.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Well by moving a couple of lines outside the loop, I'm halfway there, in that I dont see an ever increasing box, rather dont see the bottom and right lines at all until the mouse is released.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Include <Misc.au3>

While 1
    Sleep(10)
    If _IsPressed("01") Then
        _rect()
    EndIf
    If _IsPressed("02") Then
        Exit
    EndIf
WEnd

Func _rect()
    Local $hDC, $hPen, $obj_orig
    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x00ff)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
    Local $sPos = MouseGetPos() ; rect start pos
    Local $ePos
    While _IsPressed("01")
        $ePos = MouseGetPos() ; rect current/end pos
        _WinAPI_DrawLine($hDC, $sPos[0], $sPos[1], $ePos[0], $sPos[1]) ;top x
        _WinAPI_DrawLine($hDC, $sPos[0], $sPos[1], $sPos[0], $ePos[1]) ;left y

        Sleep(10)
    WEnd
    _WinAPI_DrawLine($hDC, $sPos[0], $ePos[1], $ePos[0], $ePos[1]) ;bottom x
    _WinAPI_DrawLine($hDC, $ePos[0], $ePos[1], $ePos[0], $sPos[1]) ;right y
    Sleep(3000)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
    ; clear resources
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc

Except thats my problem. I want to see the botton and right lines increase. but not in the fashion they are in the OP.

I've a feeling _WinApi_MoveTo may be my salvation but just ghavent figured it out yet.

Thabks for all the alternatives, its well appreciated guys.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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