Sign in to follow this  
Followers 0
Crayfish

Stop updating text box if value the same.

3 posts in this topic

Please assist with the logic.

I have create a window that read another window text using controlgettext.

When i run this, it will capture the text and place in an edit box. The problem is it continuously doing it. I can't even select the input field.

If there a way to stop it from updating the input if the text in the input is the same as the capture.

Logic:

Get info → if info is the same in the input box → don't update

→ if info is different → update input box

→ if can't find info from external → keep looking.

I also wonder if it possible to have a list of last 3 info obtained.

Thank you for your assist. Please let me know if you need anything in addition.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1_1 = GUICreate("Current Info", 490, 122, 699, 494)
$Group1 = GUICtrlCreateGroup("Info", 8, 8, 473, 105)
$Label1 = GUICtrlCreateLabel("Category:", 16, 24, 69, 17)
$Label2 = GUICtrlCreateLabel("Type:", 44, 50, 41, 17)
$Label3 = GUICtrlCreateLabel("Net:", 24, 74, 58, 17)
$Label4 = GUICtrlCreateLabel("Field:", 288, 24, 62, 17)
$Label5 = GUICtrlCreateLabel("Size:", 304, 74, 45, 17)
$Input1 = GUICtrlCreateInput("", 88, 22, 193, 21)
$Input2 = GUICtrlCreateInput("", 88, 47, 193, 21)
$Input3 = GUICtrlCreateInput("", 88, 72, 193, 21)
$Input4 = GUICtrlCreateInput("", 352, 22, 121, 21)
$Input5 = GUICtrlCreateInput("", 352, 72, 121, 21)
;$Label6 = GUICtrlCreateLabel("Completed:", 292, 50, 57, 17)
;$Input6 = GUICtrlCreateInput("", 352, 47, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    
            Global $Label1V = ControlGetText("Time", "", "[NAME:cboEditCategory]"); Job Category
            Global $Label5V = ControlGetText("Time", "", "[NAME:txtEditSize]"); lot size
            Global $Label2V = ControlGetText("Time", "", "[NAME:dataCacheComboBox1]"); Vendor
            Global $Label4V = ControlGetText("Time", "", "[NAME:txtCombobox]"); Work Order
            Global $Label3V = ControlGetText("Time", "", "[NAME:cboEditType]")

            _WindowMonitor() ; Call the Function to monitor Notepad.
WEnd



Func _WindowMonitor()
$Hold = ""
If Not $Hold = $Label4V Then
GUICtrlSetData($Input1,$Label1V)
GUICtrlSetData($Input2,$Label2V)
GUICtrlSetData($Input3,$Label3V)
GUICtrlSetData($Input4,$Label4V)
GUICtrlSetData($Input5,$Label5V)
$Hold = $Label4V
elseif $Hold = $Label4V Then
   sleep(50)
Endif
EndFunc

Share this post


Link to post
Share on other sites



Thanks JohnOne.

I revised the function as follow and it work decently but it still spamming the func. Is there a better logic to call the func when there changes?

Would you know the best way to hold last 3 infos obtained?

Func _WindowMonitor()
If $Hold <> $Label1V Then
   GUICtrlSetData($Input1,$Label1V)
   GUICtrlSetData($Input2,$Label2V)
   GUICtrlSetData($Input3,$Label3V)
   GUICtrlSetData($Input4,$Label4V)
   GUICtrlSetData($Input5,$Label5V)
   $Hold = $Label1V
   Else
   Sleep(50)
EndIf
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0