vanillaslice Posted November 8, 2019 Share Posted November 8, 2019 Hey all! I've been trying to make script that pulls hashtags from posts on Instagram so I can make some analytics. However I'm very new to AutoIt, and coding in general, so I thought I'd just familiarise myself with the Syntax before getting ahead of myself. After a few days of straining to understand the help file and other posts I can't seem to fully comprehend Functions and Loops. I've been trying to make a check function that makes sure that the post preview section is on screen, and that a post is loaded. I have the variables which imply those states figured out, and what I think is a functional check/loop. However when it runs the LoadChk() function, the script seems to continue running without waiting for it to finish. I feel like this is some really basic Syntax error, but I've tried my best to understand it and have come up short. Any help would be appreciated! expandcollapse popupGlobal $iCounter = 0 Global $iOperations = 100 While $iCounter < $iOperations LoadChk() ;Checks if post preview window is open, and the next post has loaded. Sleep (500) Send("^f") Send({ESC}) ;Here I'll put my search/record function. For now just closes the find tool and continues. Send("{RIGHT}") $iCounter = $iCounter + 1 WEnd Func LoadChk() Local $iBGcolour = PixelGetColor(1355, 577) Local $iPOSTcolour = PixelGetColor(2081, 619) Local $iWaitCount = 0 If $iBGcolour <> 526601 Then ;If it is not this colour it means the post preview window is closed. MsgBox(0,"Error", "No Post Selected.") Exit ElseIf $iPOSTcolour = 526601 Then ;If it is this colour then it means post has not loaded. While $iPOSTcolour = 526601 ;Check again two more times, otherwise end the script. Sleep(1000) If $iWaitCount > 2 Then MsgBox(0, "Error", "Post not loading.") Exit EndIf iWaitCount = $iWaitCount + 1 $iPOSTcol = PixelGetColor(2081, 619) WEnd EndIf EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Nine Posted November 8, 2019 Share Posted November 8, 2019 Take a serious look at IE UDF. Trying to automate a web site with colors and stuff will get you nowhere. “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
vanillaslice Posted November 8, 2019 Author Share Posted November 8, 2019 1 hour ago, Nine said: Take a serious look at IE UDF. Trying to automate a web site with colors and stuff will get you nowhere. I see, this all looks very useful. Thanks! While I appreciate your help, the reason I post is to understand why the script seems to continue without waiting for the LoadChk() to finish. I'd like to be sure I fully understand how to set up Error Checking functions, regardless of the environment they're in. I've confirmed that it's pulling the correct colours, and that it detects it needs to wait for two more rechecks. Although when the LoadChk() runs it seems to continue with the script before it's had a chance to finish the function. Resulting in a bunch of keys being sent and making a mess before the error MsgBox appears and Exits the script. Again, I really appreciate the time. Link to comment Share on other sites More sharing options...
Nine Posted November 8, 2019 Share Posted November 8, 2019 2 hours ago, vanillaslice said: iWaitCount = $iWaitCount + 1 Missing a $ there ! “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted November 8, 2019 Share Posted November 8, 2019 (edited) 2 hours ago, vanillaslice said: $iPOSTcol = PixelGetColor(2081, 619) missing a our there ! Like I said so many times, programmers of autoIt should always use : Opt ("MustDeclareVars", 1) At the beginning of their scripts. It saves a lot of time debugging... Edited November 8, 2019 by Nine seadoggie01 1 “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted November 8, 2019 Share Posted November 8, 2019 4 hours ago, Nine said: missing a our there ! Like I said so many times, programmers of autoIt should always use : Opt ("MustDeclareVars", 1) At the beginning of their scripts. It saves a lot of time debugging... This is always a good advice . If anyone like to have it really fierce, she/he can also use the following compiler directive : #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 https://www.autoitscript.com/autoit3/docs/intro/au3check.htm -q : quiet (only error/warn output)-d : as Opt("MustDeclareVars", 1)-w 1 : already included file (on)-w 2 : missing #comments-end (on)-w 3 : already declared var (off)-w 4 : local var used in global scope (off)-w 5 : local var declared but not used (off)-w 6 : warn when using Dim (off)-w 7 : warn when passing Const or expression on ByRef param(s) (on) Opt('MustDeclareVars', 1) can then be omitted because the flag -d sets the "MustDeclareVars" option to True. Note : I do not use the parameter -w 5 during development. Especially for larger projects it is not uncommon to declare local variables without using them immediately (only warnings - no errors - are issued, but this can be nerve-racking). At the end of a project you can 'activate' -w 5 to find unused local variables. At the beginning, this directive can be very annoying because it reveals many weaknesses, but on the long run, it makes scripts neater. "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 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