bbskingfly 发表于 2011-8-23 10:25:40

(已解决)请问有木有可能不建立GUI在屏幕上画条线?求思路,谢谢!

本帖最后由 bbskingfly 于 2011-8-23 14:53 编辑

如题,谢谢

pusofalse 发表于 2011-8-23 10:43:46

#include <WinAPI.au3>

$hDC = _WinAPI_GetDC(0)
$hPen = _WinAPI_CreatePen(2, 5, 0)

_WinAPI_SelectObject($hDC, $hPen)
_WinAPI_DrawLine($hDC, 200, 200, 800, 200)

_WinAPI_DeleteObject($hPen)
_WinAPI_ReleaseDC(0, $hDC)

powerofos 发表于 2011-8-23 10:49:36

#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) ; DC of entire screen (desktop)
    $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) ; horizontal left
    _WinAPI_DrawLine($hDC, $start_x + $length, $start_y, $start_x + 5, $start_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $start_x, $start_y - $length, $start_x, $start_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $start_x, $start_y + $length, $start_x, $start_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $start_x, $start_y + $length)
    _WinAPI_LineTo($hDC, $start_x, $start_y + 5)

    Sleep($time) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _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   ;==>ShowCross

powerofos 发表于 2011-8-23 10:50:17

翻了下帮助,一刷新发现已有人回复了...

bbskingfly 发表于 2011-8-23 11:00:00

回复 2# pusofalse


O(∩_∩)O谢谢,原来小弟的版本已经落后这么久了!

bbskingfly 发表于 2011-8-23 11:00:16

回复 3# powerofos


O(∩_∩)O谢谢,原来小弟的版本已经落后这么久了!

hzxymkb 发表于 2011-8-23 11:54:03

P版大侠真是厉害

bbskingfly 发表于 2011-8-23 14:42:12

本帖最后由 bbskingfly 于 2011-8-23 14:51 编辑

回复 2# pusofalse

谢谢pusofalse版主,学习了,不过可不可以设定线型呢?比如说粗细?
明白了,调整_WinAPI_CreatePen 的参数就可以啦O(∩_∩)O~
页: [1]
查看完整版本: (已解决)请问有木有可能不建立GUI在屏幕上画条线?求思路,谢谢!