ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

AHK Help

(1/3) > >>

wraith808:
I need a little utility program to automate use of some third party software, so I thought this was the perfect time to learn a little AutoHotKey.  But, I'm running into a bit of a problem.  Can someone tell me where I'm going wrong with the following snippet?  Using the latest AHK downloaded from the AHK site.


--- Code: AutoIt ---; Variables_InputDirectory := "\\snlwebtool3\apps\TranslationRepository_test\"_OutputDirectory := "\\snlwebtool3\apps\TranslationRepository\Incoming"_PDFConverterPath := ProgramFiles . "\AnyBizSoft\PDFConverter\PDFConverter.exe" ; Script StartFileSelectFile % _SourceFileName, 3, _InputDirectory, "Select the file to be converted.", "Adobe PDF (*.pdf)"
I get the following error:
C:\Dev\.NET20\Document System\SNL.DocumentTranslationService\Scripts\PDFConverter.ahk (21) : ==> This parameter contains a variable name missing its ending percent sign.
     Specifically: % _SourceFileName

It works if I take the % out, but then it's not using the values of the variables, but the variable names.

Thoughts?

Target:
Wraith

i think the correct syntax is

    FileSelectFile, %_SourceFileName%, 3,%_InputDirectory%, Select the file to be converted, Adobe PDF (*.pdf)

you were getting an error because you 'opened' a variable with your first % but didn't close it (at least that's how AHK see's it)

Also note that it's not necessary (in this case) to enclose your text values   

lanux128:
what Target said but the line should be like this:


--- ---      FileSelectFile _SourceFileName, 3, %_InputDirectory%, "Select the file to be converted.", "Adobe PDF (*.pdf)"

the OutputVar (i.e. SourceFileName) need not be quoted..

wraith808:
I was trying to use expression format, i.e. (from the documentation)

By contrast, the expression method omits the percent signs around variable names, but encloses literal strings in quotes. Thus, the following are the expression equivalents of the previous examples:


--- Code: AutoIt ---MsgBox % "The value in the variable named Var is " . Var . "."  ; A period is used to concatenate (join) two strings.CopyOfVar := Var
--- End quote ---

I already changed it to the manner which you gave after seeing it would work, and getting around my need for expressions in that case.  But why didn't using the expression method work?

skwire:

--- Code: AutoIt ---FileSelectFile % _SourceFileName, 3, _InputDirectory, "Select the file to be converted.", "Adobe PDF (*.pdf)" ; Your original             ; -----------------             ; This is the NAME of the variable to STORE the output path in.             ; You don't use "%" at all for this since you're simply             ; declaring the name of the variable. FileSelectFile % _SourceFileName, 3, _InputDirectory, "Select the file to be converted.", "Adobe PDF (*.pdf)" ; Your original                                   ; ---------------                                   ; This is where you want to use the CONTENTS of a variable so this is where                                   ; you should use "% _InputDirectory" or "%_InputDirectory%" (minus quotes). FileSelectFile _SourceFileName, 3, % _InputDirectory, "Select the file to be converted.", "Adobe PDF (*.pdf)" ; One correct way.FileSelectFile _SourceFileName, 3, %_InputDirectory%, "Select the file to be converted.", "Adobe PDF (*.pdf)" ; Another correct way.                                        
Does that help to explain things?

Navigation

[0] Message Index

[#] Next page

Go to full version