Zeerti Posted July 16, 2013 Share Posted July 16, 2013 (edited) I've got a script right now that is pulling information from a website and pasting it into a chat room for my job. The way it works it reads the chat log of the chat room, scans whats said and then copies out what it needs to run on the website. The problem is that right now it can only run one lookup at a time and by the time someone else needs a look up the chat has moved on and it no longer can see the prior request. What would be great is if someone could show me how you can set up a queuing system so it stores each request it sees and then pushes them out one by one. I honestly have no idea how to even being to implement something like. Bit of a programming noob here. Edited July 16, 2013 by Zeerti Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 Hi,Arrays should be a good start for your queuing system.Br, FireFox. Link to comment Share on other sites More sharing options...
Zeerti Posted July 16, 2013 Author Share Posted July 16, 2013 So I know how to make it save to an array, but how do I have it push out information that I have already used? Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 You have multiple ways to do it, you can for example use the _Array* functions :#include <Array.au3> Local $aQueue[1] _ArrayAdd($aQueue, "task1") _ArrayAdd($aQueue, "task2") _ArrayDisplay($aQueue) ;process task1 _ArrayDelete($aQueue, 1) ;delete task1 _ArrayDisplay($aQueue)Br, FireFox. Link to comment Share on other sites More sharing options...
Zeerti Posted July 16, 2013 Author Share Posted July 16, 2013 Here is a sample of the current code $Final_Text = StringRegExp(ClipGet(), "(CM[^\v]+|Current CMTS Status[^\v]+|Modem Boot File[^\v]+)", 3) ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "===Health Check Results===" & @LF & $Final_Text[0] & @LF & $Final_Text[1] & @LF & $Final_Text[2]) ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "{ENTER}") Based off this and what you were saying it will push in as many things it finds and paste the first three. So what I need to do is add in a line of code that tells it to delete those three posted and then loop this until Ubound == 0 right? Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 (edited) ah, it's not a queue. In your case the StringRegExp returns an error flag on failure, the following script will perform actions only if it succeeds otherwise the loop will restart. While 1 $Final_Text = StringRegExp(ClipGet(), "(CM[^\v]+|Current CMTS Status[^\v]+|Modem Boot File[^\v]+)", 3) If @error Then ContinueLoop ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "===Health Check Results===" & @LF & $Final_Text[0] & @LF & $Final_Text[1] & @LF & $Final_Text[2], 1) ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "{ENTER}") WEnd Edit: How do you know the computer is busy to add the results to a queue? Br, FireFox. Edited July 16, 2013 by FireFox Link to comment Share on other sites More sharing options...
Zeerti Posted July 16, 2013 Author Share Posted July 16, 2013 Still trying to learn how to use macros properly, but in the example you used I am a little confused why the @error is important. Also don't you have to set the @error with the SetError function? I'm going to go ahead and post the full code so you can see exactly what I am doing. Also please feel free to critique me. If there is a better way to get this accomplished I would love to know. I know for starters I need to understand when to use local and global variables expandcollapse popup;Bugs to be Fixed ;1. Fix to work with up to 4 modems on account. ;2. IECrashes @ end of script sometimes ;3. Get ControlSend() to function with IE ;Long Term Goals ;1. Outage Detection + Message ;2. Entitlement ;3. Direct pinging of people ;4. Rewrite to work with multiple instances running ;4.1 In allowing multiple instances to run, have them communicate with each other to not repeat requests (.ini file?) ;Short Term Goals ;1. Display Account # when returning GSLU ;2. Have buttons clicked based on pixels and not coords ;Assign last array element to a variable to open up. #include <FileSource.au3> #include <array.au3> #include <IE.au3> #include <File.au3> ;Run("C:\Program Files (x86)\Pidgin\pidgin.exe") ;Start Pidgin $healthMessage = "===Health Check Results===" $link = "HTTP:\\COMPANYWEBSITE.NET" $oIE = _IECreate($link, Default, 1) ;_IENavigate($oIE, $link, 1) WinMove("[CLASS:IEFrame]", "", 0, 0, 1050, 656) ;Array of files in log folder ;Chat room Text input $FileList = _FileListtoArrayEx('C:\Users\ETC\ETC\ETC', '*.*', 1) $File = $FileList[$FileList[0]] ;ConsoleWrite($FileList[$FileList[0]]) While True ;Opens the file, reads the last line $FileHandle = FileOpen($File) $LineRead = FileReadLine($FileHandle, -1) FileClose($FileHandle) ;Check if GSLU was found $RegExArray = StringRegExp($LineRead, ".*?((?i)GSLU).*?(\d+).*?((?i)Health)", 3) ;Start Main Loop if Ubound($RegExArray) == 3 Then ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "Processing GSLU, ETA 30 seconds." & "{ENTER}") ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "{ENTER}" & "{ENTER}" & "{ENTER}") WinActive("[CLASS:IEFrame]") ClipPut($RegExArray[1]) _IEImgClick($oIE, "SearchIconT.gif") sleep(5000) MouseClick("left", 465, 220, 1, 0);Account Click ;Sleep(100) Send(ClipGet()) Send("{ENTER}") Sleep(8000) _IELinkClickByText($oIE, "HSI", 0, 1) _IELinkClickByText($oIE, "Health Check", 1, 1) Sleep(1500) MouseClick("Left", 180, 230, 1, 0) ;Clicking Modem ;Sleep(100) MouseClickDrag("Left", 180, 230, 180, 260, 1) ;Clicking Modem MouseClick("Left", 530,280,1,0) ;Clicking Health MouseClick("Left", 530,300,1,0) ;Clicking Health Sleep(5000) MouseClick("Left", 826, 283,1,0) ;Clicking Text Format MouseClick("Left", 826, 293,1,0) ;Clicking Text Format MouseClick("Left", 500, 260,1,0) ;Clicking Text Format for copying Send("^a") Send("^c") Send("^c") ;Sleep(500) ;Refining GSLU down to needed info $Final_Text = StringRegExp(ClipGet(), "(CM[^\v]+|Current CMTS Status[^\v]+|Modem Boot File[^\v]+)", 3) ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "===Health Check Results===" & @LF & $Final_Text[0] & @LF & $Final_Text[1] & @LF & $Final_Text[2]) ControlSend( "[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "{ENTER}") Send("{F5}");NEEDS TO BE EDITED TO CONTROLSEND TO IEWINDOW Sleep(5000);LOOK INTO _IEWAIT EndIf Sleep(100) WEnd ;BAD BOOT FILES CaptivePortal, timeout, walledgarden, cdvonly, vacation, non-pay. Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 Still trying to learn how to use macros properly, but in the example you used I am a little confused why the @error is important. Also don't you have to set the @error with the SetError function?The @error is important to check if the CMTS Status is found (without knowing how much element will be returned in the array). In your script you use the UBound function which is more accurate.Also please feel free to critique me. If there is a better way to get this accomplished I would love to know.I will post a script with some possible improvements.I know for starters I need to understand when to use local and global variables You should take a look at the "Best coding practices" topic.;1. Fix to work with up to 4 modems on account.Is an account linked to a single text file?If Ubound($RegExArray) = 3 Then ;use a single equal sign to compare (two equal signs are for case sensitivity string comparison) ControlSend("[CLASS:gdkWindowToplevel]", "", "gdkWindowChild4", "{ENTER 3}") Send("^v") ;instead of Send(ClipGet())And try to use as much as possible IE* functions instead of Mouse* functions.Br, FireFox. Link to comment Share on other sites More sharing options...
Zeerti Posted July 17, 2013 Author Share Posted July 17, 2013 CMTS status? I would love to see what you come up with. I'll take a look at that best practices post How it works is the web GUI loads and you have to click on the individual modem and then press another button to pull up the info. You can have it click all at once with a click drag. However the buttons move depending on how many modems are on the account. So I have it right now clicking multiple times downwards in a line to compensate for that. The problem with using IE functions is that the way the website loads I honestly have no idea how to do it. I'll post a screenshot of what it does, but breif example. It loads the website with JS and that pulls up fine and works with the IE* usage. However, when you go to search an account it pulls up a window within the window and this window cannot be seen by the IE* functions, at least from what I can gather. Sending a ControlSend() to it also causes it to click behind this window and not actually on it. This is why I have to send regular Mouse() functions. That alone is what kills this program from being able to run multiple instances of it at once on the same machine which is something I ultimately want to change. However, I am focusing on the more important things at hand and will look to that in a later version of it! Link to comment Share on other sites More sharing options...
FireFox Posted July 19, 2013 Share Posted July 19, 2013 CMTS status?I was talking about this code :$Final_Text = StringRegExp(ClipGet(), "(CM[^\v]+|Current CMTS Status[^\v]+|Modem Boot File[^\v]+)", 3)I would love to see what you come up with.I think you missunderstood what I meant, you need to add a UBound check like the first regexp test you make.For the rest, It might be easier to directly send/receive HTTP requests.Br, FireFox. 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