Miloud

Get contents_of_a_file (and its path) associated with an_application_built_with_autoIt

4 posts in this topic

#1 ·  Posted

Hi,

I have associated a file extension "tcr" with my application using this script which I found on stackOverFlow

FileExtAssoc("tcr", "C:\Users\HP\Desktop\crypt\cryptIt.exe")

func FileExtAssoc($sExt, $sApplication)
    RunWait(@COMSPEC & " /c ASSOC ." & $sExt & "=ExTest", "", @SW_HIDE)
    RunWait(@COMSPEC & " /c FTYPE ExTest=" & $sApplication , "", @SW_HIDE)
    MsgBox(0,"File Extension Application Association",'"' & $sExt & '"is now asscoiated with "' & $sApplication & '"',3)
EndFunc

on my application:

#include <Array.au3>
#include <WinAPIShPath.au3>

; An alternative to the limitation of $CmdLine[] only being able to return a maximum of 63 parameters.
Local $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw)
_ArrayDisplay($aCmdLine)

$t=""
For $i=1 To $CmdLine[0]
   $t &=$CmdLine[$i] &@CRLF
Next


ClipPut($t)

I want to get the path after running  "myfile.tcr".

Using the above script, it's possible if I drag the mouse over the file "myfile.tcr" and drop it on my my application... I want that to happen when I double click.

Any suggestions please!

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

Thank to: https://commandwindows.com/assoc.htm

The solution is to add " %1" to the 5th line of the association script:

FileExtAssoc("tcr0", "C:\Users\HP\Desktop\crypt\cryptIt.exe")

Func FileExtAssoc($sExt, $sApplication)
    RunWait(@COMSPEC & " /c ASSOC ." & $sExt & "=ExTest", "", @SW_HIDE)
    RunWait(@COMSPEC & " /c FTYPE ExTest=" & $sApplication &  ' "%1"', "", @SW_HIDE)
    MsgBox(0,"File Extension Application Association",'"' & $sExt & '"is now asscoiated with "' & $sApplication & '"',3)
EndFunc

 

Edited by Miloud
Ammending the code I provided
1 person likes this

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