AutoHotkey Community

It is currently May 27th, 2012, 7:20 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: October 17th, 2004, 4:07 pm 
Offline

Joined: October 5th, 2004, 5:03 pm
Posts: 121
Location: Brasília, Brazil
Hi,

I'd like to know how to associate an extension (*.anc) to my program create with AHK. Would anybody have a tip?

Thanks,
Lingoist.


Last edited by lingoist on November 4th, 2005, 11:42 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2004, 4:55 pm 
Create the file with that ext.
Execute that file. You'll be asked which app should open that type of file.
Assign eg. Notepad/Notepad2/UltraEdit/or any other editor to it.
Select "Always use this ..." & save that setting.
Open Explorer/Tools/Folder Options/File Types and select the *.anc entry from the list. Click "Advanced". Here you can do any specific changes regarding your new file type. If you need any details on HowTo do that, have a lock at AutoHotkey's settings (*.ahk).

Compile
edit
open
run

Or use: File Type Manager [Freeware] which has been recommended here [more...]

8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2004, 11:33 pm 
Offline

Joined: October 5th, 2004, 5:03 pm
Posts: 121
Location: Brasília, Brazil
I got it, but would you know how to do this with a script in AHK?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2004, 11:50 pm 
Offline

Joined: April 1st, 2004, 12:00 am
Posts: 87
Location: Philippines
I'm guessing that it would require you to manipulate a few registry entries. That could be dangerous, so back-up your registry first. You may want to study up on the subject (where else..) to know more. I haven't done much registry editing so I really can't provide you with more info than this.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2004, 2:17 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
The below might be of interest because it can convert an existing registry key (such as a subkey of your choice in HKEY_CLASSES_ROOT) to a working script that is capable of recreating that key. You could then modify that script to create a new file association of your own.

http://www.autohotkey.com/forum/viewtopic.php?t=139


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2004, 4:32 pm 
Offline

Joined: August 23rd, 2004, 10:06 pm
Posts: 276
Location: East Bay, California USA
i use this myself:
Code:
#A::
  clipboard =
  send, ^c
  clipwait, 100
  splitpath, clipboard, , , extension
  if extension = ahk
    run, "C:\Temp\AutoHotkey\AutoHotkey.exe" "%clipboard%"
Return

This will Make WinKey+A run what ever script you have highlighted. Works well for me, you will have to change the Path for your AHK program file. I use this for some of my users systems that they do not have full Admin rights to install or run programs locally on their computer.
:D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 2:14 pm 
Offline

Joined: October 5th, 2004, 5:03 pm
Posts: 121
Location: Brasília, Brazil
I'm trying to understand some comands to execute a file, but I don't understand %1 etc after the nome of the program. Could anybody help me? In AutoHotKey, the commands (actions) are:

C:\Arquivos de programas\AutoHotkey\AutoHotkey.exe "%l" %2 %3 %4 %5 %6 %7 %8 %9
Lingoist.


Last edited by lingoist on November 4th, 2005, 11:42 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 2:58 pm 
These are indexed parameters. Like in the BATCH world the first parameter %0% contains the total number of parameters used with an app, %1% the content of the first parameter, %2% the content of the second one, %3% the content ...

1) compile this code to an exe

Code:
MsgBox, Number of params used: %0%`n1. param: %1%`n2. param: %2%3. param: %3%4. param: %4%5. param: %5%6. param: %6%7. param: %7%8. param: %8%9. param: %9%


2) start the exe this way from the command line

My.exe A B C D E F G H I

3) you should get a MsgBox displaying:

Number of params used: 9
1. param: A
2. param: B
3. param: C
4. param: D
5. param: E
6. param: F
7. param: G
8. param: H
9. param: I


This way you're able to transfer a value/variable to a compiled executable.

8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 3:08 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Although I'm a little uncertain about the diffence between "%l" and "%1", the others pass any parameters given to the file as args for the program. I think this only applies when launching the script directly, such as by making a shortcut to it and passing in some args. For example, you could create a shortcut with this in its "target" field:

C:\MyScript.ahk arg1 arg2

The script would receive arg1 and arg2 as it's first two args. The above avoids the need to specify C:\Program Files\... etc. However, it seems that double quotes around args does not work to preserve spaces. If anyone knows a way to improve the registry entry to support args with spaces, please let me know.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 5:11 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
An easy way to do this from a script:

(Not tested)

Code:
Run, %comspec% /k ftype ancfile="C:\Arquivos de programas\AutoHotkey\AutoHotkey.exe" "%l" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"

Run, %comspec% /k assoc .anc=ancfile


Correct me if I'm wrong, but isn't there a %$ parameter in file associations that represents all the parameters?
I thought it safer to put quotes around all the parameters, just to be safe.
If %comspec% doesn't seem to work, replace it with cmd.

I use this method to fix the associations of my file types all the time, especially after textpad, crimson editor, and ultraedit competely screwed them up :(.

It's a lot safer than mucking about in the registry.

Come to think of it, I'm pretty sure that you only need %1 in there because when you run multiple files at once they each call the command, so it only receives on parameter at a time.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 6:48 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
Correct me if I'm wrong, but isn't there a %$ parameter in file associations that represents all the parameters?
I thought it safer to put quotes around all the parameters, just to be safe.
Thanks, I'll look into that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2004, 4:14 am 
Offline

Joined: October 5th, 2004, 5:03 pm
Posts: 121
Location: Brasília, Brazil
I've partly suceeded in doing it:

My ANC files are based on IniRead/IniWrite functions.
This is a simplified scritp of my program:

Code:
#SingleInstance FORCE
SetWorkingDir, %A_ScriptDir%

;IT SETS PARAMETERS
   param_n=%0% ;how many parameters exist when you run in DOS-prompt: C:\MyFolder\Associate.exe first second third etcetera
   
   param_1=%1% ;the first parameter: first (windows associates automatically to the first parameter)
   param_2=%2% ;the second one: second
   param_3=%3% ;the third one: third
   param_4=%4% ;the forth one: etcetera

;STARTS GUI
   Gui, add, edit,
   Gui, add, edit,
   Gui, add, button, Default, Close
   Gui, add, button,, New
   Gui, add, button,, Save as
   Gui, add, button,, Open
   Gui, Show

;TEST PARAMETERS: IF DIFFERENT FROM 0, OPENS THE PARAMETER (FILE)
   If param_n > 0
      {
      ; There is a parameter
      ;file_name is set by the parameter
            
      StringReplace, param_1, param_1, .anc,, all

      SplitPath, param_1, param_1_file
      
      msgbox, param_1: %param_1%.anc
      msgbox, param_1: %param_1_file%.anc
      
      IniRead, value_box1, %param_1_file%.anc, etc, box1
      IniRead, value_box2, %param_1_file%.anc, etc, box2
      ControlSetText, Edit1, %value_box1%
      ControlSetText, Edit2, %value_box2%
      }

Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;action of button close
   ButtonClose:
   GuiClose:
   ExitApp

;action of button new
   ButtonNew:
   ControlSetText, Edit1,
   ControlSetText, Edit2,
   Return

;action of button save as
   ButtonSaveas:
   ;SAVE AS BOX
   FileSelectFile, file_name, 16,, Save as - ANC file, ANC File (*.anc)
      if file_name=
         MsgBox, The user pressed cancel.


   ControlGetText, box1_content, Edit1
   ControlGetText, box2_content, Edit2
   IniWrite, %box1_content%, %file_name%.anc, etc, box1
   IniWrite, %box2_content%, %file_name%.anc, etc, box2
   Return


;action of button open

ButtonOpen:
   ;OPEN FILE BOX
   ;file_name is set by the user
   FileSelectFile, file_name, 3,, Open  - ANC file, ANC File (*.anc)
      if file_name=
         MsgBox, The user pressed cancel.
   
   StringReplace, file_name, file_name, .anc,, all

   IniRead, value_box1, %file_name%.anc, etc, box1
   IniRead, value_box2, %file_name%.anc, etc, box2
   ControlSetText, Edit1, %value_box1%
   ControlSetText, Edit2, %value_box2%
Return





You'll have your file open when you associate it in Windows Explorer. I still do not know how to do it through Registry and all that stuff.

Special Thanks to Bobo and Chris, (By the way, Bobo in my country means moron!! Sorry...)

Lingoist


Last edited by lingoist on November 4th, 2005, 11:43 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2004, 7:57 am 
Quote:
Bobo in my country means moron!! Sorry...)


I love it. :lol: Check this out: [Here] Btw. I hate his music :twisted:

8)
What's your country ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2004, 9:42 am 
Offline

Joined: April 1st, 2004, 12:00 am
Posts: 87
Location: Philippines
Whoa... he's probably from the philippines. If not, well, bobo means something like stupid here too. Don't worry, I don't think so. :wink:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group