attreus Valued Newbie
Joined: 30 Jul 2002 Posts: 46 Location: Berlin/Germany
|
Posted: Wed Apr 25, 2007 8:48 am Post subject: working code to get left middle or right mouseclick |
|
|
hi,
here is a script to get mouseclicks on all buttons. it works fine on winxp and
should do also on win2000. could not test it on 95,98,me,vista - please report.
i think this could be useful for several of you.
Code: |
# This code is intended as a proper working replacement for
# the awful @mousedown function. You can capture mouseclicks
# globally or use the @winactive()-function to obtain the
# window that was clicked on.
# If a button is specified the function returs 1 or NULL. If
# not, it returns the button by initial letter.
# It also works correctly with a left-hand-mouse.
Title Mouse Example
#define Function,Mouse
option decimalsep,.
DIALOG CREATE,Mouse Example by attreus,-1,0,240,100,class MouseExample,ontop
DIALOG ADD,Text,TX1,32,94
DIALOG ADD,STATUS,STAT,
DIALOG SHOW
:Evloop
wait event,0.1
goto @event()
:timer
# remove this condition to get global clicks
if @equal(@winactive(C),MouseExample)
%X = @Mouse()
%L = @Mouse(L)
%M = @Mouse(M)
%R = @Mouse(R)
dialog set,TX1,Button: %X
dialog set,stat,Left=%L@tab()Middle=%M@tab()Right=%R
end
goto evloop
:Close
exit
# Function Mouse
# -----------------
# put the #include statement here and compile the
# code to Mouse.dsu if you like.
:Mouse
LOADLIB user32.dll
# First check if mousebuttons are swapped
# GetSystemMetrics(SM_SWAPBUTTON)
%S = @LIB(user32,GetSystemMetrics,INT:,$17)
# if no button was specified return the initial letter
if @not(%1)
goto MouseBtn
end
if @equal(%S,0)
if @equal(%1,L)
%B = 01
elsif @equal(%1,M)
%B = 04
elsif @equal(%1,R)
%B = 02
else
goto MouseExit
end
elsif @equal(%S,1)
if @equal(%1,L)
%B = 02
elsif @equal(%1,M)
%B = 04
elsif @equal(%1,R)
%B = 01
else
goto MouseExit
end
else
goto MouseExit
end
# now get state of the button
%X = @LIB(user32,GetAsyncKeyState,INT:,$%B)
# and convert it to a bool value
if @unequal(%X,0)
%X = 1
else
%x =
end
goto MouseExit
:MouseBtn
%L = @LIB(user32,GetAsyncKeyState,INT:,$01)
%M = @LIB(user32,GetAsyncKeyState,INT:,$04)
%R = @LIB(user32,GetAsyncKeyState,INT:,$02)
if @equal(%S,0)
if @unequal(%L,0)
%X = L
elsif @unequal(%M,0)
%X = M
elsif @unequal(%R,0)
%X = R
end
elsif @equal(%S,1)
if @unequal(%L,0)
%X = R
elsif @unequal(%M,0)
%X = M
elsif @unequal(%R,0)
%X = L
end
end
:MouseExit
FREELIB USER32
exit %X
|
greetings attreus
edit: i have modified the script that if no button is specified it returns the button by initial letter.
attreus |
|