找回密码
 加入
搜索
查看: 2497|回复: 7

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

  [复制链接]
发表于 2011-8-23 10:25:40 | 显示全部楼层 |阅读模式
本帖最后由 bbskingfly 于 2011-8-23 14:53 编辑

如题,谢谢
发表于 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)
发表于 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

评分

参与人数 1威望 +5 金钱 +20 贡献 +5 收起 理由
pusofalse + 5 + 20 + 5 热心助人。

查看全部评分

发表于 2011-8-23 10:50:17 | 显示全部楼层
翻了下帮助,一刷新发现已有人回复了...
 楼主| 发表于 2011-8-23 11:00:00 | 显示全部楼层
回复 2# pusofalse


O(∩_∩)O谢谢,原来小弟的版本已经落后这么久了!
 楼主| 发表于 2011-8-23 11:00:16 | 显示全部楼层
回复 3# powerofos


O(∩_∩)O谢谢,原来小弟的版本已经落后这么久了!
发表于 2011-8-23 11:54:03 | 显示全部楼层
P版大侠真是厉害
 楼主| 发表于 2011-8-23 14:42:12 | 显示全部楼层
本帖最后由 bbskingfly 于 2011-8-23 14:51 编辑

回复 2# pusofalse

谢谢pusofalse版主,学习了,不过可不可以设定线型呢?比如说粗细?
明白了,调整_WinAPI_CreatePen 的参数就可以啦O(∩_∩)O~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 17:32 , Processed in 0.075370 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表