Mouse Tester

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

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

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Mouse Tester

Post by Phil Pendlebury » Mon Nov 22, 2010 3:48 pm

A very basic script but there a few things here that may help some folks.

Of course, as usual, many ways to skin a cat.

Image

Code: Select all

//Do not remove the spaces as they are there for alignment 
Dialog>Dialog1
object Dialog1: TForm
  Left = 675
  Top = 413
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  BorderStyle = bsSingle
  Caption = 'Mouse Test by Phil P (www.pendlebury.biz)'
  ClientHeight = 236
  ClientWidth = 504
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSMemo1: tMSMemo
    Left = 8
    Top = 37
    Width = 289
    Height = 192
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Courier New'
    Font.Style = []
    ParentFont = False
    ScrollBars = ssVertical
    TabOrder = 0
  end
  object MSButton1: tMSButton
    Left = 304
    Top = 8
    Width = 193
    Height = 193
    Caption = 'MOUSE HERE'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 1
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 6
    Top = 8
    Width = 291
    Height = 25
    Caption = 'CLEAR'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object Edit1: TEdit
    Left = 304
    Top = 208
    Width = 193
    Height = 21
    TabOrder = 3
  end
end
EndDialog>Dialog1


AddDialogHandler>Dialog1,MSButton2,OnClick,CLEAR
AddDialogHandler>Dialog1,MSButton1,OnMouseDown,MDOWN
AddDialogHandler>Dialog1,MSButton1,OnMouseUp,MUP
AddDialogHandler>Dialog1,MSButton1,OnMouseMove,MOVE
AddDialogHandler>Dialog1,,OnClose,EXIT

Show>Dialog1,result
Let>lines=0

SRT>MDOWN
  GetCursorPos>mx,my
  GOSUB>DBUTCHECK
  GOSUB>EXIST
  IF>%existing%=
    SetDialogProperty>Dialog1,MSMemo1,Text,%clicktime% %dbutt% Down (x=%mx% y=%my%)
  ELSE
    SetDialogProperty>Dialog1,MSMemo1,Text,%existing%%CRLF%%clicktime% %dbutt% Down (x=%mx% y=%my%)
  ENDIF
END>MDOWN

SRT>MUP
  GetCursorPos>mx,my
  GOSUB>UBUTCHECK
  GOSUB>EXIST
  SetDialogProperty>Dialog1,MSMemo1,Text,%existing%%CRLF%%clicktime% %ubutt% Up   (x=%mx% y=%my%)
END>MUP

SRT>MOVE
  GetCursorPos>mx,my
  SetDialogProperty>Dialog1,Edit1,Text,x=%mx% y=%my%
END>MOVE

SRT>CLEAR
  SetDialogProperty>Dialog1,MSMemo1,Text,
END>CLEAR

SRT>EXIST
  GetDialogProperty>Dialog1,MSMemo1,Text,existing
  GetTime>clicktime
END>EXIST

SRT>DBUTCHECK
  Let>mdbutton=%MDOWN_BUTTON%
  SetDialogProperty>Dialog1,Edit1,Text,x=%mx% y=%my% button val: %mdbutton%
  IF>mdbutton=0
    LET>dbutt=Left  
  ENDIF
  IF>mdbutton=8386
    LET>dbutt=Right 
  ENDIF
    IF>mdbutton=32
    LET>dbutt=Middle
  ENDIF
END>DBUTCHECK

SRT>UBUTCHECK
  Let>mubutton=%MUP_BUTTON%
  SetDialogProperty>Dialog1,Edit1,Text,x=%mx% y=%my% button val: %mubutton%
  IF>mubutton=0
    LET>ubutt=Left  
  ENDIF
  IF>mubutton=8386
    LET>ubutt=Right 
  ENDIF
  IF>mubutton=32
    LET>ubutt=Middle
  ENDIF
END>UBUTCHECK

SRT>EXIT
  Exit>0
END>EXIT
Last edited by Phil Pendlebury on Wed Dec 08, 2010 9:19 am, edited 6 times in total.
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Nov 22, 2010 4:26 pm

Can I suggest a small enhancement. In the MDOWN function check the value of MDOWN_BUTTON to see which button was clicked and output accordingly ....
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Nov 22, 2010 7:28 pm

Great idea Marcus - There was a few things I thought of adding which I will get to eventually. Thanks.
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Wed Nov 24, 2010 3:15 pm

Hi Marcus, I have added check for up and down button.

However, I have query here:

On my system
Left Button is always value 0
Right Button is always value 8386

I cannot get a value for middle button is that normal?
Also are the values likely to be different on different systems?

I have added a readout of the value (next to the coordinates - it appears when you click).

:-)
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Wed Dec 08, 2010 9:20 am

Added check for Middle Button (value is 32 on my system).
Phil Pendlebury - Linktree

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