Jump to content

Trying to remove flicker of updating text


 Share

Recommended Posts

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 :whistle:

Thanks,

D2a007

Link to comment
Share on other sites

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 :whistle:

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
EndFunc

the 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

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...