Jump to content

IAMK

Active Members
  • Posts

    210
  • Joined

  • Last visited

Everything posted by IAMK

  1. The code is literally just: Global $file = FileOpen("LogScript.txt", 1) ;SCRIPT============================================================================================ FileWrite($file, _Now() & ": AUTOIT - Started." & @CRLF) MouseClick("primary", 50, 50, 1, 0) ;Makes sure the video is closed. Sleep(500) Upon disabling my ToolTip, which was on MouseGetPos(0), MouseGetPos(1) (separate script), this code worked fine. It seems there is some race condition happening with a ToolTip on top of the cursor and performing a mouseclick. Not sure why that would be the case though.
  2. I have a script which I've been using for over a year, and now I'm seeing issues with it. I originally attributed the issue to the system becoming laggy, so I added sleeps (even up to 1-second long, which is a long time). Hence, I don't believe the issue is lag. When I use my fingers for the touchscreen, or the mouse for manual click, it seem to work consistently. Now, when I'm trying to debug the script, It runs the same line of code (it's the very first line of the script), but sometimes it clicks and sometimes it doesn't. The code I'm having issues with is literally just MouseClick("primary", 50, 50, 1, 0) ;Close the video. Note: I'm always running the script on the same program (which I am not restarting - but I have tried powercycling the system and it makes no difference), at the same screen, but the result is inconsistent. Is there possibly some setting a computer/program can have which makes MouseClick() work inconsistantly, which I need to fix? One thing I have tried is putting it in a loop. Then, when it doesn't work, it will keep pressing the same location every .5 seconds (but doesn't work). I then use the touchscreen to touch another location, and after 1-5 attempts of the touch screen, the MouseClick() in the loop works (getting stuck later again until I use the touchscreen again). Note: The movement of the mouse works 100% of the time. It's just the click that doesn't always work. This is making my head explode. Any help would be greatly appreciated.
  3. Okay, I'll start using Scite then, since Scite-Lite doesn't have that. Thank you.
  4. I don't know what this is called, so I'm having difficulties finding the answer to this. I tried suggested/predicted/autofill/autocomplete, etc. Similar to how typing "_Arr" while scripting will show you "_ArrayAdd()", etc. Also, when you open the function bracket, it steps you through the required parameters. How do I set this up for my own variables/functions? If possible, this would make development much easier, as I have a lot of functions (from other .au3 files) which get included by a lot of my scripts.
  5. @LarsJ Thanks for the comprehensive information. I also see I may have mislead people with my first post. My arrays/filesize are not extreme, it is just the amount of times the operation is done which is extreme. Powershell: Open 10+ 100mb text files one at a time and parse them. Python: Open a 10kb text file, parse it into an array with a total of 500-1500 elements. Another array stores unique combinations (1000). I should be good for now I think. Thanks.
  6. @junkew Ehhh, the stripped down version would be that each loop represents a letter. The letters are read from the static file into arrays before the loops come into action on the arrays. E.g. hello, helli, helol, hallo are uniques which get logged, and if it finds another hello it doesn't get logged a 2nd time.
  7. @Earthshine @junkew I cannot share the actual logs, as it's confidential data. However, for the python script, the log is a small one which takes milliseconds to read. The operations are done on my array. Anyways, I'll read into Larsj's safe array stuff. Sounds good. Thanks. @BigDaddyO Correct. No validation is necessary (I manually verified the format and data before creating the script). I'm not really pulling out data, but rather processing it.
  8. @BigDaddyO Thanks. I will look into FreeBasic. Else I will probably go for C++. @Earthshine Thanks. I'm not familiar with python, but I was told to write in it, and getting it fast was a challenge. For my python script, the file read takes milliseconds, but the operations go on forever. Looking at it even now requires me to read it to try and reunderstand it. The messy code is something like: for a, aVal in enumerate(saa_data[0]): for b, bVal in enumerate(saa_data[1]): for c, cVal in enumerate(saa_data[2]): for i, iVal in enumerate(ia_lines): if (saa_data[0][getNum(0, a, i)] or ia_wild[0]) == (saa_data[1][getNum(1, b, i)] or ia_wild[0]) == (saa_data[2][getNum(2, c, i)] or ia_wild[0]): for d, dVal in enumerate(saa_data[3]): if (saa_data[0][getNum(0, a, i)] or ia_wild[0]) == (saa_data[3][getNum(3, d, i)] or ia_wild[0]): for e, eVal in enumerate(saa_data[4]): if (saa_data[0][getNum(0, a, i)] or ia_wild[0]) == (saa_data[4][getNum(4, e, i)] or ia_wild[0]): if searchOrAddRecord() == False: #If new unique combination was found. fout.write(str(a) + "," + str(b) + "," + str(c) + "," + str(d) + "," + str(e) + '\n')
  9. I read the following but still have some questions, as my circumstances may be bigger than what was discussed in the thread. How quick is AutoIT at parsing text files? E.g. If a simple powershell/python script takes ~5 hours to run, would AutoIT be slower or the same speed (on average)? I was planning on using AutoIT for the GUI, but would like to know if I should make it purely AutoIT or just use AutoIT for the GUI and make it call the powershell/python scripts I have. Examples of my powershell/python scripts: 1- Parse 1GB+ of text files and count how many times certain strings appear. 2- Read a file into an array and find all unique combinations (out of millions of possible mathematical combinations).
  10. https://www.autoitscript.com/wiki/Arrays https://www.autoitscript.com/autoit3/docs/keywords/For.htm These should give examples on what faust has mentioned.
  11. Does this help? WinSetTrans($MYGUI, "", 100)
  12. @genius257 Thanks. I will look into both of those for #1 and #4.
  13. I feel like some of this might not be possible, but I thought I'd ask. I want to create a GUI which does the following: 1- Only has a full-screened YouTube video in it. 2- Is resizable, but contains the aspect ratio (The full-screen works with resizability). 3- Finds the aspect ratio of the video (if videos have different aspect ratios). 4- Videos autoplay. 5- A URL which displays the current playing video's link (for copy/share purposes). 6- A button which brings a popup GUI which does the following: a- Allows searching the YouTube webpage for videos. b- Clicking on a video will remove the GUI, and the video being watched on the main GUI will be the selected video. Current status (problems in bold): 1- I need to manually press it. Choosing a new video would also break this. 2- Resizing works, but not to aspect ratio. 3- My plan is to read the source code for the aspect ratio (if there's no better way)? 4- Need to ensure autoplay is enabled. Don't know how to do this. 5- Implemented, but happens a million times. Way to improve this? 6- Trying to sort the others before I implement this, but this should be easy and replace the Search button. a- Simple IE Browser... b- My plan is to _IE_Navigate() the main GUI then hide the search GUI after finding the URL in the source of the video I clicked on? Is there a way to not go to the video in the search GUI, but rather just send the URL when a video is clicked? #include <IE.au3> #include <GUIConstantsEx.au3> $MYGUI = GUICreate("YoutubePlayer", 440, 300, -1, -1, 0x00CF0000) $URL = GUICtrlCreateCombo("http://youtube.com", 0, 0, 400) GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT)) $searchButton = GUICtrlCreateButton("Search", 400, 0, 40, 20) GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKRIGHT, $GUI_DOCKSIZE)) $xy = WinGetClientSize($MYGUI) $videoPlayer = _IECreateEmbedded() GUICtrlCreateObj($videoPlayer, 0, 22, $xy[0], $xy[1] - 22) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetState() _IENavigate($videoPlayer, GUICtrlRead($URL)) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit Case $searchButton _IENavigate($videoPlayer, GUICtrlRead($URL)) EndSwitch GUICtrlSetData($URL, _IEPropertyGet($videoPlayer, "locationurl")) Sleep(100) Until False If anyone knows the solutions, it would be greatly appreciated. Thanks.
  14. @FrancescoDiMuro @Dwalfware I understand how the ArraySplit() and $arrSplit[0] work. I meant this part: Global $strString = 'After this is a link!!! <a href="https://imgur.com/a/u9E0Srf" target="_blank">https://imgur.com/a/u9E0Srf</a><br>Before this was a link!!! //Note: This is 1 line.' & @CRLF & _ 'After this there is another link!!! <a href="https://imgur.com/a/something" target="_blank">https://imgur.com/a/something</a><br>Before this was another link!!! //Note: This is 2 line.', _ $arrSplit @iamtheky Thanks, but I don't require this. I only wrote it as this website word wraps there. @mikell Yes, that's what I was getting at. Thanks.
  15. @FrancescoDiMuro That regex is too complex for me to understand :s Also, why is $arrSplit appended to the string? I'm not sure what that does since $arrSplit has not been defined yet. @mikell Jesus, you and your regex... I laughed as soon as I saw your name, expecting regex. I'm not sure if something like X < Y will ever appear, but I'll keep your code in mind in case I'm sure it won't appear.
  16. @Nine Thanks, I will try that. Also, the load did finish in my case (stopped spinning almost instantly).
  17. How I currently write HTML_INNERTEXT to a text file without editing it: After this is a link!!! <a href="https://imgur.com/a/u9E0Srf" target="_blank">https://imgur.com/a/u9E0Srf</a><br>Before this was a link!!! //Note: This is 1 line. Goal is to have this: After this is a link!!! https://imgur.com/a/u9E0Srf Before this was a link!!! //Note: This is 2 lines. I'm trying to do something along the lines of the following, but am stuck on the second last line of the function: Func cleanup($temp) ;Turns special characters back to their real symbols. Local $cleanupResult = $temp $cleanupResult = StringReplace($cleanupResult, "<br>", @CRLF) $cleanupResult = StringReplace($cleanupResult, ">", ">") $cleanupResult = StringReplace($cleanupResult, "<", "<") $cleanupResult = StringReplace($cleanupResult, "&", "&") Local $tempURL = $cleanupResult $tempURL = StringSplit($tempURL, '<a href="', 1) $tempURL = StringSplit($tempURL[1], '"', 1) $cleanupResult = StringReplace($cleanupResult, '<a href' UNTIL '</a>', $tempURL[0], 1) ;How do I do something like this? Return $cleanupResult EndFunc Or perhaps there's a MUCH simpler way of doing this? FYI: Where you see ">", ">" etc, it's actually changing & gt ; to >, but the formatting on this site hides it.
  18. @Nine Ah, that will help me with debugging I think. I've been playing around for a while now, just doing random things. At one point I received an error when trying to navigate to the second page, but I can't reproduce that. The confusing thing is that the browser navigates correctly and does finish loading (because the icon stops spinning). Now, it works... I don't know why... @Danp2 Good observation. I just copied the links as they are on the website at those pages. Anyways, upon removing the wait as @Nine suggested, I found another issue in my code, correction in caps: While(UBound($linkArray) > 1) ;Reset the array. _ArrayDelete($linkArray, 2) ;THIS SHOULD HAVE BEEN 1 WEnd Now, my code works correctly, but that's because I've changed the following code as well, as suggested by @Nine: If($currentPage > 1) Then _IENavigate($ie, "http://lang-8.com/MYID/journals?page=" & $currentPage) ;ADDED 0 AS THE 3RD PARAMETER TO NOT WAIT FOR LOAD. EndIf ;ADDED HERE: Sleep(6000) I'm still not convinced though. I want to know why not setting WAIT to false breaks. Any ideas? Okay... just as I wrote the line above, I went to double check and changed the code back to set WAIT to true, and it works now... I am seriously confused now, because the first change I made of setting _ArrayDelete to delete element 1 is called AFTER my ConsoleWrite(), which was not getting reached on page 2, which was directly after _IENavigate(). Anyone have any clue?
  19. @FrancescoDiMuro Sorry, I should have mentioned before that the only reason I added ConsoleWrite/Tooltip was to see if the script ever reached those places. The only other thing I can do is Consolewrite("http://lang-8.com/MYID/journals?page=" & $currentPage) before the If statement, but that is the correct link format (and the website navigates to the correct page as expected).
  20. @FrancescoDiMuro No, it contains my password, etc. The most I can give is: #include <IE.au3> #include <Array.au3> Local $ie = _IECreate("https://lang-8.com/login?from=header") ;The Browser Local $totalPages = 60 Func runScript() _IELoadWait($ie) Sleep(2000) login() ;Not showing this function _IENavigate($ie, "http://lang-8.com/NotshowingmyID/journals/") Local $linkArray[1] = ["0"] Local $linkCount = 1 Local $currentPage = 1 While($currentPage < $totalPages) If($currentPage > 1) Then _IENavigate($ie, "http://lang-8.com/NotshowingmyID/journals?page=" & $currentPage) EndIf ConsoleWrite("1") While(UBound($linkArray) > 1) ;Reset the array. _ArrayDelete($linkarray, 2) WEnd ConsoleWrite("2") Local $oH3Tags = _IETagNameGetCollection($ie, "H3") For $oH3Tag In $oH3Tags If($oH3Tag.ClassName = "journal_title") Then $oLinks = _IETagNameGetCollection($oH3Tag, "a") For $oLink In $oLinks _ArrayAdd($linkArray, $oLink.href) Next EndIf Next ConsoleWrite("3") $linkArray[0] = UBound($linkArray) - 1 _ArrayDisplay($linkArray) ConsoleWrite("4") For $i = 1 To $linkArray[0] _IENavigate($ie, $linkArray[$i]) ;Go to the journal. Local $divTags = _IETagNameGetCollection($ie, "div") For $divTag In $divTags If($divTag.id = "body_show_ori") Then $fout = FileOpen("lang8journals.txt", 1) FileWrite($fout, _IEPropertyGet($divTag, "InnerHTML") & @CRLF & "--------------------------------------------------" & @CRLF) FileClose($fout) ElseIf($divTag.id = "body_show_mo") Then $fout = FileOpen("lang8journals.txt", 1) FileWrite($fout, _IEPropertyGet($divTag, "InnerHTML") & @CRLF & @CRLF) FileClose($fout) EndIf Next Next ConsoleWrite("5") $currentPage = $currentPage + 1 WEnd _IEQuit($ie) EndFunc runScript() The only part you need is the part in post 1, as the issue is from $currentPage being >1 and not returning from _IENavigate().
  21. I have the following code which is supposed to navigate through pages on a website. Local $currentPage = 1 While($currentPage < $totalPages) If($currentPage > 1) Then _IENavigate($ie, "http://lang-8.com/MYIDREMOVED/journals?page=" & $currentPage) EndIf ToolTip("1") For page 1, the code after the If statement works properly (because before Local $currentPage = 2 is executed, I have a _IENavigate() call to a plain URL (no $currentPage variable used as page 1 is always the same). However, when the code for page 1 finishes, I increment $currentPage to 2, and then the If statement never gets exited. It seems something inside _IENavigate() is not being handled properly when I use $currentPage in the URL. Note: The browser correctly navigates to page 2 but then just hangs. I have also tried to set $currentPage = 2, and the hang happens at the same spot, so the issue is not with doing the loop a second time. Does anyone know what could possibly be the issue and how I could fix this?
  22. Thanks. I wish all languages had this.
  23. I just found out that I can create empty arrays for use later. This will help me a lot with a few things I want to do. However, are there any reasons I wouldn't want to do this? Because from my experience, other languages can't do this. #include <Array.au3> Local $empty[0] _ArrayAdd($empty, "100, 100, 100, 100, 100, 1820, 1820, 1820, 1820, 1820", 0, ", ") _ArrayDisplay($empty) Thank you in advance.
  24. @BrewManNH Trust me that it works (the first example). Here is 100% complete test scripts: temp.au3: #include "temp2.au3" Global $file = FileOpen("temptext.txt", 1) LogToFile() FileClose($file) temp2.au3: Local $file = "" Func LogToFile() If($file <> "") Then ;If there is a $file in the calling script. FileWrite($file, "Hello") EndIf EndFunc It first includes temp2, which makes the Local $file = "", then it goes back to temp and makes the Global $file = Not "", then it calls the function in temp2, and $file holds the value of what was given in temp. Does that make sense?
  25. @BrewManNH That's because I'm the only programmer. I need to make things ASAP (as simple as possible) for the people who work with me and will be required to maintain these scripts. Otherwise, it all comes back to me to handhold. Trust me on this... In a personal project, I would do it the suggested way. Edit: The only time I've ever used complex code, is in files which get included and don't need to be looked at by anyone. I'm also 99% sure these functions will never need to be maintained.
×
×
  • Create New...