Mouse Cursor Monitor++ - MSched v12

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Mouse Cursor Monitor++ - MSched v12

Post by Rain » Sun Dec 05, 2010 6:00 pm

Image

Submitted by: Rain

Macro Scheduler Version: 12

Description: Cursor Monitor++ displays the current mouse cursor position and pixel color in a large font. I've included a preview panel of the pixel color in the current cursor position and a magnifier to magnify the area around the cursor. Credit for the magnifier goes to JRL and his "A toy for old eyes" examples here http://www.mjtnet.com/forum/viewtopic.php?t=6030

You can change the magnification by editing the Magnification factor inside the script.

Please Plus Rep me if you find this script useful.

Code: Select all

/*
Mouse Cursor Monitor++ by Rain
Credit for the Magnifier Goes To JRL
Magnifier Topic http://www.mjtnet.com/usergroup/viewtopic.php?p=26751
*/

LET>APP_TITLE=Mouse Cursor Monitor++ by Rain
//Add Tray icon
IfFileExists>%TEMP_DIR%MschedulerCursorMonitor.ico
ELSE
ExportData>CMONITOR.ICO_DATA,%TEMP_DIR%MschedulerCursorMonitor.ico
ENDIF
AddTrayIcon>%TEMP_DIR%MschedulerCursorMonitor.ico,MyTrayIcon,Double Click To Show And Hide Cursor Monitor Or Press Alt+Esc To Exit

LibFunc>user32,MessageBoxA,r,0,Double Click Tray Icon To Hide And Show Cursor Monitor%CRLF%%CRLF%Press Alt+Esc To Exit Cursor Monitor,Mscheduler Cursor Monitor Hot Keys Info,270400


Dialog>Dialog1
object Dialog1: TForm
  Left = 440
  Top = 144
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  BorderStyle = bsNone
  BorderWidth = 2
  Caption = 'Mouse Cursor Monitor++ by Rain'
  ClientHeight = 96
  ClientWidth = 246
  Color = clLime
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -15
  Font.Name = 'Tahoma'
  Font.Style = [fsBold]
  OldCreateOrder = True
  Position = poOwnerFormCenter
  ShowHint = False
  OnTaskBar = True
  PixelsPerInch = 96
  TextHeight = 18
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 249
    Height = 25
    Align = alCustom
    Alignment = taLeftJustify
    BevelWidth = 2
    Color = 14548991
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -19
    Font.Name = 'Tahoma'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 0
    object Panel2: TPanel
      Left = 216
      Top = 1
      Width = 30
      Height = 22
      BevelKind = bkSoft
      Color = clBlack
      ParentBackground = False
      TabOrder = 0
    end
  end
end
EndDialog>Dialog1


GetDialogProperty>Dialog1,Panel1,Width,Panel1Width
GetDialogProperty>Dialog1,,BorderWidth,Border_Width
SetDialogProperty>Dialog1,,ClientWidth,Panel1Width

SetDialogProperty>Dialog1,,FormStyle,fsStayOnTop
GetDialogProperty>Dialog1,,ClientWidth,Wide
GetDialogProperty>Dialog1,,ClientHeight,High

Show>Dialog1

//Press Alt+Esc To Exit
OnEvent>KEY_DOWN,VK27,3,EXIT


//Set Hide Or Show Dialog1 To False
//FALSE=Show Dialog1
LET>HIDE_WINDOW=FALSE


//Add Tray icon Handler to hide or show Dialog1
AddTrayHandler>MyTrayIcon,OnDblClick,HIDE_OR_SHOW


//Magnification factor
Let>Magnification=15

//Set far right dialog position
GetScreenRes>X_POS,Y_POS
let>Border_Width=%Border_Width%*2
let>X_POS={%X_POS%-%Wide%-%Border_Width%}

GoSub>SetupMagnifier
//////////// Acquire the needed "Device Context" /////////////
// For more on "Device Context", see the Microsoft MSDN web site.
LibFunc>user32,GetDC,HDC1,Dialog1.handle
LibFunc>user32,GetDC,HDC3,0



Label>Loop
Wait>0.05

Let>WIN_USEHANDLE=1
GetWindowSize>Dialog1.handle,WinW,WinH
Let>WIN_USEHANDLE=0

        If>{(%WinW%<>%Wide%)or(%WinH%<>%High%)}
        Let>Wide=%WinW%
        Let>High=%WinH%
        GoSub>SetupMagnifier
        EndIf

GetCursorPos>MagnifyX,MagnifyY
GetPixelColor>MagnifyX,MagnifyY,theCOLOR
SetDialogProperty>Dialog1,Panel1,Caption, %MagnifyX%,%MagnifyY%,%theCOLOR%
SetDialogProperty>Dialog1,Panel2,Color,%theCOLOR%

    //<--Start Move Dialog away from cursor
    IF>{(%MagnifyX%<%Wide%) AND (%MagnifyY%<%High%)}
    //Move Dialog Right
    MoveWindow>Mouse Cursor Monitor++ by Rain,X_POS,0
    ENDIF
    IF>{(%MagnifyX%>%X_POS%) AND (%MagnifyY%<%High%)}
    //Move Dialog Left
    MoveWindow>Mouse Cursor Monitor++ by Rain,0,0
    ENDIF
    //<--End Move Dialog away from cursor

Sub>MagnifyX,%UpperLeftAreaX%
Sub>MagnifyY,%UpperLeftAreaY%

/////// The function that's doing the Magnifier display
LibFunc>Gdi32,StretchBlt,SBres,HDC1,0,0,%Wide%,%High%,HDC3,MagnifyX,MagnifyY,%AreaX%,%AreaY%,13369376
GoSub>DrawLine,Dialog1.handle,1,0,%CrossHairDown%,%CrossHairY%,%CrossHairUp%,%CrossHairY%
GoSub>DrawLine,Dialog1.handle,1,0,%CrossHairX%,%CrossHairLeft%,%CrossHairX%,%CrossHairRight%

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



SRT>SetupMagnifier
  Let>AreaX={round(%Wide%/%Magnification%)}
  Let>AreaY={round(%High%/%Magnification%)}
  Let>UpperLeftAreaX={round(%AreaX%/2)}
  Let>UpperLeftAreaY={round(%AreaY%/2)}
  Let>CrossHairX={round(%Wide%/2)}
  Let>CrossHairY={round(%High%/2)}
  Let>CrossHairUp=%CrossHairX%+10
  Let>CrossHairDown=%CrossHairX%-10
  Let>CrossHairRight=%CrossHairY%+10
  Let>CrossHairLeft=%CrossHairY%-10
END>SetupMagnifier








SRT>HIDE_OR_SHOW
IF>HIDE_WINDOW=TRUE
//Show Cursor Monitor
LET>HIDE_WINDOW=FALSE
Show>Dialog1
ELSE
//Hide Cursor Monitor
LET>HIDE_WINDOW=TRUE
CloseDialog>Dialog1
ENDIF
WAIT>.5
END>HIDE_OR_SHOW







SRT>EXIT
  Exit>0
END>EXIT






/*
CMONITOR.ICO_DATA:
0000010001001010000001002000680400001600000028000000100000002000000001002000000000004004000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000690F0F0F980F0F0F9800000069000000100000000000000000000000000000000000000000000
00000000000260000004A0000004A000000573A3835E7ABA8A3FFD0CCC7FFD0CCC7FFACA8A3FF3A3836E70000005C000000510000005100000029000000000000004E524D45FC787164FF787164FF787164FF978E7EFF999080FF999080FF999080FF999080FF978E7EFF7C7567FF7E7767FF8C836AFF514C43FB0000004612
110FA5A69E8FFFC1B697FFC0B185FFC2B389FFC3B68CFFC4B890FFC6BA94FFC6BA93FFC4B78FFFC3B58CFFC1B388FFC0B084FFC4B894FFA69E8EFF090908971A1917AEB0A99BFFCAAF59FFD1B650FFD9C36DFFDFCD88FFE5D8A2FFE9E0B8FFE9DFB5FFE4D69EFFDECC84FFD8C169FFD0B44CFFC9AE56FFB0A99BFF10100EA02
01F1CB4BAB3A7FFCCB157FFD7BD55FFDCC870FFE2D18AFFE6D9A1FFE9DFB0FFE9DEAEFFE6D89EFFE1D086FFDBC66CFFD6BB51FFCBB055FFBAB3A7FF171615A8262523BAC3BDB3FFC9AD4FFFD5B94AFFD9C262FFDECA78FFE1D189FFE3D493FFE3D492FFE1D087FFDDC974FFD9C05EFFD4B846FFC8AB4CFFC3BDB3FF1E1D1CB0
2D2B29C0CCC7BDFFC5A744FFD2B43CFFD6BB50FFD9C262FFDCC76FFFDECA77FFDECA76FFDCC66DFFD9C15FFFD5BA4DFFD1B338FFC3A541FFCCC7BDFF262523B8343331C6D4D0C8FFBFA037FFCEAE2BFFD2B43CFFD5BA4BFFD7BD55FFD8BF5BFFD8BF5AFFD7BD54FFD4B949FFD1B33AFFCEAD28FFBE9E35FFD4D0C8FF2E2D2CC
03B3A38CCDBD7D1FFBB992CFFCCAA20FFCFAF2DFFD1B339FFD3B641FFD4B845FFD4B845FFD3B640FFD1B337FFCFAE2BFFCCA91DFFBA982AFFDBD7D1FF373634C8424140D2E0DDD8FFBB9A30FFD1B234FFD3B53CFFD4B844FFD5BA4AFFD6BB4DFFD6BB4DFFD5BA49FFD4B743FFD2B43BFFD1B132FFBB9B30FFE0DDD8FF403F3D
CF4A4948D8E4E1DDFFC2A757FFE3D289FFE4D38CFFE5D48FFFE5D591FFE6D692FFE6D692FFE5D591FFE5D48EFFE4D38BFFE3D289FFC2A857FFE4E1DDFF494847D74D4C4CDBEDEBE8FFC6B68DFFCEBD8FFFCEBD8FFFCFBD8FFFCFBE8FFFCFBE90FFCFBE90FFCFBE8FFFCFBD8FFFCEBD8FFFCEBD8FFFC6B68DFFEDEBE8FF4D4C4
BDA0F0F0F90B4B2B1FFE5E2DFFFEBE8E6FFF0EEECFFF3F1F0FFF5F3F2FFF5F4F3FFF5F4F2FFF4F3F1FFF2F0EFFFEEECEAFFE8E5E3FFE0DDD9FFA9A8A6FF0C0C0C89000000020000005B312E2BE189847FFFB0ADA9FFDFDCD9FFF0EFEDFFF7F7F6FFF5F5F4FFEBE9E7FFD5D2CDFFA6A29DFF7E7A75FF282522DA000000500000
000100000000000000000000000A000000440101016D0F0E0E9C1111119B101010980F0F0F980E0E0D980A090997000000660000003C000000060000000000000000F81F00008001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C00
30000
*/

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts