Jump to content

[UNSOLVED] #include in IF conditionally run statement

Recommended Posts

  • Moderators


AutoIt runs all directives (such as #include) before running the code, so the file is always included.

Can you explain in more detail why you need to conditionally include this file? Then we might be able to offer some sensible workarounds.


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to post
Share on other sites

First of all, hi Melba23. You always give nice and practical help to people arround here so thank you for that.

I made a search GUI which is not piece of art for sure but it works for me. Since I do not code for a living (i would be already starve to death if I did) my scripts are very basic ones. And I have a problem when I am reading my old scripts because code is clattered...  Anyway I made just a gui for search (but now I am using it also to get lines of text in clipboard for furthure use when I write something.


Idea was to separate part of code which will be standard GUI with buttons and everything from a code which would be connected to a search and which i could easily change since the idea was 1 search - 1 file with code. So... 


Func z001()
#include <search\001\001.au3>
Func z002()
#include <search\002\002.au3>
Func z003()
#include <search\003\003.au3>
Func z004()
#include <search\004\004.au3>
Func z005()
#include <search\005\005.au3>
Func z006()
#include <search\006\006.au3>
Func z007()
#include <search\007\007.au3>


Func z157()
#include <search\157\157.au3>
Func z158()
#include <search\158\158.au3>
Func z159()
#include <search\159\159.au3>
Func z160()
#include <search\160\160.au3>


Its very basic GUI with 160 buttons which will execute whatever is in a file...


I will give you an example for that:


www.youtube.com (less then 4min and date)

$iMenustate = GUICtrlRead($edit1) ; return the state of the menu item
$search=GUICtrlRead($edit1, $GUI_READ_EXTENDED)
$ssearch=StringSplit($search," ")
For $i = 1 To $ssearch[0]
ShellExecute('https://www.youtube.com/results?sp=CAISAhgBUBQ%253D&q=' & $searchadd & '')

second line is what will appear as a button name (between #cs and #cs) so i dont have to include that in main script also

it reads whatever is written in edit field in main script and then combine other data with it. Since other web pages have different search codes I did it like this so I can search one expression on many different pages with just a press of a button. "Space" is a splitter if there is more then one word to search and it is replaced by a "+" because it usually is like that (sometimes it could be a "&" character. Then it trimms a last char. In this case there is no need to add anything after the searching data part but sometimes there is site that demands some data after that so i should add that after

$searchadd & '')

Anyway I hope you know what am I doing in order to help me because I am not :)

Link to post
Share on other sites

Anyway...   I dont really need a help because my idea was to use separated small files for every search and not to cut and paste in main script whenever i want to change order of buttons or what buttons will do.  problem is that I always must have 160 files or script would brake. And all files must have same names... I have 001.au3 to 160.au3. If there is no need for a button function I would put a zero byte file (123.au3 for example). What do you think?

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By SergeiK
      Hello Everyone,
      Is it possible to get shorter multiple condition expressions avoiding operator OR? for instance If @OSVersion In (Win_10, Win_7, Win8) Then. I got used to it in t-sql. Thank you.
    • By TrashBoat
      How do i add a path to a file in Include.
      I want my script to get the udf in the same folder as the script/exe:
      Include "@ScriptDir/udf.au3" can this be done?
    • By chacoya121
      can anyone help me plz
      how can you put mouseclick in if statement or is it possible
      if Mouseclick = "left" then Tooltip(" you click left mouse") thank you
    • By ur
      I have recorded a gui installation and modified the au3 file as per my requirement.
      But the problem is, whenever I try to compile the au3 file, I am getting a special character on top of the file.

      Can you suggest how to resolve this as it is appearing everytime during compilation.
      And also I am trying to include a au3 file which is separate folder so I am adding the <..\Library.au3> line.
      It is able to pick that but in that file "Library.au3" there is a file install line.
      FileInstall(".\SendMail.ps1", @ScriptDir & "\SendMail.ps1") Library.au3 is being used by many other codes in the previous folder..
      But the current file is looking for the ps1 file in current folder.
      So is there any option to tell the compiler to pick the dependent files relative to Library.au3 instead of the current code.
    • By pedrit0
      Hi all.
      I have created an external au3 (a library of functions and vars) that is #included in a main script that i must compile.
      I wish that the content of the library is not merged with the main script when compiling.
      My goal is to keep the ability to modify the library even after the main exe is compiled and that these changes are effective when executing the exe.
      I guess this is not possible using the standard #include method.
      Is there a way to do that ?
      thx a lot :-)
  • Create New...