It is currently Sat Jan 16, 2021 9:08 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Move mouse cursor
PostPosted: Tue Dec 03, 2019 11:11 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 338
Location: NL
Any reason why this code does not position the mouse at the center of the screen?

Code:
EnableExplicit

ImportC ""
  CGWarpMouseCursorPosition(p)
  CGMainDisplayID()
  CGDisplayPixelsWide(did)
  CGDisplayPixelsHigh(did)
  CGEventSourceCreate(state)
  CGEventSourceSetLocalEventsSuppressionInterval(event, seconds) 
EndImport

Procedure Test()
  Protected mouseLoc.CGPoint
 
  Protected did = CGMainDisplayID()
  mouseLoc\x = CGDisplayPixelsWide(did) / 2
  mouseLoc\y = CGDisplayPixelsHigh(did) / 2
  CGWarpMouseCursorPosition(mouseLoc)
;   Protected evs = CGEventSourceCreate(0)
;   CGEventSourceSetLocalEventsSuppressionInterval(evs, 0) 
EndProcedure

Test()


Top
 Profile  
Reply with quote  
 Post subject: Re: Move mouse cursor
PostPosted: Tue Dec 03, 2019 11:43 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 338
Location: NL
Ok, this one does work CGWarpMouseCursorPosition(x.CGFloat, y.CGFloat)

But still, pity structure support for API on macOS is lacking.
CGWarpMouseCursorPosition(*xy.CGPoint) is also a no-go (wrong result?). Structure return value too.


Top
 Profile  
Reply with quote  
 Post subject: Re: Move mouse cursor
PostPosted: Tue Dec 03, 2019 4:37 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 338
Location: NL
btw why is CGWarpMouseCursorPosition(*xy.CGPoint) not working as expected? Don't understand.


Top
 Profile  
Reply with quote  
 Post subject: Re: Move mouse cursor
PostPosted: Tue Dec 03, 2019 4:44 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3710
Location: Netherlands
Rinzwind wrote:
btw why is CGWarpMouseCursorPosition(*xy.CGPoint) not working as expected? Don't understand.

Because PureBasic passes structures by reference and a lot of macOS functions (including this one) need the structure to be passed by value.

_________________
macOS 10.15 Catalina, Windows 10


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 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