Jump to content

Beep sound if Textbox value changes


Go to solution Solved by Zedna,

Recommended Posts

1 hour ago, EAHuaroto said:

do you think we could add or concatenate a "STRING" at the end  of the Textbox value?

Take a look at https://www.autoitscript.com/autoit3/docs/functions/ControlSetText.htm

Edit : You can add the sign behind the numeric string ( ... & " €"). This will be ignored by the Number function (but don't put it before the value !). Which position is suitable for this operation, however, I can not judge, because I only see your code snippet.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Compacted version

$sTextOld = ''

 While WinActive("[Title:Caja]") And Assign("sText", ControlGetText("Caja", "", "ThunderRT6TextBox21"))
 If $sText <> $sTextOld And Number(StringReplace(StringStripWS($sText, 8), ',', '.',1))<>0 And Assign("sTextOld", $sText) And Beep(660, 300) Then Sleep(0)
 WEnd

 

Edited by Werty

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

45 minutes ago, Werty said:

Compacted version

Hi Werty !

In principle, there is nothing wrong with writing compact code. In this case, however, I am of the opinion that comprehensibility is more important than saving a few lines of code. But please don't take this as a criticism of your suggestion ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

lol, yea, it is more like a sport, fun doing it, but i also use the method in my own scripts simply to make a long script shorter, when there are parts that are done and doesnt need anymore changing, less scrolling.

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

On 8/16/2022 at 8:33 PM, EAHuaroto said:

 

Great, thanks! …By the way, using this code, I mean not creating a new script file, do you think we could add or concatenate a "STRING" at the end  of the Textbox value? I'd like to see the Textbox showing the currency symbol every time the value changes. By default, the Textbox does not shows the currency symbol on the app .  

 

Ref. 

 

POS Textbox Parameter Layout by default

POS Textbox Parameter Layout by default.png

 

 

 

How I wish It would look like

How I wish It would look like.png

 

Here are two possible ways, you can accomodate code accordingly:

$sTextOld = ''

While True
    If WinActive("[Title:Caja]") Then ;Check if POS Window is currently active.
        $sText = ControlGetText("Caja", "", "ThunderRT6TextBox21") ;Get data from  "TOTAL Textbox"
        If $sText <> $sTextOld Then ;Beep if "TOTAL Textbox" value changes
            If Number(StringReplace(StringStripWS($sText, 8), ',', '.',1)) <> 0 Then Beep(660, 300) ;Beep sound (not when 0 / 0,00)
            $sTextOld = $sText & ' €'
            ControlSetText("Caja", "", "ThunderRT6TextBox21", $sTextOld)
        EndIf
    EndIf
    Sleep(0)
WEnd

 

$sTextOld = ''

While True
    If WinActive("[Title:Caja]") Then ;Check if POS Window is currently active.
        $sText = ControlGetText("Caja", "", "ThunderRT6TextBox21") ;Get data from  "TOTAL Textbox"
        If $sText <> $sTextOld Then ;Beep if "TOTAL Textbox" value changes
            If Number(StringReplace(StringStripWS($sText, 8), ',', '.',1)) <> 0 Then Beep(660, 300) ;Beep sound (not when 0 / 0,00)
            If Not StringInStr($sText,'€',1) Then
                $sText &= ' €'
                ControlSetText("Caja", "", "ThunderRT6TextBox21", $sText)
            EndIf
            $sTextOld = $sText
        EndIf
    EndIf
    Sleep(0)
WEnd

 

Edited by Zedna
Link to comment
Share on other sites

23 hours ago, Zedna said:

 

Here are two possible ways, you can accomodate code accordingly:

$sTextOld = ''

While True
    If WinActive("[Title:Caja]") Then ;Check if POS Window is currently active.
        $sText = ControlGetText("Caja", "", "ThunderRT6TextBox21") ;Get data from  "TOTAL Textbox"
        If $sText <> $sTextOld Then ;Beep if "TOTAL Textbox" value changes
            If Number(StringReplace(StringStripWS($sText, 8), ',', '.',1)) <> 0 Then Beep(660, 300) ;Beep sound (not when 0 / 0,00)
            $sTextOld = $sText & ' €'
            ControlSetText("Caja", "", "ThunderRT6TextBox21", $sTextOld)
        EndIf
    EndIf
    Sleep(0)
WEnd

 

$sTextOld = ''

While True
    If WinActive("[Title:Caja]") Then ;Check if POS Window is currently active.
        $sText = ControlGetText("Caja", "", "ThunderRT6TextBox21") ;Get data from  "TOTAL Textbox"
        If $sText <> $sTextOld Then ;Beep if "TOTAL Textbox" value changes
            If Number(StringReplace(StringStripWS($sText, 8), ',', '.',1)) <> 0 Then Beep(660, 300) ;Beep sound (not when 0 / 0,00)
            If Not StringInStr($sText,'€',1) Then
                $sText &= ' €'
                ControlSetText("Caja", "", "ThunderRT6TextBox21", $sText)
            EndIf
            $sTextOld = $sText
        EndIf
    EndIf
    Sleep(0)
WEnd

 

 With these lines we're experiencing a "slow transition effect"  every time the control Textbox update the value (deleting de currency symbol, putting the numeric value, adding the currency symbol again) but It was a good try, though 

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