How can I get the hand cursor to stop flickering? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

How can I get the hand cursor to stop flickering?

Post by PipeDreams » 02 Jul 2023, 00:13

When I move the mouse over any text it flickers.. How can I keep it sold when I move it over the text, and change it back to the arrow when not over the text?
HandFlicker.gif
HandFlicker.gif (120.95 KiB) Viewed 860 times
Here's my script:

Code: Select all

;<=======================================================================================================>
;<===========================================  Game Launcher  ===========================================>
;<=======================================================================================================>
#SingleInstance Force
#Persistent
#NoEnv
PID:=DllCall("GetCurrentProcessId") ;PID Of Script
Process, Priority, %PID%, Normal
SetControlDelay, -1
SetBatchLines, -1
SetWinDelay, -1
SetWorkingDir %A_ScriptDir%
;Menu, Tray, Icon, GameFloder.ico
SetWorkingDir, E:\Install Me\Auto Hot Key\My Auto Hotkey Scripts\Game Scripts
CoordMode, Mouse, Screen
C1:=Format("Aqua" Color)
C2:=Format("0xFFA500" Color) ;Orange
GUI, FONT, s15 c%C1% Bold
GUI, +LastFound -Caption +AlwaysOnTop +ToolWindow
GUI, Color, Blue
GUI, Show, H420 W220, SelectionMenu
WinSet, Transparent, 220, SelectionMenu
WinGetPos,,, WindowWidth, WindowHeight
MouseGetPos, x, y
x:=(x-WindowWidth//2),y:=(y-WindowHeight//4+90)
WinMove, x, y
Gui, Add, Text, y+1 w200 vText1 gSelectionMenu, Borderlands 2
Gui, Add, Text, y+1 w200 vText2 gSelectionMenu, Broforce
Gui, Add, Text, y+1 w200 vText3 gSelectionMenu, Code Vein
Gui, Add, Text, y+1 w200 vText4 gSelectionMenu, DBZ Kakarot
Gui, Add, Text, y+1 w200 vText5 gSelectionMenu, Destiny Warriors
Gui, Add, Text, y+1 w200 vText6 gSelectionMenu, Evoland
Gui, Add, Text, y+1 w200 vText7 gSelectionMenu, Middle Earth
Gui, Add, Text, y+1 w200 vText8 gSelectionMenu, Never Alone
Gui, Add, Text, y+1 w200 vText9 gSelectionMenu, Nine Parchments
Gui, Add, Text, y+1 w200 vText10 gSelectionMenu, Rocket League
Gui, Add, Text, y+1 w200 vText11 gSelectionMenu, SMITE
Gui, Add, Text, y+1 w200 vText12 gSelectionMenu, Sonic Racing
Gui, Add, Text, y+1 w200 vText13 gSelectionMenu, The Witcher 2
Gui, Add, Text, y+1 w200 vText14 gSelectionMenu, Who's That Flying?!
Gui, Add, Text, y+1 w200 vText15 gSelectionMenu, Worms W M D
Gui, Add, Text, y+1 w200 vText16 gSelectionMenu, ZSNES
WinWaitActive, SelectionMenu
SetTimer, Blinker, 100
~Esc::ExitApp
Return
;<=========================================== Selection  Menu ===========================================>
SelectionMenu:
{	MouseGetPos,,,, Ctrl
	If (MouseOver (Ctrl="Static1"))
	{	Run, "steam://rungameid/49520"	;Borderlands 2
	} If (MouseOver (Ctrl="Static2"))
	{	Run, "steam://rungameid/274190"	;Broforce
	} If (MouseOver (Ctrl="Static3"))
	{	Run, "steam://rungameid/678960"	;Code Vein
	} If (MouseOver (Ctrl="Static4"))
	{Run, "DBZ Kakarot\DBZ Kakarot.ahk"	;DBZ Kakarot
	} If (MouseOver (Ctrl="Static5"))
	{	Run, "steam://rungameid/399790"	;Destiny Warriors
	} If (MouseOver (Ctrl="Static6"))
	{	Run, "steam://rungameid/233470"	;Evoland
	} If (MouseOver (Ctrl="Static7"))
	{	Run, "steam://rungameid/241930"	;Middle Earth
	} If (MouseOver (Ctrl="Static8"))
	{	Run, "steam://rungameid/295790"	;Never Alone
	} If (MouseOver (Ctrl="Static9"))
	{	Run, "steam://rungameid/471550"	;Nine Parchments
	} If (MouseOver (Ctrl="Static10"))
	{	Run, "steam://rungameid/252950"	;Rocket League
	} If (MouseOver (Ctrl="Static11"))
	{	Run, "SMITE\SMITE.ahk"			;SMITE
	} If (MouseOver (Ctrl="Static12"))
	{	Run, "steam://rungameid/212480"	;Sonic Racing
	} If (MouseOver (Ctrl="Static13"))
	{	Run, "steam://rungameid/20920"	;The Witcher 2
	} If (MouseOver (Ctrl="Static14"))
	{	Run, "steam://rungameid/57700"	;Who's That Flying?!
	} If (MouseOver (Ctrl="Static15"))
	{	Run, "steam://rungameid/327030"	;Worms W M D
	} If (MouseOver (Ctrl="Static16"))
	{	Run, "ZSNES\ZSNES.ahk"			;ZSNES EMU
}	} ExitApp
;<=============================================  Animations  ============================================>
Blinker:
{	If !(WinActive("SelectionMenu"))
	{	ExitApp
	} 
	
	If (a||b||c||d||e||f||g||h||i||j||k||l||m||n||o||p||q||r||s||t||u||v||w||z)		;Don't use C1, C2, X, Y
	{	DllCall("SetCursor","UInt",DllCall("LoadCursor", Uint, 0, Int, 32649))		;Chang Mouse Pointer.
	} 
	
	MouseGetPos,,,, Ctrl
	If (MouseOver (Ctrl="Static1") AND !(a))	;Borderlands 2
	{	a:=!a
		Gui, Font, s15
		GuiControl, Font, Static1
		GuiControl, +c%C2% +Redraw, Text1
	} Else, If (MouseOver (Ctrl="Static1") AND (a))
	{	GuiControl, +c%C1% +Redraw, Text1
		a:=!a
		If (a1)
			a1:=!a1
	} Else, If !(a1)	;Anti Text Flicker
	{	a1:=!a1
		Gui, Font, s12
		GuiControl, Font, Static1
	} If (MouseOver (Ctrl="Static2") AND !(b))	;Broforce
	{	b:=!b
		Gui, Font, s15
		GuiControl, Font, Static2
		GuiControl, +c%C2% +Redraw, Text2
	} Else, If (b)
	{	GuiControl, +c%C1% +Redraw, Text2
		b:=!b
		If (b1)
			b1:=!b1
	} Else, If !(b1)
	{	b1:=!b1
		Gui, Font, s12
		GuiControl, Font, Static2
	} If (MouseOver (Ctrl="Static3") AND (!c))	;Code Vein
	{	c:=!c
		Gui, Font, s15
		GuiControl, Font, Static3
		GuiControl, +c%C2% +Redraw, Text3
	} Else, If (c)
	{	GuiControl, +c%C1% +Redraw, Text3
		c:=!c
		If (3c)
			3c:=!3c
	} Else, If !(3c)
	{	3c:=!3c
		Gui, Font, s12
		GuiControl, Font, Static3
	} If (MouseOver (Ctrl="Static4") AND (!d))	;DBZ Kakarot
	{	d:=!d
		Gui, Font, s15
		GuiControl, Font, Static4
		GuiControl, +c%C2% +Redraw, Text4
	} Else, If (d)
	{	GuiControl, +c%C1% +Redraw, Text4
		d:=!d
		If (d1)
			d1:=!d1
	} Else, If !(d1)
	{	d1:=!d1
		Gui, Font, s12
		GuiControl, Font, Static4
	} If (MouseOver (Ctrl="Static5") AND (!e))	;Destiny Warriors
	{	e:=!e
		Gui, Font, s15
		GuiControl, Font, Static5
		GuiControl, +c%C2% +Redraw, Text5
	} Else, If (e)
	{	GuiControl, +c%C1% +Redraw, Text5
		e:=!e
		If (e1)
		 e1:=!e1
	} Else, If !(e1)
	{	e1:=!e1
		Gui, Font, s12
		GuiControl, Font, Static5
	} If (MouseOver (Ctrl="Static6") AND (!f))	;Evoland
	{	f:=!f
		Gui, Font, s15
		GuiControl, Font, Static6
		GuiControl, +c%C2% +Redraw, Text6
	} Else, If (f)
	{	GuiControl, +c%C1% +Redraw, Text6
		f:=!f
		If (f1)
		 f1:=!f1
	} Else, If !(f1)
	{	f1:=!f1
		Gui, Font, s12
		GuiControl, Font, Static6
	} If (MouseOver (Ctrl="Static7") AND (!g))	;Middle Earth
	{	g:=!g
		Gui, Font, s15
		GuiControl, Font, Static7
		GuiControl, +c%C2% +Redraw, Text7
	} Else, If (g)
	{	GuiControl, +c%C1% +Redraw, Text7
		g:=!g
		If (g1)
		 g1:=!g1
	} Else, If !(g1)
	{	g1:=!g1
		Gui, Font, s12
		GuiControl, Font, Static7
	} If (MouseOver (Ctrl="Static8") AND (!h))	;Never Alone
	{	h:=!h
		Gui, Font, s15
		GuiControl, Font, Static8
		GuiControl, +c%C2% +Redraw, Text8
	} Else, If (h)
	{	GuiControl, +c%C1% +Redraw, Text8
		h:=!h
		If (h1)
		 h1:=!h1
	} Else, If !(h1)
	{	h1:=!h1
		Gui, Font, s12
		GuiControl, Font, Static8
	} If (MouseOver (Ctrl="Static9") AND (!i))	;Nine Parchments
	{	i:=!i
		Gui, Font, s15
		GuiControl, Font, Static9
		GuiControl, +c%C2% +Redraw, Text9
	} Else, If (i)
	{	GuiControl, +c%C1% +Redraw, Text9
		i:=!i
		If (i1)
		 i1:=!i1
	} Else, If !(i1)
	{	i1:=!i1
		Gui, Font, s12
		GuiControl, Font, Static9
	} If (MouseOver (Ctrl="Static10") AND (!j))	;Rocket League
	{	j:=!j
		Gui, Font, s15
		GuiControl, Font, Static10
		GuiControl, +c%C2% +Redraw, Text10
	} Else, If (j)
	{	GuiControl, +c%C1% +Redraw, Text10
		j:=!j
		If (j1)
		 j1:=!j1
	} Else, If !(j1)
	{	j1:=!j1
		Gui, Font, s12
		GuiControl, Font, Static10
	} If (MouseOver (Ctrl="Static11") AND (!k))	;SMITE
	{	k:=!k
		Gui, Font, s15
		GuiControl, Font, Static11
		GuiControl, +c%C2% +Redraw, Text11
	} Else, If (k)
	{	GuiControl, +c%C1% +Redraw, Text11
		k:=!k
		If (k1)
		 k1:=!k1
	} Else, If !(k1)
	{	k1:=!k1
		Gui, Font, s12
		GuiControl, Font, Static11
	} If (MouseOver (Ctrl="Static12") AND (!l))	;Sonic Racing
	{	Gui, Font, s15
		GuiControl, Font, Static12
		l:=!l
		GuiControl, +c%C2% +Redraw, Text12
	} Else, If (l)
	{	GuiControl, +c%C1% +Redraw, Text12
		l:=!l
		If (l1)
		 l1:=!l1
	} Else, If !(l1)
	{	l1:=!l1
		Gui, Font, s12
		GuiControl, Font, Static12
	} If (MouseOver (Ctrl="Static13") AND (!m))	;The Witcher 2
	{	m:=!m
		Gui, Font, s15
		GuiControl, Font, Static13
		GuiControl, +c%C2% +Redraw, Text13
	} Else, If (m)
	{	GuiControl, +c%C1% +Redraw, Text13
		m:=!m
		If (m1)
		 m1:=!m1
	} Else, If !(m1)
	{	m1:=!m1
		Gui, Font, s12
		GuiControl, Font, Static13
	} If (MouseOver (Ctrl="Static14") AND (!n))	;Who's That Flying?!
	{	n:=!n
		Gui, Font, s15
		GuiControl, Font, Static14
		GuiControl, +c%C2% +Redraw, Text14
	} Else, If (n)
	{	GuiControl, +c%C1% +Redraw, Text14
		n:=!n
		If (n1)
		 n1:=!n1
	} Else, If !(n1)
	{	n1:=!n1
		Gui, Font, s12
		GuiControl, Font, Static14
	} If (MouseOver (Ctrl="Static15") AND (!o))	;Worms W M D
	{	o:=!o
		Gui, Font, s15
		GuiControl, Font, Static15
		GuiControl, +c%C2% +Redraw, Text15
	} Else, If (o)
	{	GuiControl, +c%C1% +Redraw, Text15
		o:=!o
		If (o1)
		 o1:=!o1
	} Else, If !(o1)
	{	o1:=!o1
		Gui, Font, s12
		GuiControl, Font, Static15
	} If (MouseOver (Ctrl="Static16") AND (!p))	;ZSNES EMU
	{	p:=!p
		Gui, Font, s15
		GuiControl, Font, Static16
		GuiControl, +c%C2% +Redraw, Text16
	} Else, If (p)
	{	GuiControl, +c%C1% +Redraw, Text16
		p:=!p
		If (p1)
		 p1:=!p1
	}  Else, If !(p1)
	{	p1:=!p1
		Gui, Font, s12
		GuiControl, Font, Static16
}	} Return
;<=======================================================================================================>
;<===============================================  E N D  ===============================================>
;<=======================================================================================================>

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How can I get the hand cursor to stop flickering?

Post by mikeyww » 02 Jul 2023, 06:35

Hello,

1. Is this from ChatGPT?
2. Does the script intend to call a user-defined function?
3. What should happen if you run the following script by itself?

Code: Select all

#Requires AutoHotkey v1.1.33
If (MouseOver (Ctl=Ctl) AND !(a))
 MsgBox 123

User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

Re: How can I get the hand cursor to stop flickering?

Post by PipeDreams » 02 Jul 2023, 14:29

mikeyww wrote:
02 Jul 2023, 06:35
Hello,

1. Is this from ChatGPT?
2. Does the script intend to call a user-defined function?
3. What should happen if you run the following script by itself?

Code: Select all

#Requires AutoHotkey v1.1.33
If (MouseOver (Ctl=Ctl) AND !(a))
 MsgBox 123
1. No, it’s not from chat GDP. Is my coding that bad? :lol: I am curious; what makes you think that?
2. No, it works how I want it to, aside from the hand pointer flickering when I move the mouse over text. However, it stays solid when it is held still. The script just launches a game when I click a line of text, and I wanted it to have some animations when the mouse goes over the text. Do you think it may run better if I used any user-defined functions? If so, could you list some examples?
3. When I run your code by itself, a message box comes up that says 123. But that’s not surprising, seeing as how conditions 1 and 2 are met without checking anything, e.g., Ctl=Ctl and not(a).

Anyways, I found this post on replacing and restoring system cursors and was able to get the script working the way I wanted with a little more editing.

Code: Select all

CursorChange:
{	If (Cursor)
	{	If !(Lock)
		{	Lock:=!Lock
			DllCall("SystemParametersInfo",UInt,0x57,UInt,0,UInt,0,UInt,0)
			DllCall("SetSystemCursor",Uint,DllCall("LoadCursor",Uint,0,Int,32649),Int,32512)	;Chang Mouse Pointer to Hand.
	}	} Else,
	{	DllCall("SystemParametersInfo",UInt,0x57,UInt,0,UInt,0,UInt,0)	;Chang Mouse Pointer Back to Arrow.
}	} Return
CursorLock:
{	If !(Cursor)
	 Cursor:=!Cursor
} Return
CursorUnlock:
{	If (Cursor)
	{	Cursor:=!Cursor
		If (Lock)
		{	Lock:=!Lock
}	}	} Return
Blinker:
{	If !(WinActive("SelectionMenu"))
	{	ExitApp
	} GoSub, CursorChange
	MouseGetPos,,,, MouseOver
	If ((MouseOver="Static1") AND !(a))	;Borderlands 2
	{	a:=!a
		GoSub, CursorLock	;Anti Cursor Flicker
		Gui, Font, s15
		GuiControl, Font, Static1
		GuiControl, +c%C2% +Redraw, Text1
	} Else, If (a)
	{	GuiControl, +c%C1% +Redraw, Text1
		a:=!a
		If (a1)
			a1:=!a1
	} Else, If !(a1)		;Anti Text Flicker
	{	a1:=!a1
		Gui, Font, s12
		GuiControl, Font, Static1
		GoSub, CursorUnlock	;Anti Cursor Flicker
	}
Fixed.gif
Fixed.gif (140.09 KiB) Viewed 789 times
Last edited by PipeDreams on 02 Jul 2023, 16:28, edited 1 time in total.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How can I get the hand cursor to stop flickering?

Post by mikeyww » 02 Jul 2023, 15:07

I see. It sounds like you have your script working, so that is good.

I hope you will not mind if I ask a few questions. How did you come up with MouseOver? Was it in the documentation, or another script that you saw? What is your understanding of what it does? What makes it work in the short test script that I posted?

The script below doesn't show the MsgBox. Should it?

Code: Select all

#Requires AutoHotkey v1.1.33
If !a AND (Ctl=Ctl) * (MouseOver * (Ctl=Ctl))
 MsgBox 123

User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

Re: How can I get the hand cursor to stop flickering?

Post by PipeDreams » 02 Jul 2023, 16:20

Oh, I see what you mean by user-defined function. No, MouseOver is not in the AHK doc. It was something left over from another script I saw long ago, and this script never complained about it not being defined, so I just assumed it was necessary for the pointer thing to work and never tried removing it. However, when I remove it from my script, it functions the same way. So, I guess I didn’t need it after all.
However, I’ve noticed that the Ctrl in MouseGetPos,,,, Ctrl can be defined by the user, so I guess I will just repurpose MouseOver; as it makes more sense to me, e.g., MouseGetPos,,,, MouseOver and If ((MouseOver=“Static1”) AND !(a))

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How can I get the hand cursor to stop flickering?  Topic is solved

Post by mikeyww » 02 Jul 2023, 16:24

OK.

For future: a function name is always immediately followed by (, not a space.


just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How can I get the hand cursor to stop flickering?

Post by just me » 03 Jul 2023, 04:42

A bit shorter (and maybe clearer):

Code: Select all

;<=======================================================================================================>
;<===========================================  Game Launcher  ===========================================>
;<=======================================================================================================>
#Requires AutoHotkey v1.1.33
#NoEnv
#Persistent
#SingleInstance Force
; Script settings ----------------------------------------------------------------------------------
PID:=DllCall("GetCurrentProcessId") ;PID Of Script
Process, Priority, %PID%, Normal
SetControlDelay, -1
SetBatchLines, -1
SetWinDelay, -1
;Menu, Tray, Icon, GameFloder.ico
SetWorkingDir, E:\Install Me\Auto Hot Key\My Auto Hotkey Scripts\Game Scripts
CoordMode, Mouse, Screen
; Variables ----------------------------------------------------------------------------------------
MouseOver := ""
C1 := "Aqua"   ; normal color
C2 := "FFA500" ; selection color -> Orange
; Gui ----------------------------------------------------------------------------------------------
Gui, +LastFound -Caption +AlwaysOnTop +ToolWindow +HwndHGUI
Gui, Margin, 10, 10
Gui, Color, Blue
Gui, Font, s15 c%C1% Bold
Gui, Add, Text, ym  w200 vText1  gSelectionMenu hwndHCTL, Borderlands 2
Gui, Add, Text, y+1 w200 vText2  gSelectionMenu, Broforce
Gui, Add, Text, y+1 w200 vText3  gSelectionMenu, Code Vein
Gui, Add, Text, y+1 w200 vText4  gSelectionMenu, DBZ Kakarot
Gui, Add, Text, y+1 w200 vText5  gSelectionMenu, Destiny Warriors
Gui, Add, Text, y+1 w200 vText6  gSelectionMenu, Evoland
Gui, Add, Text, y+1 w200 vText7  gSelectionMenu, Middle Earth
Gui, Add, Text, y+1 w200 vText8  gSelectionMenu, Never Alone
Gui, Add, Text, y+1 w200 vText9  gSelectionMenu, Nine Parchments
Gui, Add, Text, y+1 w200 vText10 gSelectionMenu, Rocket League
Gui, Add, Text, y+1 w200 vText11 gSelectionMenu, SMITE
Gui, Add, Text, y+1 w200 vText12 gSelectionMenu, Sonic Racing
Gui, Add, Text, y+1 w200 vText13 gSelectionMenu, The Witcher 2
Gui, Add, Text, y+1 w200 vText14 gSelectionMenu, Who's That Flying?!
Gui, Add, Text, y+1 w200 vText15 gSelectionMenu, Worms W M D
Gui, Add, Text, y+1 w200 vText16 gSelectionMenu, ZSNES
; Reset the font
Gui, Font, s12 c%C1% Norm
Loop, 16
   GuiControl, Font, Text%A_Index%
; Change the default cursor for all Static controls to Hand
CHAND := DllCall("LoadCursor", "Ptr", 0, "Int", 32649, "UPtr")
If (A_PtrSize = 8)
   DllCall("SetClassLongPtrA", "Ptr", HCTL, "Int", -12, "Ptr", CHAND)
Else
   DllCall("SetClassLongA", "Ptr", HCTL, "Int", -12, "Ptr", CHAND)
; Calculate the window's position
Gui, Show, Hide
WinGetPos, , , W, H
MouseGetPos, X, Y
X -= W // 2
X := Max(X, 0)
Y -= H // 2
Y := Max(Y, 0)
WinSet, Transparent, 220
Gui, Show, x%X% y%Y%, SelectionMenu
WinWaitActive, SelectionMenu
SetTimer, Blinker, 100
Return
GuiEscape:
~Esc::
ExitApp
;<=========================================== Selection  Menu ===========================================>
SelectionMenu:
   Switch A_GuiControl {
      Case "Text1":  Run, "steam://rungameid/49520"      ;Borderlands 2
      Case "Teyt2":  Run, "steam://rungameid/274190"     ;Broforce
      Case "Text3":  Run, "steam://rungameid/678960"     ;Code Vein
      Case "Text4":  Run, "DBZ Kakarot\DBZ Kakarot.ahk"  ;DBZ Kakarot
      Case "Text5":  Run, "steam://rungameid/399790"     ;Destiny Warriors
      Case "Text6":  Run, "steam://rungameid/233470"     ;Evoland
      Case "Text7":  Run, "steam://rungameid/241930"     ;Middle Earth
      Case "Text8":  Run, "steam://rungameid/295790"     ;Never Alone
      Case "Text9":  Run, "steam://rungameid/471550"     ;Nine Parchments
      Case "Text10": Run, "steam://rungameid/252950"     ;Rocket League
      Case "Text11": Run, "SMITE\SMITE.ahk"              ;SMITE
      Case "Text12": Run, "steam://rungameid/212480"     ;Sonic Racing
      Case "Text13": Run, "steam://rungameid/20920"      ;The Witcher 2
      Case "Text14": Run, "steam://rungameid/57700"      ;Who's That Flying?!
      Case "Text15": Run, "steam://rungameid/327030"     ;Worms W M D
      Case "Text16": Run, "ZSNES\ZSNES.ahk"              ;ZSNES EMU
   }
ExitApp
;<=============================================  Animations  ============================================>
Blinker:
   If !(WinActive("SelectionMenu"))
      ExitApp
   MouseGetPos, , , , Ctrl
   If (Ctrl = MouseOver)
      Return
   If (SubStr(MouseOver, 1, 6) = "Static") {
      Gui, Font, s12 c%C1%
      GuiControl, Font, %MouseOver%
   }
   MouseOver := Ctrl
   Gui, Font, s15 c%C2%
   GuiControl, Font, %MouseOver%
Return
;<=======================================================================================================>
;<===============================================  E N D  ===============================================>
;<=======================================================================================================>

User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

Re: How can I get the hand cursor to stop flickering?

Post by PipeDreams » 04 Jul 2023, 02:46

Wow! Nice cleanup just me. :bravo:
I have some questions, however.
1. How did you get the Blinker timer only to run when the mouse moves?
I Also wanted the text to blink from Aqua to Orange when the mouse is over it, but I could not get it to work in the Blinker timer you set up because it only runs when the mouse moves.

Code: Select all

MouseOver := Ctrl
If (SubStr(MouseOver, 1, 6) = "Static") 
{	If (Blink:=!Blink)
	{	Gui, Font, s15 c%C1%
	} Else,
	{	Gui, Font, s15 c%C2%
}	} GuiControl, Font, %MouseOver%
So I had to make a second-timer to get it to work.

Code: Select all

Blinker2:
{	MouseOver := Ctrl
	If (SubStr(MouseOver, 1, 6) = "Static") 
	{	If (Blink:=!Blink)
		{	Gui, Font, s15 c%C1%
		} Else,
		{	Gui, Font, s15 c%C2%
	}	} GuiControl, Font, %MouseOver%
} Return
2. Not that what I did is bad, but I am curious how you would have set it up to make the text blink when the mouse is over it.

just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How can I get the hand cursor to stop flickering?

Post by just me » 04 Jul 2023, 04:32

Hi @PipeDreams,

I wrongly assumed that you don't want blinking text.
1. How did you get the Blinker timer only to run when the mouse moves?
I didn't. The timer is always running but as long the control under the mouse does not change, it does nothing:

Code: Select all

   If (Ctrl = MouseOver)
      Return
To get blinking text you can change the timer code as follows:

Code: Select all

Blinker:
   If !(WinActive("SelectionMenu"))
      ExitApp
   MouseGetPos, , , , Ctrl
   If (Ctrl = MouseOver) { ; changed
      If (SubStr(MouseOver, 1, 6) = "Static") { ; added
         CC := CC = C1 ? C2 : C1 ; added - toggle current color
         GuiControl, +c%CC% +Redraw, %MouseOver% ; added - change the control's color
      } ; added
      Return
   } ; added
   If (SubStr(MouseOver, 1, 6) = "Static") {
      Gui, Font, s12 c%C1%
      GuiControl, Font, %MouseOver%
   }
   MouseOver := Ctrl
   CC := C2 ; added - CC = current color
   Gui, Font, s15 c%C2%
   GuiControl, Font, %MouseOver%
Return

User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

Re: How can I get the hand cursor to stop flickering?

Post by PipeDreams » 04 Jul 2023, 14:21

Hi @just me
Ok, I see; I was using SoundBeep, 100, 10 to find where the the loop runs unhindered and where it does not.
So If I put SoundBeep, 100, 10 above If (Ctrl = MouseOver) I hear it no matter where the pointer is.
But if I place SoundBeep, 100, 10 below the return point for If (Ctrl = MouseOver). As you said, I only hear it go off one time when the mouse is over some text. So that's why I thought the Blinker timer was only running when the mouse moved.

I also wanted to add some Italic to the blinking and restore Norm Bold text when it's not blinking.
I tried to add Italic to your GuiControl GuiControl, +c%CC% +Redraw, Font, %MouseOver% but I could not get it to work.
The only way I could make it work was by adding a second GuiControl above yours.
Is there a cleaner way to add Italic?

Nice use of the Ternary Operator btw, I didn't know it could be used like that.

Code: Select all

Blinker:
{	If !(WinActive("SelectionMenu"))
	{   ExitApp
	} MouseGetPos, , , , Ctrl
	If (MouseOver = Ctrl)
	{	If (SubStr(MouseOver, 1, 6) = "Static") 
		{	CC := CC = C1 ? C2 : C1
			Gui, Font, s15 Italic			;<<<Added for Italic
			GuiControl, Font, %MouseOver%	;<<<Added for Italic
			GuiControl, +c%CC% +Redraw, %MouseOver%
		} Return
	} If (SubStr(MouseOver, 1, 6) = "Static") 
	{	Gui, Font, s12 Norm Bold			;<<< Restores Text 
		GuiControl, Font, %MouseOver%
	} MouseOver := Ctrl
} Return

just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How can I get the hand cursor to stop flickering?

Post by just me » 05 Jul 2023, 04:35

Hi @PipeDreams,

you don't need to set italic again and again. It's sufficient to set it once at the bottom of Blinker: as in my original example.

Code: Select all

Blinker:
   If !(WinActive("SelectionMenu"))
      ExitApp
   MouseGetPos, , , , Ctrl
   If (MouseOver = Ctrl) {
      If (SubStr(MouseOver, 1, 6) = "Static") {
         CC := CC = C1 ? C2 : C1
         GuiControl, +c%CC% +Redraw, %MouseOver%
      }
      Return
   }
   If (SubStr(MouseOver, 1, 6) = "Static") {
      Gui, Font, s12 c%C1% Norm Bold			;<<< Restores Text
      GuiControl, Font, %MouseOver%
   }
   MouseOver := Ctrl
   CC := C2 ; added - CC = current color
   Gui, Font, s15 c%C2% Italic
   GuiControl, Font, %MouseOver%
Return
*not tested*


Post Reply

Return to “Ask for Help (v1)”