bositroll Posted February 16, 2014 Share Posted February 16, 2014 (edited) Hello everybody, I wrote a script and now I want to make an exe of that script. The problem I'm having is that I use the imagesearch file/library. So my script consists of the following files: * theacutalscript.au3 *ImageSearch.au3 *ImageSearchDLL.dll *theImageToSearch.bmp I was wondering if it is possible to make a single exe file out of these 4 files. Thanks in advance To make thing simple, imagine that my main script looks like this: #Include <ImageSearch.au3> Func startProgram() Local $X=0 Local $Y=0 Local $Search=_ImageSearch("theProgramIcon.bmp",1,$X,$Y,100) if $Search Then MouseMove ($X,$Y,10) Sleep(500) MouseClick("left") EndIf EndFunc startProgram() Edited February 16, 2014 by bositroll Link to comment Share on other sites More sharing options...
Jonniy Posted February 16, 2014 Share Posted February 16, 2014 Look at FileInstall() Thanks for your help & have a good day. Yours sincerely, -Jonniy- Link to comment Share on other sites More sharing options...
bositroll Posted February 16, 2014 Author Share Posted February 16, 2014 Will it work then if I copy the executable and run it on another computer? Link to comment Share on other sites More sharing options...
Jonniy Posted February 16, 2014 Share Posted February 16, 2014 (edited) Yes, if you look at the helpfile it says "The FileInstall() function is designed to include files into a compiled AutoIt script. These included files can then be "extracted" during execution of the compiled script if the statement is executed. Keep in mind that files such as images can greatly increase the size of a compiled script." Then of course you have to set the paths to the fileinstall'ed paths Edited February 16, 2014 by Jonniy Thanks for your help & have a good day. Yours sincerely, -Jonniy- Link to comment Share on other sites More sharing options...
bositroll Posted February 16, 2014 Author Share Posted February 16, 2014 (edited) First of all thank you for your help, I'm trying to put the image in appdata. it works, it is there. I have the following code: #Include <ImageSearch.au3> DirCreate(@AppDataDir & "\MyProgram") DirCreate(@AppDataDir & "\MyProgram\images\") FileInstall(@DesktopDir & "\oldLook\ccleaner.bmp",@AppDataDir & "\MyProgram\images\") Func OpenCCleaner() Local $X=0 Local $Y=0 Local $Search=_ImageSearch(@AppDataDir & "\MyProgram\images\ccleaner.bmp",1,$X,$Y,10) if $Search Then MouseMove ($X,$Y,10) Sleep(500) MouseClick("left") EndIf EndFunc OpenCCleaner() It put's the image to a folder in appdata and the script runs fine when I open it with scite and press F5. But when I right click the au3 file and click "compile script (x86)" it says "Invalid FileInstall() function". What am I doing wrong? Edited February 16, 2014 by bositroll Link to comment Share on other sites More sharing options...
Jonniy Posted February 16, 2014 Share Posted February 16, 2014 You have to specify the destination file, so: FileInstall(@DesktopDir & "\oldLook\ccleaner.bmp",@AppDataDir & "\MyProgram\images\ccleaner.bmp") Thanks for your help & have a good day. Yours sincerely, -Jonniy- Link to comment Share on other sites More sharing options...
bositroll Posted February 16, 2014 Author Share Posted February 16, 2014 (edited) The problem why it doesn't want to compile is because I used @AppDataDir and @DesktopDir inside FileInstall. An dautoIt can' t handle that. So I rewrote the code with absolute paths and now I can compile it. But I installed all the files in c:Myprogram. Is it still possible to install these files in apddata? C:UsersUSERNAMEAppDataRoaming I can't use absolute path here becuase every computer has anothet username of course and not all windows installations are on disk C. Does anybody know if I still can store it in appdata? Edited February 16, 2014 by bositroll Link to comment Share on other sites More sharing options...
JohnOne Posted February 16, 2014 Share Posted February 16, 2014 Does the source path not have to be a literal string? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
bositroll Posted February 16, 2014 Author Share Posted February 16, 2014 (edited) Jep that's what I've done. See post above your post. But I still want to store it in appdata. But I don't know how But I still don't understand. I create the executable. Delete the image/ImageSearch.au3 and the ImageSearchDLL.dll but then it starts complaining when I run my exe file that it didn't find these files -.- . What is the point to use fileInstall if I still have to include all these files in the folder. I just want one single exe file and that's it. So this is my code: #Include <C:\MyProgram\ImageSearch.au3> DirCreate("C:\MyProgram") DirCreate("C:\MyProgram\images\") FileInstall("C:\Users\name\Desktop\oldLook\ccleaner.bmp","C:\MyProgram\images\ccleaner.bmp") FileInstall("C:\Users\name\Desktop\oldLook\ImageSearch.au3","C:\MyProgram\ImageSearch.au3") FileInstall("C:\Users\name\Desktop\oldLook\ImageSearchDLL.dll","C:\MyProgram\ImageSearchDLL.dll") Func OpenCCleaner() Local $X=0 Local $Y=0 Local $Search=_ImageSearch("C:\MyProgram\images\ccleaner.bmp",1,$X,$Y,10) if $Search Then MouseMove ($X,$Y,10) Sleep(500) MouseClick("left") EndIf EndFunc OpenCCleaner() I compile it to an .exe file. I delete ccleaner.bmp, ImageSearch.au3 and ImageSearchDLL.dll. Then I try to run the exe and it says that on line 7 the file is missing... But isn't that file inside the exe? Because if the files still have to be in the folder of the exe... there is really no difference with before Edited February 16, 2014 by bositroll Link to comment Share on other sites More sharing options...
JohnOne Posted February 16, 2014 Share Posted February 16, 2014 It only has to be absolute source because it's being compiled on your machine, and you know the path. The destination can be variable. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
bositroll Posted February 16, 2014 Author Share Posted February 16, 2014 (edited) ow okay, thank you will try that. EDIT: I have two problems left. The first one: I don't know how I can point to imageSearch.au3 in the include so it will work on every computer. I can use absolute path for my computer, but that isn't a solution of course. #Include @AppDataDir & "MyProgramImageSearch.au3" Didn't work. My second problem is: WhenI run the program for the first time. It tries to run the #Include first. Before the FileInstalls are being executed. Leading to an "no such file found" error. Because the MyFolder folder isn't created yet. Does anybody know a fix for any of these problems? Thanks in advance EDIT2: I solved the two problems above by copy pasting the code from the ImageSearch.au3 file to my script file. So I no longer had to include a file. Edited February 16, 2014 by bositroll Link to comment Share on other sites More sharing options...
BrewManNH Posted February 16, 2014 Share Posted February 16, 2014 Don't FileInstall the #includes, once the script is compiled those include lines aren't used any longer. Just use FileInstall on the files that are going to be used with the compiled script, the .bmp and .dll files are the only ones that need it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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