PhilipG Posted January 6, 2010 Share Posted January 6, 2010 If I associate a file extension with my program. How do I make the program know what to do when a file is started? Link to comment Share on other sites More sharing options...
Fire Posted January 6, 2010 Share Posted January 6, 2010 I think this will helps: assoc .dat=fakefile ftype fakefile="%programfiles%\AutoIt3\AutoIt3.exe" "%1" Use it with run() command and define your program (just replace : %programfiles%\AutoIt3\AutoIt3.exe In my example i use for assosiate .dat files with autoit. [size="5"] [/size] Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 6, 2010 Share Posted January 6, 2010 It just creates some registry entries. Like in: HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt If you put your script in there it will receive the file path as %1 on the command line, and for AutoIt that goes in the $CommandLine array (see help file). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PhilipG Posted January 6, 2010 Author Share Posted January 6, 2010 That's not really what I meant! I know how too associate the extensions with the program. My problem is that I don't know how too make my program understand what to do when the file is opened! Link to comment Share on other sites More sharing options...
James Posted January 6, 2010 Share Posted January 6, 2010 Func _FiletypeAssociation ($extension, $type, $program, $description = '') ; e.g. _FiletypeAssociation('.pdf', 'FoxitReader.Document', '"%ProgramFiles%\FoxitReader.exe" "%1"') $exitcode = RunWait(@ComSpec & ' /c ftype ' & $type & '=' & $program & _ ' && assoc ' & $extension & '=' & $type, '', @SW_HIDE) If $description And Not $exitcode Then Return RegWrite('HKCR' & $type , '', 'Reg_sz', $description) EndIf Return Not $exitcode EndFunc Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Fire Posted January 6, 2010 Share Posted January 6, 2010 (edited) In my example which i post on above => %programfiles%\AutoIt3\AutoIt3.exe" "%1" is for to KNOW your programm what does when the specified file extension executed(i mean file with specified extension). I think you need parametric execution! Edited January 6, 2010 by Sh3llC043r [size="5"] [/size] Link to comment Share on other sites More sharing options...
PhilipG Posted January 6, 2010 Author Share Posted January 6, 2010 (edited) How does parametric execution work then? Func _FiletypeAssociation ($extension, $type, $program, $description = '') ; e.g. _FiletypeAssociation('.pdf', 'FoxitReader.Document', '"%ProgramFiles%\FoxitReader.exe" "%1"') $exitcode = RunWait(@ComSpec & ' /c ftype ' & $type & '=' & $program & _ ' && assoc ' & $extension & '=' & $type, '', @SW_HIDE) If $description And Not $exitcode Then Return RegWrite('HKCR' & $type , '', 'Reg_sz', $description) EndIf Return Not $exitcode EndFunc Is this for telling the program what to do? Edited January 6, 2010 by PhilipG Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 6, 2010 Share Posted January 6, 2010 That's not really what I meant! I know how too associate the extensions with the program. My problem is that I don't know how too make my program understand what to do when the file is opened!The penguin already told you. Read "Command Line Parameters" in the helpfile. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
James Posted January 6, 2010 Share Posted January 6, 2010 The comment beneath the function declaration line gives you an example. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 7, 2010 Author Share Posted January 7, 2010 I've managed to associate the extensions with my program, but this caused me to run into an other problem. If you run a file while the program is running. It starts a new instance. Is it possible to just pass the parameters to the already running instance instead of starting a new one? Link to comment Share on other sites More sharing options...
James Posted January 7, 2010 Share Posted January 7, 2010 Is it possible to just pass the parameters to the already running instance instead of starting a new one?Well if your program is already open then it shouldn't be too much of a problem.Try converting this VB code to AutoIt. VB is fairly easy to port so shouldn't be too much of a problem Couple of notes if you do port that code:Public Const WM_COPYDATA = &H4A = 74Many of the functions I'm sure will already be available on the forum, just search for themSome constants may defined in WinAPI.au3 for example (referring to the first point I made here) Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
KaFu Posted January 7, 2010 Share Posted January 7, 2010 (edited) Upsa, not what the OP wanted ... take a look at the second post in the "Enforce Single Instance" UDF in my signature, a working example of the WM_COPYDATA method mentioned by James above... Edited January 7, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
PhilipG Posted January 7, 2010 Author Share Posted January 7, 2010 Thats seems like what I whant! But the code just provides an error message! message: /Error StdOut "%path\to\script.au3" I'll guess Iknow where to look though! Link to comment Share on other sites More sharing options...
James Posted January 7, 2010 Share Posted January 7, 2010 Upsa, not what the OP wanted ... take a look at the second post in the "Enforce Single Instance" UDF in my signature, a working example of the WM_COPYDATA method mentioned by James above...Very nice KaFu! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
dirty Posted February 16, 2010 Share Posted February 16, 2010 (edited) Script.au3(2,75) : ERROR: _FiletypeAssociation() called by a previous line with 0 arg(s). Min = 3. First previous line calling this Func is 1. Is there another way to associate files with other programs other then using CMD ? I mean CMD does not make associated file look like a program it was associated with. I wonder how do installers do it... Knowing would be awesome Edited February 16, 2010 by dirty Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now