forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


working code to get left middle or right mouseclick

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code
View previous topic :: View next topic  
Author Message
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Wed Apr 25, 2007 8:48 am    Post subject: working code to get left middle or right mouseclick Reply with quote

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
Back to top
View user's profile Send private message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Fri Oct 06, 2017 9:05 pm    Post subject: Reply with quote

Just found this. Thanks this helps a lot!
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group