Jump to content

[SOLVED] Extension associations?


Recommended Posts

Hi guys, i hava a doubt about extension associations with autoit.

I have made this simple script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form = GUICreate("Test", 238, 77, -1, -1)
$Input = GUICtrlCreateInput("", 8, 8, 169, 21)
$Button_Check = GUICtrlCreateButton("Check", 8, 40, 105, 25)
$Button_Cancel = GUICtrlCreateButton("Cancel", 121, 40, 105, 25)
$Button_SelectFile = GUICtrlCreateButton("...", 184, 8, 41, 21)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button_SelectFile
   Select_File()
  Case $Button_Check
   If GUICtrlRead($Input) <> "" Then
    MsgBox(0,0,GUICtrlRead($Input))
   EndIf
  Case $Button_Cancel
   GUICtrlSetData($Input, "")
EndSwitch
WEnd

FUNC Select_File()
    $Dir = FileOpenDialog("Select file...", @WorkingDir, "All files (*.*)", 1 + 4)
    If StringRight($Dir, 1) <> "\" Then $Dir &= ""
    If $Dir <> "" Then
  GUICtrlSetData($Input, $Dir)
    EndIf
EndFunc

So open the script/exe --> Click on button "..." --> Select a file -- Click on "Check" or read the input for see the full path of the file.

It's possible to have a result like this with a double click on a file or click with the right click --> File --> Open With?

I want to open a file with an autoit .exe and have the input fill with the path of the file.

Hope is clear, if not please ask ;)

Thanks

Edited by johnmcloud
Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

guinness made a script to create file associations a while back :

I don't need to create association with autoit, i can do it manually. But i what to see the path of the file directly if i open it with a specific autoit .exe

Example

Click with right click on "C:Test.txt" --> Open with --> MyAutoit.exe

On input box i need to see "C:Test.txt"

Edited by johnmcloud
Link to comment
Share on other sites

Thanks smartee.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

You need to make use of Command Line Parameters. Check it out in the help file, if you get stuck, post back what you tried.

So I can use an autoit commandline for have the full path of the file with "Open with" and the same time redirect it to a classic inputbox GUI?

If you have a little time, can you provide an example?

Thanks for your support

Edited by johnmcloud
Link to comment
Share on other sites

Here is an example, try running it with a parameter or from the context menu ;)

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Demo1", 500, 50)
$Input1 = GUICtrlCreateInput("", 5, 5, 490, 21)

If $CmdLine[0] > 0 Then
    GUICtrlSetData($Input1, $CmdLine[1])
EndIf

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Link to comment
Share on other sites

Ohh, really good, thanks ;)

It don't support multiple selection? It can take only 1 file at time, it' possible to have more selection like FileOpenDialog with option 4?

Like:

C:Test.txt|C:Test2.txt|C:Test3.txt

If i try to select 2 file, then "Open with" --> MyAutot.exe i see only the path of one file

Edited by johnmcloud
Link to comment
Share on other sites

Any chance for a kiss you two?

Erm...maybe not. Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Erm...maybe not.

Ha! your no changed into a maybe, my chances are getting better by the minute ;) and to think I'd have been clueless had trancexx not asked..

Ohh, really good, thanks :)

It don't support multiple selection? It can take only 1 file at time, it' possible to have more selection like FileOpenDialog with option 4?

Like:

C:Test.txt|C:Test2.txt|C:Test3.txt

If i try to select 2 file, then "Open with" --> MyAutot.exe i see only the path of one file

That depends on how you parse the command line parameters, so can you post that part of your script?
Link to comment
Share on other sites

That depends on how you parse the command line parameters, so can you post that part of your script?

I don't have a script yet for this, i have test only yours ;)

I have make this test:

1) Select a file --> Then "Open With" --> MyAutoit.exe ( your script compiled) --> Inputbox is full with the path, work fine

2) Select 2 files with CTRL+Click --> Then "Open With" --> MyAutoit.exe ( your script compiled) --> Inputbox have only one file path, don't have the second file path

I'd like to open more file and have more path like:

C:Test.txt|C:Test2.txt|C:Test3.txt

Edited by johnmcloud
Link to comment
Share on other sites

I don't have a script yet for this, i have test only yours ;) I have make this test: 1) Select a file --> Then "Open With" --> MyAutoit.exe ( your script compiled) --> Inputbox is full with the path, work fine 2) Select 2 files with CTRL+Click --> Then "Open With" --> MyAutoit.exe ( your script compiled) --> Inputbox have only one file path, don't have the second file path I'd like to open more file and have more path like: C:Test.txt|C:Test2.txt|C:Test3.txt The second parameter is in $CmdLine[2], third in $CmdLine[3] etc. You must loop through and parse the whole array, not totally unlike how you would use FileOpenDialog() if multiple files was selected.

Edit: see smartee's post.

Edited by AdmiralAlkex
Link to comment
Share on other sites

Hmm, so don't you get two instances of the program, each with a file?

No, only one but also if i have two instance i don't need it ;)

If you drag e drop 2 files at the same time with ctrl+click on a classic cmd window you see only one, maybe we need a different approach or a different script.

Edited by johnmcloud
Link to comment
Share on other sites

Are you running your exe from the command line? Or through the context menu of an associated file? Or by drag and drop onto the exe? If you are passing multiple parameters through the command line (or by dragging multiple files onto the exe) you would need to parse each parameter as the admiral was suggesting:

The second parameter is in $CmdLine[2], third in $CmdLine[3] etc. You must loop through and parse the whole array, not totally unlike how you would use FileOpenDialog() if multiple files was selected.

Link to comment
Share on other sites

Are you running your exe from the command line? Or through the context menu of an associated file? Or by drag and drop onto the exe? If you are passing multiple parameters through the command line (or by dragging multiple files onto the exe) you would need to parse each parameter as the admiral was suggesting:

I have told you at #13, through right click on a file -- context menu -- open with -- your compiled script.

If i select one file work, two or more i have only one instance and only one path. The path is the first file selected.

I don't need a commandline, i want simply to have the fullpath of the selected file(s) without open the compiled script everytime.

Do you have try your script? ;)

Thanks for your time.

Link to comment
Share on other sites

ok, two or more instances should be opened in such a case, and from above I assume the admiral concurs, can you post a short video or something so I can see precisely what you are doing?

Anyway, you should be able to put together a script using WM_COPYDATA and optionally, _Singleton, that would pass the file-names to the already running script.

Check guinness's signature (lol everything seems to be in there) for a WM_COPYDATA example.

If you get stuck post back with your attempt, I'll try to put together a simple example.

EDIT: spelling

Edited by smartee
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...