Jump to content

#include (adding diff .au3 into gui)


Recommended Posts

hi again im here with a different topic

umm i cant figure out how to do this :

this is example dont mind all code :)

$gui = guicreate("")
$button = guictrlcreatebutton("", xx,xx,xx,xx)

while 1
switch guigetmsg()
case $button
#include <my other file.au3>
endswitch
wend

so when pressing button... the #include file would create an input box or something in this current $gui not in the other file... :)

i dont know how else to explain ... i tryed this #include thing few ways but everytime i just get error at that line

Link to comment
Share on other sites

case $button
#include <my other file.au3>
endswitch

I made this same mistake before. You can't put an #include statement within a block statment (case, func, if-then, etc...), and there is no way to do a conditional #include.

All #include statements will be replaced by the contents of the include file BEFORE any code is executed.

Edited by willichan
Link to comment
Share on other sites

You put the code that creates the inputbox (or Whatever) in a function in the include file. The include file should have the line #Include-Once at the top of it.

Now you move that #Include line to the top of the script. If it's a local file and not one in your AutoIt\Include\ folder then use the Quote method.

#Include "<path>\my other file.au3"

Where you now have the #Include<my other file.au3> line, replace it with a function call to bring up the inputbox.

EDIT: I should have mentioned that #Include is a pre-processor directive so you can't call it in a loop like you did.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Move the #include line to the top of the script. When the script is started the file is included. AutoIt does not support conditional includes.

In your case statement you have to call a function thas is included with <my other file.au3>

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

hmm i tryed with calling func

and put in func the #include but not working at all :)

maybe i understood u wrong :)

but isnt there anyway to do sumtin like that?

coz i want like when u press button then add into the $gui an edit box or inputbox or anything :P

Link to comment
Share on other sites

You DO NOT put the #Include in the Include file

You DO NOT use #Include in a loop.

#Include is a pre-processor directive and the file must only be #Included once, preferably at the top of the script.

Your include file can be as simple as this.

#Include-Once
Func _Run_InputBox()
   Local $sStr = InputBox("My Input Box", "Enter whatever you want")
   Return ($sStr)
EndFunc

Then Call the FUNCTION in the loop, NOT the file.

#Include "C:\Some\Folder\my other file.au3"
$gui = guicreate("")
$button = guictrlcreatebutton("", xx,xx,xx,xx)

While 1
   Switch guigetmsg()
       Case $button
           $s_Rtn = _Run_InputBox()
           MsgBox(4096, "Result", $s_Rtn)
   EndSwitch
WEnd

All clear now?

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...