Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OSD grid lines
#1
Hello,

Any one has macro that can display grid lines on the screen. Adjusting transparency, grid size and lines` thickness would be also nice.

Thanks!
#2
Macro OSD grid
Code:
Copy      Help
int hwnd=OnScreenGrid(0 0 ScreenWidth ScreenHeight 32 1 ColorFromRGB(255 200 0) 160)
wait 2

;if need to change grid properties at run time, use hwnd
OnScreenGrid(0 0 ScreenWidth ScreenHeight 100 4 ColorFromRGB(0 200 0) 50 hwnd)
wait 2

;if need to remove the grid before the thread ends
OnScreenDrawEnd hwnd

Function OnScreenGrid
Code:
Copy      Help
;/
function# x y width height gridSize [lineThickness] [lineColor] [transparency] [hwnd]

;Shows grid on screen.
;Returns grid window handle. It can be used with OnScreenDrawEnd, or with another OnScreenGrid call (to change grid properties).
;The thread must then wait.

;x, y, width, height - where to show grid.
;gridSize - width and height of grid cells.
;lineThickness, lineColor - properties of grid lines.
;transparency - transparency of grid lines. Can be 1 (almost transparent) to 255 (opaque). If 0, does not cange.
;hwnd - handle of grid window, returned by previous OnScreenGrid call. Use if you want to dynamically change grid properties.


type OSDGRID gridSize lineThickness lineColor

if(transparency and hwnd) Transparent hwnd transparency GetSysColor(COLOR_BTNFACE) ;;OnScreenDraw doesn't change it

ret OnScreenDraw(x y width height &OSD_ProcGrid &gridSize transparency 1 sizeof(OSDGRID) hwnd)

Function OSD_ProcGrid
Code:
Copy      Help
;/
function hwnd hdc cx cy OSDGRID&g

int hpen oldpen

hpen=CreatePen(0 g.lineThickness g.lineColor); oldpen=SelectObject(hdc hpen)

ARRAY(int) ai
ARRAY(POINT) a
int i k

;horz lines

ai.create(cy/g.gridSize)
a.create(ai.len*2)
k=0
for i 0 a.len
,ai[i/2]=2
,k+g.gridSize
,a[i].y=k
,i+1
,a[i].y=k
,a[i].x=cx

PolyPolyline(hdc &a[0] &ai[0] ai.len)

;vert lines

ai.create(cx/g.gridSize)
a.create(ai.len*2)
k=0
for i 0 a.len
,ai[i/2]=2
,k+g.gridSize
,a[i].x=k
,i+1
,a[i].x=k
,a[i].y=cy

PolyPolyline(hdc &a[0] &ai[0] ai.len)

DeleteObject SelectObject(hdc oldpen)


Also you will need on-screen draw functions.
If don't have, download Archive.qml from
Collected QM apps, functions, samples
and import 'On-screen draw' folder. It is in folder 'Samples - other'.
#3
Thanks, all works great. Can you also tell me how to draw a circle with the centre being exactly where the mouse pointer is? And how to draw a line that starts/ends from to points i click on the screen?
#4
i can see there is example of drawing a line in archives, but how to make the line stay on the screen for x seconds?
#5
Macro OSD mouse circle
Code:
Copy      Help
;As you move the mouse, draws circle around mouse pointer. Click to stop.

int rad=32 ;;change this
;_________________________

POINT p pp
rep
,ifk((1)) break
,0.01
,xm p
,if(!memcmp(&pp &p sizeof(POINT))) continue
,pp=p
,int h=OnScreenDraw(p.x-rad p.y-rad rad*2 rad*2 &OSD_ProcExample3 0 80 1 0 h)

Function OSD_ProcExample3
Code:
Copy      Help
;/
function hwnd hdc cx cy param

int hpen oldpen

hpen=CreatePen(0 2 0xff0000); oldpen=SelectObject(hdc hpen)
Ellipse hdc 0 0 cx cy
DeleteObject SelectObject(hdc oldpen)

______________________________________

Macro OSD line static
Code:
Copy      Help
OnScreenDisplay "Click 2 times. The macro will draw line between clicks." 3

;wait for 2 clicks and get their coordinates
POINT p1 p2
wait 0 ML
xm p1
wait 0 ML
xm p2

;draw line
int color=ColorFromRGB(255 0 0)
OnScreenLine(p1.x p1.y p2.x p2.y color 2)

wait 5


Forum Jump:


Users browsing this thread: 1 Guest(s)