Jump to content

Detecting next mouse click


Recommended Posts

OK so I am trying to make an irregular shaped gui, in this case a circle that is divided into 9 pieces each "slice" is effectivly a button. Basically I am going to have this gui pop up whenever the user right clicks in a certain app and can select a function. However I have not found a way of making these slices actual buttons (that dont flicker) since they are not rectangular. I decided to cheat and since this is a right click menu is it possible to detect where the next mouse click is? That way I can define if the next click (following the right click that brought up the menu) is in a certain location it is on button x or is outside of the circle and should be sent to the app. I dont know of a way of monitoring mouse clicks.

Any suggestions either on how to monitor mouse clicks (specificallly the next click after a certain point) or does anyone have any code to map a very irregular shapped button?

Thanks ahead of time

Not that it matters too much with my question but heres a sample of the code I am using.

#include <GuiConstants.au3>
#include <windowsconstants.au3>
; GUI
$mousepos = mousegetpos()
$width = IniRead("config.ini", "GUI", "Width", "DEFAULT")
$height = IniRead("config.ini", "GUI", "Height", "DEFAULT")


$gui = GUICreate("Menu",$width,$height,$mousepos[0]-$width/2,$mousepos[1]-$height/2,$WS_POPUP,$WS_EX_LAYERED)
GUICtrlCreatePic("menu.bmp",0,0,$width,$height)
GuiSetIcon("Menu.ico", 0)

; BUTTON
;GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)


; GUI MESSAGE LOOP
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd
Link to comment
Share on other sites

You could make a gui in place of each button. It might take a bit of math to get the window to the right shape, but then you could find the window that the mouse is over to see which "button" is clicked. I don't have the script to manipulate the window shape off hand, but it uses "SetWindowRgn" as a dllcall to change the shape. Search for that and you will find some examples about how to change the window shape.

This is the only way I can think of that will have no flickering. It isn't the easiest way and probably not the best way, but it will get the job done.

Edited by dantay9
Link to comment
Share on other sites

Crikey, I never even new you could make a circular gui

Now this is just a blind idea which may well be stupid, but I'll try nonetheless

Could you make these segments into groups ?

That would only work, if infact a group would detect a mouse click just as a label will.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Actually, the making a label in place of a button would be a great idea. You can detect clicks on a label.

Edit: If all else fails, I guess you could just measure the position of the mouse in relation to the window to see which section of the window the mouse is in.

Edited by dantay9
Link to comment
Share on other sites

Great idea with the multiple guis. As far as the lables I didnt know you could make labels irregular shaped. If I set one of the lables color to transpararent wont it register the mouse click on the transparancy? I was under the impression the transparancy was just pixel level.

Thanks

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...