Mouse Outside Window
BlitzPlus Forums/BlitzPlus Programming/Mouse Outside Window
| ||
Is it possible to capture the x and y coordinates of the mouse as well as the state of the mouse buttons outside of the BlitzPlus window? |
| ||
already tried mousedown(button), mousex(canvas), and mousey(canvas) ? |
| ||
Graphics 640,480,16,2 Const UPS=60 period=1000/UPS time=MilliSecs()-period Type TPoint Field X% Field Y% End Type Global cPos.TPoint = New TPoint Repeat Repeat elapsed=MilliSecs()-time Until elapsed ticks=elapsed/period tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period If KeyHit(1) End Next api_GetCursorPos(cPos) Print cPos\X + ", " + cPos\Y Flip Cls Forever Win API saves the day again! :) |
| ||
Hi! I had simalar problem some time ago; I solved it by determining the gadgets screen x, y coords and then using: rectsoverlap(gadgetsx, gadgetsy, gadgetwidth, gadgetheight, mousex(), mousey(), 1, 1) any how here is a link to the gadet screen x, y code http://www.blitzbasic.com/Community/posts.php?topic=22355 check out the last posting! Mr Brine |
| ||
Thanks for the reply! How do I get the mouse clicks though? Won't that only get me the x,y? |
| ||
Graphics 640,480,16,2 Const UPS=60 period=1000/UPS time=MilliSecs()-period Type TPoint Field X% Field Y% End Type Const VK_LBUTTON = 1 Const VK_RBUTTON = 2 Const VK_MBUTTON = 4 Global cPos.TPoint = New TPoint Repeat Repeat elapsed=MilliSecs()-time Until elapsed ticks=elapsed/period tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period If KeyHit(1) End Next ;get mouse position api_GetCursorPos(cPos) Text 10,10,cPos\X + ", " + cPos\Y If (api_GetAsyncKeyState(VK_LBUTTON) <> 0) Text 10,25, "Left button down" EndIf If (api_GetAsyncKeyState(VK_RBUTTON) <> 0) Text 10,25, "Right button down" EndIf If (api_GetAsyncKeyState(VK_MBUTTON) <> 0) Text 10,25, "Middle button down" EndIf Flip Cls Forever |
| ||
Hi Jay I dunno whom the question was directed to, If it was me...I just checked out the code I implemented and basicly the way I did my thing at the time was: 1. is mouse over window (yes goto 2) 2. is window active (yes goto 3) 3. avoid using blitz plus events and simply use the mousedown(), mousehit(), or mouseup() functions to test wether the mouse has been pressed. I remember at the time this worked fine (due to technicalities that go beyond the scope of this thread, It wont compile now), if you have any probs, post another jobber. Ive also seem to remeber that the gadget screen x/y returns the top corner of the inside of the window and not the top corner of the title bar, but I could be wrong, you might wanna make sure. Good Luck Mr Brine |