Sign in to follow this  
Followers 0
SadBunny

How to tell if mouse is on a GuiCtrl of the Button type?

9 posts in this topic

Hi!

I have a load of buttons-next-to-labels in a simple GUI (designing a simple SameGnome-like game for AutoIt practising purposes), and I want to play a tiny bleeping sound whenever the mouse is hovered over a button. (But NOT when moved over the labels next to them.)

I can access the text on the current control the mouse is hovered over, but since this text is based on user input and not fixed, I cannot tell in that way whether the mouse is hovered over a button and not over a label. Finding out whether 'the mouse is hovering over another GuiCtrl than at last checkup' is no problem at all, but finding out whether or not that GuiCtrl is of the Button type, there's my challenge.

I WAS able to use a workaround where all buttons are in an array or something, and do a while loop every .25 seconds or so, to see if the mouse is over one of them, but this is very intensive to check and the app itself is already pretty intensive so it slows down a LOT if I do it like that.

To go short, I need a function that does the following:

Func _MouseHoversOverButton()
 if (active GuiCtrl on mouseX,mouseY = of the Button type) then
  return True
 else;<- mouse NOT hovering over any GuiCtrl, or over a TabItem/Label/Radio/Group/whatever other type
  return False
 endif
EndFunc

Can anyone point me in the right direction what I can do to discover the type of a certain GuiCtrl?


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi!

I have a load of buttons-next-to-labels in a simple GUI (designing a simple SameGnome-like game for AutoIt practising purposes), and I want to play a tiny bleeping sound whenever the mouse is hovered over a button. (But NOT when moved over the labels next to them.)

I can access the text on the current control the mouse is hovered over, but since this text is based on user input and not fixed, I cannot tell in that way whether the mouse is hovered over a button and not over a label. Finding out whether 'the mouse is hovering over another GuiCtrl than at last checkup' is no problem at all, but finding out whether or not that GuiCtrl is of the Button type, there's my challenge.

I WAS able to use a workaround where all buttons are in an array or something, and do a while loop every .25 seconds or so, to see if the mouse is over one of them, but this is very intensive to check and the app itself is already pretty intensive so it slows down a LOT if I do it like that.

To go short, I need a function that does the following:

Func _MouseHoversOverButton()
 if (active GuiCtrl on mouseX,mouseY = of the Button type) then
  return True
 else;<- mouse NOT hovering over any GuiCtrl, or over a TabItem/Label/Radio/Group/whatever other type
  return False
 endif
EndFunc

Can anyone point me in the right direction what I can do to discover the type of a certain GuiCtrl?

I believe Valuater made a _CtrlHover() function for his xSkin ... But Larry's Hook.dll would probably be best for this... and you may want to look at http://msdn2.microsoft.com/en-us/library/s...mousehover.aspx to see if any of that garble may be of use :whistle:

Edit:

Valuaters ControlHover

http://www.autoitscript.com/forum/index.ph...st&id=11121

http://www.autoitscript.com/forum/index.ph...st&p=336467

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I believe Valuater made a _CtrlHover() function for his xSkin ... But Larry's Hook.dll would probably be best for this... and you may want to look at http://msdn2.microsoft.com/en-us/library/s...mousehover.aspx to see if any of that garble may be of use :whistle:

Edit:

Valuaters ControlHover

http://www.autoitscript.com/forum/index.ph...st&id=11121

http://www.autoitscript.com/forum/index.ph...st&p=336467

Thanks for the links! Very useful for finding other stuff... Alas, there is no function to be found that tells what type of control a certain control is - you still need to have a list of controls in there and check for them, which was what I already managed to do myself. Guess I'll stick with that approach now, albeit slower than I would like (though I did get some optimizing ideas from Valuater's code).

Thanks anyway for your trouble. I'm not very trained in using that MSDN information to construct AutoIt structures, maybe if I get further ahead in that field I'll try again. If anyone would know a more direct 'AutoItty' way of discovering the type of $anyGuiCtrl, then I'd be very thankful.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Thanks for the links! Very useful for finding other stuff... Alas, there is no function to be found that tells what type of control a certain control is - you still need to have a list of controls in there and check for them, which was what I already managed to do myself. Guess I'll stick with that approach now, albeit slower than I would like (though I did get some optimizing ideas from Valuater's code).

Thanks anyway for your trouble. I'm not very trained in using that MSDN information to construct AutoIt structures, maybe if I get further ahead in that field I'll try again. If anyone would know a more direct 'AutoItty' way of discovering the type of $anyGuiCtrl, then I'd be very thankful.

You might do a search for "WindowFromPoint", I believe Larry did a work up on something similar that your talking about.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

You might do a search for "WindowFromPoint", I believe Larry did a work up on something similar that your talking about.

No Smoke, it turns out it was you :lmao:

Your function here did EXACTLY what I needed, even more (it gave me the instance number like the old AutoInfo tool, the ClassNN and I only wanted the Class name) but that was easily taken care of...

:whistle: Thanks ever so much.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

No Smoke, it turns out it was you :lmao:

Your function here did EXACTLY what I needed, even more (it gave me the instance number like the old AutoInfo tool, the ClassNN and I only wanted the Class name) but that was easily taken care of...

:whistle: Thanks ever so much.

Hmm... Might check out _CtrlGetByPos(), you could always use the mouse position with it (In mousecoordmode 2), and it returns ... ID/ClassNameNN/Control Handle (if you choose that option)

http://www.autoitscript.com/forum/index.ph...mp;highlite=%2B

It's in there somewhere...

I think the thread you are referring to is the one that got me to write that one anyway ;)...


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

No Smoke, it turns out it was you :lmao:

Your function here did EXACTLY what I needed, even more (it gave me the instance number like the old AutoInfo tool, the ClassNN and I only wanted the Class name) but that was easily taken care of...

:whistle: Thanks ever so much.

Smoke_N has written alot of great stuff...

... Obviously, he has written so many useful scriptlets, it's hard to remember them all

( I watch his stuff so I can place it in Autoit Wrappers )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Smoke_N has written alot of great stuff...

... Obviously, he has written so many useful scriptlets, it's hard to remember them all

( I watch his stuff so I can place it in Autoit Wrappers )

8)

:"> Please ... so speaketh one of the AutoIt heros themselves... He helps/provides training tools that took hours of his time/and took a challenge that no one wanted too with skinning autoit GUIs ... I'm grouchy, don't like people much, and take away my toys (don't share well with the other kids :whistle: ) ...

Valuater for President!! :lmao:


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Hey Smoke and Val,

You're both sharing the 1st place in both the modesty and the usefullness contest. (Eat that!)

Your info has been incredibly helpful; this has saved me hours if not days of puzzling AND it has given me lots of ideas about eventual future code improvements.

Keep up the good work! That's an order :whistle:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0