Kaasplakje Posted December 31, 2019 Posted December 31, 2019 Hi Guys! I am new to autoIT and have started to make a simple script that reads the sourcecode of a website and returns a message box (popup) with the time, name and text which was lastly written. Now I'm trying to figure out how to let it run smoothly, update and edit the msgbox for bigger messages but it is not working out for me. Maby you guys could push me into the right direction. Here is the code: ; Message box script for updates in Delphi #include <String.au3> #include <Array.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> ; Variables $Source = '{"MessageID":19719,"Timestamp":"2019-12-31T14:06:00.903","Tag":"","Text":"Dit bericht kan je negeren en is voor een software test :)","Type":"Chat","Votes":1,"Enabled":true,"User":{"Name":"Damian Kessler","Division":"RN"},"Division":"RN"}]' ;Select the chunks from the shoutbox source code $FirstChunks = _StringBetween($Source, '{"MessageID":', '"},' ) ;Takes the log from the source code For $a In $FirstChunks ConsoleWrite($a & @CRLF) Next Const $sTxt = $FirstChunks[UBound($FirstChunks) -1] ;selects the last message which was put into shoutbox Local $aArray = StringRegExp ($sTxt, '"Timestamp":"(.+?)".+"Text":"(.+?)".+"Name":"(.+?)"', $STR_REGEXPARRAYMATCH) $Time = $aArray[0] $Text = $aArray[1] $Name = $aArray[2] Func _TrayMessageBox($TBTitle, $TBText, $TBwidth = 220, $TBheight = 100, $display_Time = 5000) $TBgui = GUICreate($TBTitle, $TBwidth, $TBheight, @DesktopWidth - ($TBwidth + 12), @DesktopHeight - ($TBheight + 53), -1, $WS_EX_TOOLWINDOW) $Status = GUICtrlCreateLabel($TBText, 20, 20) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $TBgui, "int", 1000, "long", 0x00040008);slide-in GUISetState() Sleep($display_Time) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $TBgui, "int", 1000, "long", 0x00050004);slide-out GUIDelete($TBgui) EndFunc ;==>_TrayMessageBox ; Simple Example _TrayMessageBox($Time, $Name & @CRLF & @CRLF & $Text)
Nine Posted December 31, 2019 Posted December 31, 2019 (edited) As I already told you in your previous thread here, you could (should) extract all the informations from multiple messages with only StringRegExp. Your current _StringBetween is defective. It won't work properly with multiple "MessageID" into a single string. So the 2 solutions : 1- Remove the _StringBetween and use $STR_REGEXPARRAYGLOBALMATCH in the StringRegExp (you must have @CRLF at the end of each message) Local $aArray = StringRegExp ($Source, '"Timestamp":"(.+?)".+"Text":"(.+?)".+"Name":"(.+?)"', $STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay ($aArray) 2- Use StringSplit instead of _StringBetween ([0] cell will be empty) $aChunks = StringSplit ($Source, '{"MessageID":', $STR_ENTIRESPLIT+$STR_NOCOUNT) _ArrayDisplay ($aChunks) Once you got the data, you will need to loop thru each message and display it as you would like. Maybe the tray approach is not best for multiple messages. Something like a Listview could be more appropriate... Edited December 31, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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