Jump to content

Recommended Posts

Posted

Hi all,

I'm running into a strange issue and wanted to see if anyone else has experienced this or knows what's going on.

I'm working on a GUI with multiple buttons. One of the buttons has no color modifications and can be clicked extremely rapidly (10+ times per second) with no problem.
However, the moment I use GUICtrlSetBkColor() or GUICtrlSetColor() on a button, that button becomes significantly less responsive, I can only click it around 3–4 times per second.

I have searched the forums and i could only find information about delays these functions can have when modifying large amounts of controls Here but this isn't what I'm encountering.

If you review the below script, you will find you can double click the top button easily and click it fast. But the bottom 2 arn't as responsive and quite slow.
 

#include <GUIConstantsEx.au3>

Global $i = 0

GUICreate("Speed Test", 200, 120)

;Top Button - Fast
Local $hButton = GUICtrlCreateButton("I Click Fast :D", 10, 5, 180, 25)
;Middle Button - Slow
Local $button2 = GUICtrlCreateButton("I click slow :(", 10, 40, 180, 25)
GUICtrlSetBkColor($button2, 0xFF0000)
;Buttom Button - Slow
Local $button3 = GUICtrlCreateButton("I click slow :(", 10, 75, 180, 25)
GUICtrlSetColor($button3, 0xFF0000)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton, $button2, $button3
            _bang()
    EndSwitch
WEnd

Func _bang()
    ;to see how fast it's clicking
    ConsoleWrite("hit: " & $i & @CRLF)
    $i += 1
EndFunc

Any idea what's causing this and how i can resolve it?

Posted
31 minutes ago, Nine said:

As mentioned before :

 

This issue isn't related to what i'm experiencing. 

The slowness also affects labels which havn't been colored at all

Here is an example
 

#include <GUIConstantsEx.au3>

Global $i = 0

GUICreate("Speed Test", 200, 120)

;Top Button - Fast
Local $hButton = GUICtrlCreateButton("I Click Fast :D", 10, 5, 180, 25)
;Middle Button - Slow
Local $button2 = GUICtrlCreateLabel("I click slow :(", 10, 40, 180, 25)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton, $button2
            _bang()
    EndSwitch
WEnd

Func _bang()
    ;to see how fast it's clicking
    ConsoleWrite("hit: " & $i & @CRLF)
    $i += 1
EndFunc

Any Ideas? Or is this a bug?

Posted

Ok tested this way :

#include <GUIConstantsEx.au3>

Global $hTimer

GUICreate("Speed Test", 200, 120)

;Top Button - Fast
Local $hButton = GUICtrlCreateButton("I Click Fast :D", 10, 5, 180, 25)
;Middle Button - Slow
Local $button2 = GUICtrlCreateLabel("I click slow :(", 10, 40, 180, 25)

GUISetState()

While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      Exit
    Case $GUI_EVENT_PRIMARYDOWN
      $hTimer = TimerInit()
    Case $hButton
      _bang(1)
    Case $button2
      _bang(2)
  EndSwitch
WEnd

Func _bang($b)
  ;to see how fast it's clicking
  ConsoleWrite("hit " & $b & " : " & TimerDiff($hTimer) & @CRLF)
EndFunc   ;==>_bang

Results :

+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart. --> Press Ctrl+BREAK to Stop.
hit 1 : 63.6258
hit 2 : 1471.3611
hit 1 : 78.6798
hit 2 : 1491.3436
hit 1 : 94.7818
hit 1 : 109.9291
hit 2 : 1331.8119
hit 2 : 543.0545
hit 2 : 1983.9762
hit 2 : 728.634
hit 1 : 110.1899
hit 2 : 1536.383
+>07:53:42 AutoIt3 ended. rc:0

You seem to be right...

Posted

Hello @TitaniusPlatinum

I had the same concern a few weeks ago, in this post . Here is a part of the comment :

On 4/5/2025 at 10:36 PM, pixelsearch said:

I just discovered why today : clicking quickly twice on a label control doesn't trigger (twice) the corresponding Case in main loop, because it's recognized as a double click on the label control, which should be taken care of with WM_COMMAND as @Melba23 indicates here  . This "annoyance" doesn't occur with button controls.

Melba23's code indicates the way to handle this. May I suggest yöu save his code on your computer. I kept his useful code about a month ago, saving it under a catchy name '"Double-click a label (WM_COMMAND).au3" :D

Good luck

"I think you are searching a bug where there is no bug... don't listen to bad advice."

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
  • Recently Browsing   1 member

×
×
  • Create New...