Jump to content

Question about AutoIT includes


IAMK
 Share

Recommended Posts

First of, by "AutoIT includes", I mean the default ones we can use with #include <name.au3>, not the ones I create myself. Is there a name for them?

Do I require sleeps and checks to safeguard modification time or lag in my code after running official functions? Or do all official functions have the appropriate checks and sleeps in place and will never fail?

E.g. If I save a screenshot and open the same image - File doesn't exist
E.g. If I create a directory and access it.
E.g. If I move a file and try to access it in the old/new location.

I have always use sleeps after such commands to protect me from any lag issues. It would be nice to know if that's actually required or not.

Link to comment
Share on other sites

you can include  your  udf function file  with

#include  "path file udf.au3"

the function  usually never fail

31 minutes ago, IAMK said:

E.g. If I save a screenshot and open the same image - File doesn't exist

probably because is in memory after you can save it and store it

if  you have  a decent computer  and  clean  , you can't use sleep 

Link to comment
Share on other sites

@faustf Sorry, by - File doesn't exist I meant that as an example of what could be an issue.
As for #include "name.au3", I use those for the ones I make.

Also, what do you mean by I can't use sleep? It's bad to use sleep if I have a good computer?

Link to comment
Share on other sites

i never use sleep  usually only use  when automate something  app.

file dosent exist is not example , if you have some trouble with script  use tag script and  send it  the  community will be  happy to resolve it .

include  you must use usually at the top of script  one  time , if you have your personal udf  the same procedure more or less

 

Link to comment
Share on other sites

  • Moderators

@IAMK Because you could spend a year trying to decipher what faustf says and make any sense of it, in plain English - you need to post the code you're working with, with a detailed description of what you are trying to accomplish, what problem you are experiencing, and what you have tried on your own to resolve it. You have been around long enough this should be second nature to you by now, but see the link in my signature for all of the information we need from you in order to properly assist.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@IAMK

Not every function has a built-in sleep, both those from "built-in" includes and UDFs ones. (GUIGetMsg() has its own Sleep()).

The "topic" of what you are talking about is objective...

You could have a benefit adding a Sleep() after calling a function, as well as removing it.

Remember that computers execute scripts in terms of milliseconds (or even less), so, it always depends from what do you expect from your script :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Any file you include can be reviewed.   if you have scite, you can put your cursor on the include, and jump to the file.   same for the functions.  I'd bet that you aren't doing error handling, and they are returning false or errors, but I don't know what functions you are using.  the included files you identified are found in a directory where you installed autoit

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

@JLogan3o13 There is no issue with my code (as of now), hence why it's not posted. It was just a general question. If you want a simple example of what I am asking, You can refer to this:

#include <ScreenCapture.au3>
DirCreate("Folder")
_ScreenCapture_Capture("Folder\1.jpg")
FileMove("Folder\1.jpg", "Folder\2.jpg")

;If I dont know how the functions above work, nor if they are foolproof, so I end up putting my own sleeps/checks, e.g.:

DirCreate("Folder1")
While(Not(FileExists("Folder1")))
    Sleep(10)
Wend

_ScreenCapture_Capture("Folder1\1.jpg")
Sleep(1000)

FileMove("Folder1\1.jpg", "Folder1\2.jpg")

Screencapture works because the dircreate function waits until the creation is done or is really fast.
Dirmove works because the screencapture functions waits until the image is properly saved or is really fast.
I put my own checks which might be redundant, like how I used to use _IELoadWait() after _IENavigate(), before looking into the function and finding out that the default value of the optional parameter already calls its own _IELoadWait(). Does this make sense?

 

@jdelaney Thanks! I never knew that. I have scite-lite so I don't have that feature, but that is something I want. When I run "SciTE", it brings up "SciTE-Lite". I tried downloading SciTE again, but it looks even worse than the Lite version. p.s. this is what my editor looks like (Lite):image.png.60633341c80d4ac81853029974d3bd71.png

Edited by IAMK
removed ' from don't to make code look nicer
Link to comment
Share on other sites

AutoIt is single-threaded. The interpreter is pretty simple: it parses one line of code, executes it and then goes back to your script. It does not "dispatch" actions that later you have to keep polling to say whether it's done or not, and also does not use an event-driven approach (it is not like Javascript). The native functions and bundle UDF (includes) wait until the action has been done before returning.

A few exception are mentionable: SoundPlay (with $SOUND_NOWAIT as second argument) and InetGet (with $INET_DOWNLOADBACKGROUND as forth argument). These flags make the function execution to go to background and continues executing your script (you have to poll it to know if it is finished). Under the UDFs, few exception are mainly on IE.au3, although I'm writing this with what I remember from my mind.

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

So it seems like the real question is about sleep, not about includes.

You should use sleep inside a while loop to prevent cpu working overtime.

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...