March 8, 2010

Screen Magnifier In Only 34 Lines of Code

Filed under: General,Scripting — Marcus Tettmar @ 9:46 am

Check out this screen magnifier, written by Dick Lockey in only 34 lines of Macro Scheduler code.   Paste it into a macro, hit run and then as you move the mouse around your screen you’ll see a 5x magnification of the cursor area.

Dialog>Dialog1
   Caption=5X Magnify
   Width=800
   Height=500
   Top=500
   Left=48
EndDialog>Dialog1
Show>Dialog1
  LibFunc>user32,GetDC,HDC1,Dialog1.handle
  LibFunc>user32,GetDC,HDC3,0

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  GetCursorPos>CurX,CurY
  Sub>CurX,80
  Sub>CurY,50
  Wait>0.01
  LibFunc>Gdi32,StretchBlt,SBres,HDC1,0,0,800,500,HDC3,CURX,CURY,160,100,13369376
  GoSub>DrawLine,Dialog1.handle,1,0,390,250,410,250
  GoSub>DrawLine,Dialog1.handle,1,0,400,240,400,260
Goto>Loop

SRT>DrawLine
  LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
  LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
  LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
  Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
  LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
  LibFunc>gdi32,DeleteObject,DOres,Penres
  LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine

Yes, as Dick Says, you get one of these with Windows. But it’s kind of cool to see you can do the same thing with Macro Scheduler, and the code might come in handy elsewhere.

Enjoy.