函数参考


_WinAPI_LineTo

从当前位置绘制一条线, 但不包括指定点.

#Include <WinAPI.au3>
_WinAPI_LineTo($hDC, $iX, $iY)

参数

$hDC 设备场景的句柄
$iX 线的终点 X 坐标.
$iY 线的终点 Y 坐标.

返回值

成功: 返回 True
失败: 返回 False

注意/说明

使用当前笔绘制线, 如果笔是一个几何笔,也是当前的画笔.
如果 LineTo 成功,当前位置设置为指定的终点.

相关

_WinAPI_MoveTo, _WinAPI_DrawLine, _WinAPI_SelectObject, _WinAPI_CreatePen

详情参考

在MSDN中搜索


示例/演示


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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($start_x, $start_y, $length, $width, $color, $time)
    Local $hDC, $hPen, $obj_orig

    $hDC = _WinAPI_GetWindowDC(0) ; 全屏场景(桌面)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $width, $color)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $start_x - $length, $start_y, $start_x - 5, $start_y) ; 水平向左
    _WinAPI_DrawLine($hDC, $start_x + $length, $start_y, $start_x + 5, $start_y) ; 水平向右
    _WinAPI_DrawLine($hDC, $start_x, $start_y - $length, $start_x, $start_y - 5) ; 垂直向上
    ;_WinAPI_DrawLine($hDC, $start_x, $start_y + $length, $start_x, $start_y + 5) ; 垂直向下
    _WinAPI_MoveTo($hDC, $start_x, $start_y + $length)
    _WinAPI_LineTo($hDC, $start_x, $start_y + 5)

    Sleep($time) ; 越屏显示定义的秒数

    ; 刷新桌面 (清除穿越)
    _WinAPI_RedrawWindow( _WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; 清理资源
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross