Sign in to follow this  
Followers 0
d3v3lop3r

How call a Exe from AutoItv3 with Delphi?

4 posts in this topic

Hi, I'm trying call a program copiled by AutoItV3 (a exe file) with delphi, but when I do it, the script don't work.

If I execute a exe direct without delphi, it work normal, but when I try call it with delphi using

[Delphi CODE]-----------------------------------------------------------------------------------------------

WinExec(Pchar('cmd /c "' + LocalPath+'bin\MyProgram.exe"'),SW_ShowNormal);

or

WinExec(Pchar(LocalPath+'bin\MyProgram.exe'),SW_ShowNormal);

or

shellexecute(handle, 'open', Pchar(LocalPath+'bin\MyProgram.exe'), '', nil, sw_shownormal);

----------------------------------------------------------------------------------------------------------------

the program is executed, but the hotkey's don't execute nothing

if I press F9 to it execute a function, it don't do nothing

Someone can help?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Are you absolutely sure that the script runs?

I don't know what's in your LocalPath var, but this LocalPath+'bin\MyProgram.exe', shouldn't that be LocalPath+'\bin\MyProgram.exe' by any chance? (Note the backslash between the LocalPath and the Bin\MyProgram.exe.) Most path variables do not have the \ appended automatically, so if this is read from a system var, this might be the case.

Also make sure that your delphi system does not catch hotkeys itself; this might interfere?

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Yes, Im absolutely sure that the script run!

U can test it, and don't need delphi

If u have a script with hotkey seted, try call it using

--------It Don't Work-----------------

Menu Windows -> Execute

so type cmd /c "Dir_of_ur_programa\Name_of_ur_programa.exe"

After it ur program will be open, but if u press key of hotkey seted before, it don't do nothing

--------It Don't Work-----------------

Menu Windows -> Execute

so type cmd [Enter]

so type "Dir_of_ur_programa\Name_of_ur_programa.exe"

After it ur program will be open, but if u press key of hotkey seted before, it don't do nothing

--------It Work-----------------

Menu Windows -> Execute

so type cmd [enter]

type cd "Dir_of_ur_program"

type "name_of_ur_program.exe"

About LocalPath+'bin\MyProgram.exe' to LocalPath+'\bin\MyProgram.exe'

My LocalPath have '\' in end

LocalPath = 'c:\source\'

But my problem not is program don't run, it run, but hotkey's dont work

Thanks for reply SadBunny

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Now I know what happened, My program have a config file, this file set what it will do in hotkey, this file are in same directory of my EXE(AutoIt Script) so I use

$CONFILE=FILEOpen("config.dat", 0)

to open de file, but How I'm calling the EXE(AutoIT Script) from another directory, it try open file of config of directory of my delphi program...

[structure]

c:\source\

+------MyProgram.exe(Delphi)

+------bin\

+------+------MyScript.exe(AutoIT v3 Program)

+------+------config.dat

But how I'm calling a program MyScript.exe with my MyProgram.exe in directory source, it execute the program and back to directory current of my application delphi, so when the MyScript.exe execute de line to open file of config it no found it, because program, no is executed in directory it are saved, but in directory it is called.

So I like two solutions

1ª Move file of configuration to directory Source

c:\source\

+------MyProgram.exe(Delphi)

+------config.dat

+------bin\

+------+------MyScript.exe(AutoIT v3 Program)

2ª Change this code

of

$CONFILE=FILEOpen("config.dat", 0)

to

$CONFILE=FILEOpen("bin\config.dat", 0)

Thanks for help :whistle:

Problem has resolved, I'm using the first option

I'm preffer the first option because, I dont like a file of config, in directory bin

Edited by d3v3lop3r

Share this post


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
Sign in to follow this  
Followers 0