Jump to content

Recommended Posts

Posted

Hello!!!  

In the past I had problems adding an application as a default for an extension in Windows 10. (It was easy in windows 7 using Registry) But since Windows 8 It requires to do some steps more. I wrote a tool (in other programming language) months ago for handling it. But now I just want to share an AutoIt version.

 

Check on GitHub.

 

 

Saludos

Posted (edited)

Just at first glance I can see that it is a decent job.

btw.
You shoudl attach some header in this script to like in UDF to show what the requirments are, and who create this script.

I see you are using Maps[] so Beta is required, and not all will be know about this.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Hello guys, @mLipok as @argumentum says it's just an array. I've updated the script according your suggestions. Thank you both

Saludos

Posted (edited)

Please separate UDF <> Example

EDIT:
some functions can occurs that are not unique.

Please change name of all/each UDF Function to unique names using prefix _SFA_***()

For example

Func _SFA_GetUserSid()
    ......
EndFunc   ;==>_SFA_GetUserSid

Using such named functions in main script is very usefully because thanks to this , when you analyze main script you can easily guess that all this _SFA_***() functions comes from SFA.au3 UDF.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I usually follow those best practices you can see them integrated in my UDF. This was not intended to be an UDF. It was just a random share. 

Saludos

Posted

i'm slightly confused. there are "default programs", occasionally referred to as "default apps", which are used to handle common tasks, such as web browsing, map navigation, email, etc. and there is file type association, which is used to assign a specific file type with a specific program.

these are not the same thing, this kind-of explains it. this UDF handles file type association, but the topic title seems to refer to the default applications. i believe some clarification is required here.

secondly, this UDF sets file type association for the current user only. what would be the process for all users? would switching HKCU to HKLM suffice (with admin rights in effect, of course)?

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

@orbs yes it is related to the link you posted.  Default application it's handled by changing file type association. 

I suppose that for handling global type it will need to write in global keys. I've never tested but it's the usual way Windows.

Saludos

Posted
  On 9/17/2020 at 9:05 AM, Danyfirex said:

I usually follow those best practices you can see them integrated in my UDF. This was not intended to be an UDF. It was just a random share. 

Expand  

But it deserves to become a UDF.

Especially since you publish this code on GitHub, so you have the intention that others can take advantage of it.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

You're right, seems to be I'm lazy today (Lazy by depression) I'll update it. thank you @mLipok

 

Saludos

Posted

Updated. No according with @mLipok's suggestions because I want to keep main file name due to the main tool I wrote is SFTA so I want to keep it related, and the main function was renamed similar to my PowerShell version (Set-FTA) so now It's _Set_FTA. I'll consider an update to rename all according to our best practices, but for now it will stay that way.

 

Saludos

 

Posted (edited)

Here is my solution without hashing, crypting, encoding and other gimmicks.
Only using the Assoc and Ftype commands.

#RequireAdmin   ; due to FTYPE command
#include <array.au3>; For _ArrayDisplay()
; default for my .txt:  ftype Notepad++_file="C:\Program Files\Notepad++\notepad++.exe" "%1"
Local $sExt, $sCmd, $sResult, $aArray, $sFtype, $sApp
$sExt = InputBox("Assign an app to a file type", "Enter file type to alter ", ".txt")
$sExt = "." & StringReplace($sExt, ".", "")   ; to ensure a single dot as prefix
$sCmd = "ASSOC " & $sExt
$sResult = _CmdResult($sCmd)
If StringLeft($sResult, 1) <> "." Then Exit MsgBox(16 + 262144, Default, $sResult, 0)   ; extension NOT found
$aArray = StringSplit($sResult, "=")
$sFtype = StringTrimRight($aArray[2], 2)   ; strip CRLF
$sCmd = "FType  " & $sFtype
$sResult = _CmdResult($sCmd)
$aArray = StringSplit($sResult, "=")
$sApp = $aArray[2]
$sApp = InputBox("Assign a new app to file type  " & $sExt, "Enter new app for file type  " & $sExt, $sApp,"",600)
$sCmd = "FTYPE " & $sFtype & "=" & $sApp
$sResult = _CmdResult($sCmd)
MsgBox(64 + 262144, Default, "New assignment for  """ & $sExt & """ is:" & @LF & @LF & $sResult, 0)

Func _CmdResult($sCmd)
    Local $sResult, $sPid
    $sPid = Run(@ComSpec & " /c " & $sCmd, "", @SW_HIDE, 8)
    Do
        Sleep(20)
        $sResult &= StdoutRead($sPid)
    Until @error
    Return $sResult
EndFunc   ;==>_CmdResult

 

Edited by Exit
Changed @SW_SHOW to @SW_HIDE

App: Au3toCmd              UDF: _SingleScript()                             

Posted

Hello @Exit I'm  sure your solution will not work under windows 10. I think my solution is the only one(source code) in the worldwide that work in Windows 10. 

Saludos

Posted

Hello @Exit I'm  sure your solution will not work under windows 10. I think my solution is the only one(source code) in the worldwide that work in Windows 10. 

Saludos

Posted (edited)

Hello @Danyfirex, I must say your UDF will be very useful in my project :) I had in mind to modify in [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\] .pdf and .pdfxml but I didnt test it.

Anyways, Nice UDF! your udf will make it much simplier ^_^, I will make sure to mention you in my project post and script.

EDIT 1

Do you know how to change default browser by any miracle? :P

Thank you,

~WilliamasKumeliukas

Edited by WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

  Reveal hidden contents
Posted

@Danyfirex Will it work for all users or only current user?

Regards,

~WilliamasKumeliukas

Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this:

  Reveal hidden contents
Posted

@Exit  Try adding a custom extension with your code. or maybe .pdf or .html and let me know if it works.

 

Saludos

Posted

@WilliamasKumeliukas It's designed  for current user It would require some modification for make it work globally.

 

 

Saludos

Posted

@WilliamasKumeliukas about browser I know how to do it. I started doing a code for it time ago but didn't finish it. Maybe I get inspired again and finish it. 

Saludos 

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
×
×
  • Create New...