 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Belial
Joined: 26 Jun 2005 Posts: 40 Location: Portugal
|
Posted: Fri Jul 15, 2005 11:50 pm Post subject: AHK Script to read a new format.. How!!? |
|
|
Imagin I create a format ".hello" for example, and when a format .hello is executed it executes an AHK script [I know how to associate the format to the program, the problem is..], how does the program know what file was executed to execute the AHK script ?!
The idea is, the .hello files will have variables [like a INI file], and the AHK script should read the vars of that file.
[I know how to read the vars from the file, I just want to know how does the script can discover what file were used to execute it [the .hello file]]
::::::::::
When you have .JPG files associated to MS Paint, when I double click the JPG it opens the file with Paint.. and it's exactly this that I want to happen when I execute a .hello file =)
[I hope you ppl understood what I want ^^;;] _________________ Belial |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Sat Jul 16, 2005 9:12 am Post subject: |
|
|
Hi,
I never tried this. But you might want to capture the command line parameters that are given to the associated ahk script when you double click that .hello file.
Please have a look at the manual:
"Passing Command Line Parameters to a Script " _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Belial
Joined: 26 Jun 2005 Posts: 40 Location: Portugal
|
Posted: Sat Jul 16, 2005 1:07 pm Post subject: |
|
|
From AHK's Tutorial:
| Quote: | Passing Command Line Parameters to a Script
Scripts support command line parameters. The format is:
AutoHotkey.exe [Switches] [Script Filename] [Script Parameters]
And for compiled scripts, the format is:
CompiledScript.exe [Switches] [Script Parameters]
Switches can be zero or more of the following:
/f or /force -- Launch unconditionally, skipping any warning dialogs.
/r or /restart -- Indicate that the script is being restarted (this is also used by the Reload command, internally).
/ErrorStdOut -- Send syntax errors to stdout rather than displaying a dialog. See #ErrorStdOut for details.
Script Filename can be omitted if there are no Script Parameters. If omitted, it will run (or prompt you to create) AutoHotkey.ini in the current working directory.
Script Parameters can be any strings you want to pass into the script (but any string that contains spaces must be enclosed in double quotes). The script sees incoming parameters as the variables %1%, %2%, and so on. In addition, %0% contains the number of parameters passed (0 if none).
If the number of parameters passed into a script varies (perhaps due to the user dragging and dropping a set of files onto a compiled script), the following example can be used to extract them one by one:
Loop, %0% ; For each parameter:
{
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
MsgBox, 4,, Parameter number %A_Index% is %param%. Continue?
IfMsgBox, No
break
}If the parameters are file names, the following example can be used to convert them to their case-corrected long names (as stored in the file system), including complete/absolute path. [requires v1.0.25.14+]
Loop %0% ; For each parameter (or file dropped onto a script):
{
GivenPath := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
Loop %GivenPath%
LongPath = %A_LoopFileLongPath%
MsgBox The case-corrected long path name of file`n%GivenPath%`nis:`n%LongPath%
} |
This is interesting and useful. However, I know how to give parameters on "links" [.lnk], but on one other format I have no Idea how it is done [if it is even possible].
Defining a Parameter with the name of the file [the .hello] that was executed, it would end up my problem.
Any ideia how to give the parameter?!
[When u double click a .AHK file u are executing AutoHotkey.exe who reads the .AHK ... in this example .. how does the AutoHotkey.exe knows what .AHK was needed to read ?!] _________________ Belial |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Sat Jul 16, 2005 1:20 pm Post subject: |
|
|
I created a file "test.hello"
and I created a script "test.ahk" with the following content
I compiled the test.ahk to a file test.exe.
Then I linked the *.hello file to be opened with the test.exe file.
When I doubleclicked on the *.hello file a message box came up with
| Quote: | ---------------------------
test.exe
---------------------------
1
C:\Path\test.hello
---------------------------
OK
---------------------------
|
So, you see, the exe got the path and filename when the .hello file gets doubleclicked. :)) _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Belial
Joined: 26 Jun 2005 Posts: 40 Location: Portugal
|
Posted: Mon Jul 18, 2005 1:15 am Post subject: |
|
|
THANK YOU ^^
It was very simple after all, thanks a lot for your help =P _________________ Belial |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|