It is currently Wed May 22, 2013 2:30 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: simulating mouse clicks?
PostPosted: Wed Mar 14, 2012 3:09 pm 
Offline
User
User

Joined: Sat Sep 10, 2005 5:38 pm
Posts: 52
hi,

how can i simulate mouse clicks?

thanks!


Top
 Profile  
 
 Post subject: Re: simulating mouse clicks?
PostPosted: Wed Mar 14, 2012 7:18 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 814
Location: Germany
Code:
ImportC ""
  CFRelease(CFTypeRef.L)
  CGEventCreateMouseEvent(EventSourceRef.L, MouseEventType.L, x.F, y.F, MouseButton.L)
  CGEventPost(CGEventTapLoacation.L, CGEventRef.L)
EndImport

#kCGMouseButtonLeft = 0
#kCGEventLeftMouseDown = 1
#kCGEventLeftMouseUp = 2
#kCGHIDEventTap = 0

OpenWindow(0, 200, 100, 300, 70, "ButtonGadgets")
ButtonGadget(0, 10, 10, WindowWidth(0) - 20, 20, "Click me to activate Button below")
ButtonGadget(1, 10, 40, WindowWidth(0) - 20, 20, "Click me to activate me")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Debug "Upper button pressed"
          EventRef = CGEventCreateMouseEvent(0, #kCGEventLeftMouseDown, 340.0, 170.0, #kCGMouseButtonLeft)         
          CGEventPost(#kCGHIDEventTap, EventRef)
          CFRelease(EventRef)
          EventRef = CGEventCreateMouseEvent(0, #kCGEventLeftMouseUp, 340.0, 170.0, #kCGMouseButtonLeft)         
          CGEventPost(#kCGHIDEventTap, EventRef)
          CFRelease(EventRef)
        Case 1
          Debug "Lower button pressed"
      EndSelect
  EndSelect
ForEver


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye