#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: Matwachich Script Function: Dessin direct sur l'écran #ce ---------------------------------------------------------------------------- #include #include Global $__DesktopDraw_DrawHandle[3] = [0, 0, 0] #cs HotKeySet("{esc}", "_exit") _DesktopDraw_Start() Global $old_mouse_pos[2] = [0, 0] $mouse_pos = MouseGetPos() _DesktopDraw_MoveTo($mouse_pos[0], $mouse_pos[1]) While 1 $mouse_pos = MouseGetPos() If $mouse_pos[0] <> $old_mouse_pos[0] Or $mouse_pos[1] <> $old_mouse_pos[1] Then _DesktopDraw_LineTo($mouse_pos[0], $mouse_pos[1]) ;~ _DesktopDraw_Cross($mouse_pos[0], $mouse_pos[1]) $old_mouse_pos[0] = $mouse_pos[0] $old_mouse_pos[1] = $mouse_pos[1] EndIf Sleep(1) WEnd Func _exit() _DesktopDraw_End() Exit EndFunc #ce Func _DesktopDraw_Start($penStyle = $PS_SOLID, $penWidth = 2, $penColor = 0x0000FF) If __DesktopDraw_IsInit() Then Return 0 Local $hDC, $hPen, $obj_orig $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($penStyle, $penWidth, __DesktopDraw_RGB_to_BGR($penColor)) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) $__DesktopDraw_DrawHandle[0] = $hDC $__DesktopDraw_DrawHandle[1] = $hPen $__DesktopDraw_DrawHandle[2] = $obj_orig Return 1 EndFunc Func _DesktopDraw_PenChange($penStyle, $penWidth, $penColor) If Not __DesktopDraw_IsInit() Then Return 0 _DesktopDraw_End() _DesktopDraw_Start($penStyle, $penWidth, $penColor) Return 1 EndFunc Func _DesktopDraw_End() If Not __DesktopDraw_IsInit() Then Return 0 _WinAPI_SelectObject($__DesktopDraw_DrawHandle[0], $__DesktopDraw_DrawHandle[2]) _WinAPI_DeleteObject($__DesktopDraw_DrawHandle[1]) _WinAPI_ReleaseDC(0, $__DesktopDraw_DrawHandle[0]) For $i = 0 To 2 $__DesktopDraw_DrawHandle[$i] = 0 Next Return 1 EndFunc Func _DesktopDraw_Line($x1, $y1, $x2, $y2) If Not __DesktopDraw_IsInit() Then Return 0 _WinAPI_DrawLine($__DesktopDraw_DrawHandle[0], $x1, $y1, $x2, $y1) _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) Return 1 EndFunc Func _DesktopDraw_Cross($x, $y, $length = 40, $centerLigneDistance = 10) _DesktopDraw_Line($x - $length, $y, $x - $centerLigneDistance, $y) _DesktopDraw_Line($x + $length, $y, $x + $centerLigneDistance, $y) _DesktopDraw_MoveTo($x, $y - $length) _DesktopDraw_LineTo($x, $y - $centerLigneDistance) _DesktopDraw_MoveTo($x, $y + $length) _DesktopDraw_LineTo($x, $y + $centerLigneDistance) Return 1 EndFunc Func _DesktopDraw_MoveTo($x, $y) If Not __DesktopDraw_IsInit() Then Return 0 Return _WinAPI_MoveTo($__DesktopDraw_DrawHandle[0], $x, $y) EndFunc Func _DesktopDraw_LineTo($x, $y) If Not __DesktopDraw_IsInit() Then Return 0 Return _WinAPI_LineTo($__DesktopDraw_DrawHandle[0], $x, $y) EndFunc Func __DesktopDraw_IsInit() If $__DesktopDraw_DrawHandle[0] = 0 Then Return 0 Else Return 1 EndIf EndFunc Func __DesktopDraw_RGB_to_BGR($rgb) $rgb = StringTrimRight(Binary($rgb), 2) If Not StringInStr($rgb, "0x") Then Return 0 $rgb = StringRight($rgb, 6) $b = StringRight($rgb, 2) $r = StringLeft($rgb, 2) $g = StringMid($rgb, 3, 2) Local $bgr = Binary("0x" & $b & $g & $r) Return $bgr EndFunc