d2a007 Posted August 10, 2005 Share Posted August 10, 2005 Hi guys, I haven't done any type of programing in 6-8 years and pretty much forgot everything I knew. I'm trying to create a little program to do several little functions and one of them will need to know where the mouse is at certain times. So I pulled up the help file and went to town. Below is what I came up with. My problem is I'm still getting a flicker of the numbers when they are not changing. I know it's only cosmetic, but i'd stil like it to run smother. ;// Includes: #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $mainwindow = GUICreate("MX Coord 1.0", 200, 75, 1, 1) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinSetOnTop("MX Coord 1.0", "", 1) GUICtrlCreateLabel("Mouse X/Y", 72, 5) $pos = MouseGetPos() $mousex = GUICtrlCreateLabel( "X= " & $pos[0], 40, 25) $mousey = GUICtrlCreateLabel( "Y= " & $pos[1], 130, 25) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetState(@SW_SHOW) While 1 Sleep(350) $pos2 = MouseGetPos() if $pos <> $pos2 Then GUICtrlSetData ( $mousey, "Y= " & $pos[1] ) if $pos <> $pos2 Then GUICtrlSetData ( $mousex, "X= " & $pos[0] ) $pos = $pos2 WEnd Func OKButton() MsgBox(0, "MX Coord 1.0", "Thank You For Using MX Coord 1.0!") Exit EndFunc Func CLOSEClicked() MsgBox(0, "MX Coord 1.0", "Thank You For Using MX Coord 1.0!") Exit EndFunc I'm a programing noob again so please be kind Thanks, D2a007 Link to comment Share on other sites More sharing options...
seandisanti Posted August 10, 2005 Share Posted August 10, 2005 Hi guys, I haven't done any type of programing in 6-8 years and pretty much forgot everything I knew. I'm trying to create a little program to do several little functions and one of them will need to know where the mouse is at certain times. So I pulled up the help file and went to town. Below is what I came up with. My problem is I'm still getting a flicker of the numbers when they are not changing. I know it's only cosmetic, but i'd stil like it to run smother. ;// Includes: #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $mainwindow = GUICreate("MX Coord 1.0", 200, 75, 1, 1) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinSetOnTop("MX Coord 1.0", "", 1) GUICtrlCreateLabel("Mouse X/Y", 72, 5) $pos = MouseGetPos() $mousex = GUICtrlCreateLabel( "X= " & $pos[0], 40, 25) $mousey = GUICtrlCreateLabel( "Y= " & $pos[1], 130, 25) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetState(@SW_SHOW) While 1 Sleep(350) $pos2 = MouseGetPos() if $pos <> $pos2 Then GUICtrlSetData ( $mousey, "Y= " & $pos[1] ) if $pos <> $pos2 Then GUICtrlSetData ( $mousex, "X= " & $pos[0] ) $pos = $pos2 WEnd Func OKButton() MsgBox(0, "MX Coord 1.0", "Thank You For Using MX Coord 1.0!") Exit EndFunc Func CLOSEClicked() MsgBox(0, "MX Coord 1.0", "Thank You For Using MX Coord 1.0!") Exit EndFuncI'm a programing noob again so please be kind Thanks,D2a007<{POST_SNAPBACK}>It looks like you're doing alot more than you have to. your code makes use of MouseGetPos() which is all you really need. if you run it at the point where the current mouse position matters, then you will always have the right mouse position. as far as something to tell you where the mouse is CONSTANTLY labels may not be the way to go... personally when i want to track mouse position, i'll just do a simple loop (no gui even needed)HotKeySet("{PAUSE}","STOPIT") while 1 $pos = MouseGetPos() tooltip($pos[0] & ", " & $pos[1]) sleep(10) WEnd Func STOPIT() Exit EndFuncthe sleep is optional, the display is smoother without it, or with it set low like 10 (even though i'm sure someone will point out that anything under 15 still waits 15 ms) but it obviously uses more system resources, if you set it to 100+ it'll update a little slower making it look choppier even though it's using less time... and pressing the pause key will get rid of your tooltip Link to comment Share on other sites More sharing options...
d2a007 Posted August 10, 2005 Author Share Posted August 10, 2005 Well that works much better. And it only took me two hours to come up with what you did in 10 lines. Thanks a ton! d2a007 Link to comment Share on other sites More sharing options...
seandisanti Posted August 10, 2005 Share Posted August 10, 2005 Well that works much better. And it only took me two hours to come up with what you did in 10 lines. Thanks a ton!d2a007<{POST_SNAPBACK}>no prob man, glad i could help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now