keeeniiic Posted September 4, 2019 Share Posted September 4, 2019 Hello Community, I found your Software to solve a Problem I have. So I have an Application which needs to Update the GUI of another Application based on the Content of the first Application. I managed to get the Text of the first Application using this: $Text=WinGetText("Test2 Rechnungskontrolle (Verbuchung)") As a return I get this: ? 01.10.2018 Bankeinzug 1% Skonto SFru Beleg geprüft Überweisung 5 Bank: Bankkonto: IBAN: Verteilergruppe: Bemerkung: Valutadatum: Zahlungsziel: Zahlungsart: SB Prüfung: Bankverb Konto: Fr 28.09.2018 01.10.2018 SFru Fr 28.09.2018 &Zuschläge SFru AR000304858 F&reigabe EUR 0 A 4672 Bachmanning GutschrErzeugen Unterseling 13 Beleg freigegeben Schmalwieser GesmbH & Co KG &Parameter Solan Kraftfutterwerk &Adresse 306812 701015 Lieferant: Belegnummer: Name: Straße: Ort: Währung: RechnungsNr: Sachbearbeiter: Rechnungsdatum: Wiedervorlage: angelegt durch: Belegdatum: Basisdaten|Zuschläge|Steuer So I need now this Bold Number above, how can I manage this using RegEx or is there another solution, with the Window Info tool I can actually drop the mouse tool directly on this Number 701015. The Contents of the Window Info Tool is following: Please anyone can help me I need this Number to be able to change the gui of the second application. Also as second part I need then this script to run like a service and watch this window live and see if this Value is changing in order to be able to update the second application via an http rest call. Thank you! Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 4, 2019 Share Posted September 4, 2019 @keeeniiic If the number is always in that position of the string, you could do something like this: #include <Array.au3> #include <StringConstants.au3> Global $strString = "&Adresse" & @CRLF & _ "306812" & @CRLF & _ "701015" $arrResult = StringRegExp($strString, '(?s)&Adresse.*?\d+.*?(\d+)', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then _ArrayDisplay($arrResult) keeeniiic 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
keeeniiic Posted September 5, 2019 Author Share Posted September 5, 2019 11 hours ago, FrancescoDiMuro said: @keeeniiic If the number is always in that position of the string, you could do something like this: #include <Array.au3> #include <StringConstants.au3> Global $strString = "&Adresse" & @CRLF & _ "306812" & @CRLF & _ "701015" $arrResult = StringRegExp($strString, '(?s)&Adresse.*?\d+.*?(\d+)', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then _ArrayDisplay($arrResult) Thank you very much, this was the Solution. Now if you could help me how I can put this in kind of WatchDog Service that it recognises if the Value has changed in order to be able to change the other applications GUI based on this number. Thank you! Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 5, 2019 Share Posted September 5, 2019 (edited) @keeeniiic Does it need to be ran as a service, or could it run in background, without a GUI? If so, take a look at AdLib* functions, which allow you to re-run the code in a specific amount of time. You could also take a look at Timer* and/or _Timer* functions in the Help file. Try them, and come back with your script if you have any problem/question Edited September 5, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
keeeniiic Posted September 5, 2019 Author Share Posted September 5, 2019 10 hours ago, FrancescoDiMuro said: @keeeniiic Does it need to be ran as a service, or could it run in background, without a GUI? If so, take a look at AdLib* functions, which allow you to re-run the code in a specific amount of time. You could also take a look at Timer* and/or _Timer* functions in the Help file. Try them, and come back with your script if you have any problem/question I don't need a GUI, it should and actually must run in the background. But if I do it by time this would mean it is not monitoring live the change of the user, I actually need to monitor this value, if you tell me that this should be possible with the AdLib and or Timer functions then let me know. Thanks for your help. Best regards Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 5, 2019 Share Posted September 5, 2019 @keeeniiic So the application need to be ran by different users? You can use AdLib* and Timer* functions in order to run the script every N seconds, for example. If it is what you need, then dig a little deep in those class of functions and look at the examples provided in the Help file Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
keeeniiic Posted September 6, 2019 Author Share Posted September 6, 2019 (edited) Hi Francesco, so I managed to make this Code: #include <Array.au3> #include <StringConstants.au3> Global $storeOld, $storeOldhelper, $lieferant, $strString Func getLieferant() $strString = WinGetText("Test2 Rechnungskontrolle (Verbuchung)") $arrResult = StringRegExp($strString, '(?s)&Adresse.*?\d+.*?(\d+)', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then $lieferant = $arrResult[0] Return $lieferant EndFunc Func isChanged() $strString = WinGetText("Test2 Rechnungskontrolle (Verbuchung)") $arrResult = StringRegExp($strString, '(?s)&Adresse.*?\d+.*?(\d+)', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then $lieferantChanged = $arrResult[0] If $lieferantChanged == $lieferant Then getLieferant() Else MsgBox(0,"Changed",$lieferantChanged) EndIf getLieferant() AdlibRegister(isChanged(),1000) ; call this function again in 1 second EndFunc isChanged() I'm new to programming and to autoit, this code works partly not on every change if I switch faster then in 1 second for example and this is not reliable for me, do you have any suggestion for me how I can monitor the input better? Thanks. Edited September 6, 2019 by keeeniiic Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now