Aqua-Soft Forums: getting mouse position relative to entire desktop - Aqua-Soft Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

getting mouse position relative to entire desktop Rate Topic: -----

#1 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 22 February 2007 - 07:40 PM

I've been trying to get the mouse position relative to the entire desktop, but neither of my clumsy attempts work - what am I doing wrong?

	var MouseXPos = desklet.ConvertToValue("%MOUSEX%");
	var MouseYPos = desklet.ConvertToValue("%MOUSEY%");
	alert(MouseXPos + "n" + MouseYPos)
apparently, this just returns the position relative to the desklet

	var MouseXPos = desklet.UI.Desktop.x
	var MouseYPos = desklet.UI.Desktop.y

	var MouseXPos = desklet.UI.Desktop.screenX
	var MouseYPos = desklet.UI.Desktop.screenY
both of the above return undefined
0

#2 User is offline   pcm Icon

  • Group: Member
  • Posts: 617
  • Joined: 02-May 05

Posted 23 February 2007 - 02:28 PM

I'm not sure where you got the idea for Desktop.X/y or ScreenX I didn't see it in my sdk so it makes sense it returns undefined.

I don't have a function that returns the X,Y of the mouse relative to the desktop. Sorry didn't think of that one.

BUT you can still get it if you get the MOUSE relative to the desklet then add the position of the desklet to those values

MouseX = desklet.GetMouseXPos + desklet.DeskletXPos;
MouseY = desklet.GetMouseYPos + desklet.DeskletYPos;

I think this would give you what you want
0

#3 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 23 February 2007 - 02:43 PM

Haha, thank you pcm. I could have thought of that :)
I'm quite a noob when it comes to Javscript, so I googled for anything related to javascript and mouse positions - that's what I came up with. It seems this only works inside a browser.

As a sidenote: Is there a documentation on functions or methods that AveScripter does support, but that are not special AveScripter funtions or methods?
Or to rephrase the question, what javascript methods does AveScripter support, that are not listed in your SDK?
0

#4 User is offline   pcm Icon

  • Group: Member
  • Posts: 617
  • Joined: 02-May 05

Posted 23 February 2007 - 04:43 PM

Avescripter uses the Microsoft scripting engine, so it support everything that is in that engine.

You can go here for more info:

http://msdn2.microso...y/ms950396.aspx
0

#5 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 23 February 2007 - 05:42 PM

i tried to implement it like this:

function onClick()

{

	var MouseXPos = desklet.GetMouseXPos + desklet.DeskletXPos;

	var MouseYPos = desklet.GetMouseYPos + desklet.DeskletYPos;

	this.layers('pos').text = MouseXPos + "n" + MouseYPos;

}


but AveScripter yields:
438  Runtime Error in Microsoft JScript

This Object does not support this property or method.  Line:4   Column:1


thanks for the link and clarification :)
0

#6 User is offline   pcm Icon

  • Group: Member
  • Posts: 617
  • Joined: 02-May 05

Posted 24 February 2007 - 06:40 PM

Sorry, I gave you code in VB. Its should be

var MouseXPos = desklet.GetMouseXPos() + desklet.DeskletXPos;
var MouseYPos = desklet.GetMouseYPos() + desklet.DeskletYPos;
this.layers('pos').text = MouseXPos + "n" + MouseYPos;

GetMouse is a Method where as DeskletXPos isn't

If your wondering why I did that, so am I. :S
0

#7 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 01 March 2007 - 08:28 PM

thankyou, sir - seems to work well.

//Edit: No, it doesn't... its buggy somehow, gah. Would it be too difficult to add something like:
value = desklet.UI.desktop.mousex
value = desklet.UI.desktop.mousey

i'm planning on creating a radial menu via avescripter, since I don't know jack about LayeredWindows and such. maybe it will work out :)
0

#8 User is offline   pcm Icon

  • Group: Member
  • Posts: 617
  • Joined: 02-May 05

Posted 02 March 2007 - 02:26 PM

It wouldn't be to difficult, but I have no time till end of April. Overtime at work is taking most of my time right now.

What seems buggy about it?

What are you trying to do? Move a desklets to your mouse position?
0

#9 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 02 March 2007 - 06:42 PM

thanks for considering to add mouseposition functionality :)

It seems to only correctly update the mouseposition when a layer is at least clicked
getting the position via a hotkey gives false results, which are checked using a desktop measure tool.

and yes, i tried to hit a hotkey, say ctrl+space, to let a desklet show up at mouseposition:

var Visible = 1;

function ToggleShowDesklet()
{
  if (Visible == 1)
  {
	DeskletFadeout(false,500)
	Visible = 0;
  }
  else if (Visible == 0)
  {
	var MouseXPos = desklet.GetMouseXPos() + desklet.DeskletXPos;
	var MouseYPos = desklet.GetMouseYPos() + desklet.DeskletYPos;
	alert(MouseXPos + "," + MouseYPos)
	// desklet.SetXYPos(MouseXPos,MouseYPos)
	Visible = 1;
	DeskletFadeIn(false,500)
  }
}

0

#10 User is offline   pcm Icon

  • Group: Member
  • Posts: 617
  • Joined: 02-May 05

Posted 03 March 2007 - 04:50 PM

Ya.. the GetMouseXPos is triggerd/updated when you move over a layer etc.

I did a quick add in the code, you can download a "beta" version here: http://www.avedesk.o...wnload.php?id=2

Before releasing your desklet let me know I'll update the site with a new version, but this will let you continue with your desklet.

I haven't had a chance to test the code, but I'm assuming it works. Let me know

Desklet.Desktop.MouseX and MouseY

Sorry for quick post, just really busy with work :(
0

#11 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 04 March 2007 - 07:47 PM

I'm in front of my gf's pc right now, but I'll check it as soon as I get home - thaaaaank you ^^
0

#12 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 08 March 2007 - 06:07 PM

Doesn't seem to work :(

function onClick()

{

	var MouseXPos = Desklet.Desktop.MouseX;

	var MouseYPos = Desklet.Desktop.MouseY;

	alert(MouseXPos + "," + MouseYPos)

}


5009  Runtime Error in Microsoft JScript

'Desklet' is undefined  Line:5   Column:1

0

#13 User is offline   pcm Icon

  • Group: Member
  • Posts: 617
  • Joined: 02-May 05

Posted 09 March 2007 - 02:14 PM

Desklet is undefined?? You mean desklet.desktop.

I should be desklet.ui.desktop.mousex

forgot the UI
0

#14 User is offline   philou Icon

  • Group: Member
  • Posts: 265
  • Joined: 16-November 05

Posted 09 March 2007 - 07:46 PM

Oooh, I feel stupid now. Apologies!
...and thankies, too :)
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic