Jump to content
Sign in to follow this  
gregor202

"open with" $CmdLine[1] parameter (Drag&Drop File)

Recommended Posts

gregor202

I want to open a file (file.link) with another program (the compiled au3 script), just by Drag&Drop it on the *.exe . Then I want to open a configuration file (config.ini) and use the there stored parameters to process with the file.link.

So if I drag and drop the file and use the following code:

MsgBox(0, "parameter", $CmdLine[1])

I get back: "c:/scriptfile/file.link" This is ok.

BUT if later in the script, I try to open the configurationfile (config.ini) using the code:

$config_file = "config.ini"
$program_file   = IniRead($config_file, "config", "program", "no_data")
MsgBox(0, "file", $program_file)

I get back "no_data" , This is NOT OK.

> If I don't use Drag&Drop (And define the file.link manually), I get the correct parameter.

How do I get it working???

Thanks in Advance!

Gregor

Share this post


Link to post
Share on other sites
Authenticity

Just a side note, you should first check if $CmdLine[0] is greater than 0 or you're going to get a hard crash if you'll try to access a non-existing subscript. ;]

The reason why the return value is "no_data" can be a few things. Maybe the file could not be found, the section doesn't exist or the key-name doesn't exist. Don't rely on the current working directory to open a file. Either specify a fixed path like "C:\Temp\config.ini" or if the file should be in the current directory the executable is running from - @ScriptDir & '\config.ini'.

Share this post


Link to post
Share on other sites
ProgAndy

I think, the drag-drop changes your workin-dir. Try to soecify a full path for your ini.

(@ScriptDir & \config.ini")


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
gregor202

Ok, I will test this...

Here are the files/code I am using currently:

; open with

$config_file = "config.ini"

;this was used to create the config file:
;IniWrite($config_file, "config", "program", "c:/test/test.exe")

;to watch the parameter
MsgBox(0, "parameter", $CmdLine[1])

$program_file   = IniRead($config_file, "config", "program", "no_data")

MsgBox(0, "file", $program_file)
;here I everey time get "no_data" but I should get "c:/test/test.exe"

MsgBox(0, "file", "finish")

config.ini

[config]
program=c:/test/test.exe

file.link

[part]
identification=21A123

Share this post


Link to post
Share on other sites
gregor202

Yes, he changes the script directory!!!

I just changed the code:

$config_file = @ScriptDir & "\config.ini"

and now it works!!!

Thank you a lot for your fast help!!!!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.