Jump to content

Recommended Posts

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

Share this post


Link to post
Share on other sites

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:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-09-20

Share this post


Link to post
Share on other sites

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

Saludos

Share this post


Link to post
Share on other sites

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:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-09-20

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)?

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites
22 minutes ago, 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. 

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:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-09-20

Share this post


Link to post
Share on other sites

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

 

Saludos

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

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()                             

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Do not like my dirty code? It's okay, but, in my opinion, the dirty codes are unique and I think it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Share this post


Link to post
Share on other sites
14 minutes ago, Danyfirex said:

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. 

I'm using Windows 10   :thumbsup:
And it works. Just try it.


App: Au3toCmd              UDF: _SingleScript()                             

Share this post


Link to post
Share on other sites

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

Regards,

~WilliamasKumeliukas


Do not like my dirty code? It's okay, but, in my opinion, the dirty codes are unique and I think it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor.

~WilliamasKumeliukas

Share this post


Link to post
Share on other sites

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

 

Saludos

Share this post


Link to post
Share on other sites

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

 

 

Saludos

Share this post


Link to post
Share on other sites

@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 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By WilliamasKumeliukas
      Hi,
      I started this project alone in May 2020 as project in my spare time at work, I'm working for a IT compagny that's started opening their services to residential customers few months ago and now my position in the company kinda drifted in the doom and gloom world of repetitive tasks like: Reinstallation of Windows 10.
      The procedure is very repetitive and I started feeling like being a robot which is the main reason I started this project.
       
      ==============================FAQ==================================
      1. Q: Do you want this project to be accomplished with the usage of AutoIT ONLY or 3rd party tools / Scripts (BAT / CMD / VBS) ? A: No, if I cannot find a way using AutoIT to accomplish a task I will move to my Plan B which consist of automating an 3rd party tool to accomplish the affected task until a solution is found. 2. Q: What do I get from helping/collaborating in this project? A: I will personally take the responsability to mention you in the credits of this project. 3. Q: If I have more questions, can I ask? A: Certainly! feel free to ask any questions related to this project! 4. Q: What is the main goal of this project? A: Automating Windows 10 configuration without user interaction needed (as much as possible) ______________________________________________________________________________________________________________________________
      Current progression of the project (more might be added in future)
      « Blue = Info || Yellow = Unfinished/Untested || Purple = Could be better || Green = Done ||Red = Not Yet Started »
      *** Very early Stage ***
      Connect Network Attached Storage(NAS) (Tested & Working - AutoIT only)
      Install Adobe Reader DC, 7zip, Google Chrome (Tested & Working - using 3rd party tool)
      Change OEM Information (Tested & Working - contains both AutoIT version and CMD script)
      Disable ScreenSaver (Require testing AutoIT only)
      Change Computer Name (Require testing AutoIT only) 
      Change Default Browser (Work - using 3rd party tool)
      Change .pdf / .pdfxml from Edge to Adobe Reader DC (AutoIT only)
      Change Edge to Google Chrome as Default Browser (Tested & Working - using 3rd party tool)
      Windows Updates (Currently working on it - AutoIT only)
      Install Office 
      Activate Office (Tested on 2010 & Working - CMD Script)
      Pin to taskbar Excel, Outlook, Word, Chrome (Tested & Working - using 3rd party tool)
      GUI currently featuring the following options 
      - TreeView to check case of desired tasks
      -  Redirect ConsoleWrite with timestamp messages in richedit (errors shown in red text)
                 *** To Do ***
       - Read informations needed for tasks like: OEM, ComputerName, NAS user/password etc... from a file
       - ListView for Windows Updates
       - Probably more
       
      ***  If this project interest you, Reply here This will greatly help me to see if you'd like this project to become real  ***
      ______________________________________________________________________________________________________________________________
      2020.09.21 Update: Since this topic reached over 200+ views without a single interest shown by community, pm me and i'll share with you W10 Configurator script  
       
      Best Regards,
      ~WilliamasKumeliukas
    • By Jgladden
      Dan - thanks for all that you do - this stuff is great. 
      Hoping you can assist with an issue we are having now that we have moved to Windows 10/Server 2016. The Chrome interactions were working flawlessly until moving over. Now my code fails when attempting to create the session. As you can see, our Chrome install is not in a standard location but I have validated the path to the binary. I have attached some detail below including system info, console output and the chrome log detail. I have tried several recommendations that have seen in various forums but none have made a difference
      Any assistance you can give would be greatly appreciated. 
      Thanks in advance, 
      chrome_Details.txt
    • By poddex
      Hello everyone.
      I always try to work with old Windows 10 versions as much as possible because I know mane compatibility issues with Windows 10 upgrading. 
      But I couldn't do anything else (I got drivers problem), and nothing couldn't help me besides upgrading, so I upgraded from 1807 to 1903.
      And...get another problem 😃
      I use AutoitX library in external project like this.
      ObjectAutoIt=New COMObject("AutoItX3.Control");
      ObjectAutoIt.AutoItSetOption("WinTextMatchMode",2);
              While ObjectAutoit.WinExists("",WindowHeader) Cycle 
                  ObjectAutoIt.WinClose("",WindowHeader);
              EndCycle;
      After upgrade I get that this line code 
      While ObjectAutoit.WinExists("",WindowHeader)
      become extremely low - ~ 20 seconds even if 10 windows open. But before upgrade it takes 0.5 s for a max.
      And every time that this code line passes through  - it takes ~20s, (20.115, for example), not less, not more. Something pauses it to work.
      How can I diagnose, what is that?
      I tried reinstall whole AutoIt, but no results.
      Thanks to all.
    • By Jahar
      Hi All,
      Please help me on how to fetch date/time of last windows 10 system restore point using autoit? Basically its about querying the last restore point.
    • By kingjacob90
      Hi
      So I am trying to click the green button, this button is not always in the same place. So fare I am trying to click it by finding the color but there is also something else with the same color on the screen (circled in yellow) that is causing issues. Is there a way to use the Title and Class of the window (can't be just the window as there are more than one with the same name).
      How does AutoIt Info get this information?

×
×
  • Create New...