Draygoes Posted August 4, 2021 Share Posted August 4, 2021 (edited) This seems like a fun bit of tech knowledge that I don't have but will find useful. So, from start to finish, what happens when you double click a text file and it opens in Notepad? How do we change that in the registry? On the script side, how to we catch and parse the filename to a string? Is it a string from the start? Like I said, this isn't with the goal of designing one script. Rather, it's a skill that I want to pick up to use in projects going forward. Thanks for your time! Edited August 4, 2021 by Draygoes Spelling Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Solution Dan_555 Posted August 4, 2021 Solution Share Posted August 4, 2021 (edited) Windows is treating the filenames as Strings. The filename (argument) is passed to other apps as a string. On the AutoIt Script side, it is passed as a string as well, see the Command Line Parameters: https://www.autoitscript.com/autoit3/docs/intro/running.htm When you double click on a text file, on windows side, it can be a bit complicated. I do not know the exact order but it looks something like: Windows explorer is checking if the text extension, usually ".txt" has an assigned app to open it. If yes, it is opening the default app, if no, it is looking first if there is an app for the unknown files ( * ), then if it does not know how to, it presents a list of apps which could open it. (The apps usually set the extensions which they can open, somewhere in the registry (new in win 10 i think) ) Here is a small info on how to change the default editor for .bat files: https://www.itprotoday.com/windows-78/how-can-i-change-default-editor-used-editing-batch-files They use, in the example: Quote D:\Program Files\Microsoft Office\Office\winword.exe %1 But i remember, at least from the XP times that the filenames/paths with spaces in it may not work. (because space is a delimiter char, used to distinguish the program from the parameter) The correct use, at least for windows before 10, should be: Quote "D:\Program Files\Microsoft Office\Office\winword.exe" "%1" Edited August 4, 2021 by Dan_555 Draygoes 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Subz Posted August 4, 2021 Share Posted August 4, 2021 In Windows 10 it normally uses the following key, you would need to find the hash key which is machine specific which can be a challenge although their are tools from memory that can automate this. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice While you can use group policy to force file associations, it means users aren't able to change those associations https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.WindowsExplorer::DefaultAssociationsConfiguration You can configure the default user file associations, but this only impacts new user accounts not existing user accounts. https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/export-or-import-default-application-associations Draygoes 1 Link to comment Share on other sites More sharing options...
Draygoes Posted August 8, 2021 Author Share Posted August 8, 2021 Why can't I remember how to insert multiquotes? Old Fashioned way it is. @Dan_555Thanks for the details! I'll post a working example when I get around to actually using this. @SubzLove that name btw; So if it's that complicated, how does every other program manage to pull it off? Most programs for editing anything registers it's own file type. Thanks for the responses guys. Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Draygoes Posted August 8, 2021 Author Share Posted August 8, 2021 Also, is drag and drop treated like an open command? Does it just pass file location when you do that as well? (I'm not able to test at the moment) Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Dan_555 Posted August 9, 2021 Share Posted August 9, 2021 TBH, i do not know how the windows explorer is handling the drag'n'drop. I'm using the FreeCommanderXE, and here the drag'n'drop works very well with autoit scripts, while the windows (10) explorer does not. The full path+filename is passed to the script. Loc 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Earthshine Posted August 9, 2021 Share Posted August 9, 2021 (edited) thats because FreeCommanderXE is Win32 based exe, Explorer is now way different and doesn't use win32 controls. If you want to automate Windows Explorer then you must learn UIAutomation Edited August 9, 2021 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Dan_555 Posted August 9, 2021 Share Posted August 9, 2021 The question was about drag'n'drop. Some of my script sourcecode Link to comment Share on other sites More sharing options...
Earthshine Posted August 9, 2021 Share Posted August 9, 2021 (edited) i would not expect it to work like win32 based systems at all, even with dragon drop best off to start reading this https://docs.microsoft.com/en-us/windows/win32/shell/dragdrop you should be able to use the clipboard as mentioned in the docs sp with AutoIt you can use Objects like the IDataObject Edited August 9, 2021 by Earthshine My resources are limited. You must ask the right questions 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