Velislav Posted April 14, 2020 Share Posted April 14, 2020 (edited) Hi, All! I have an autoit executable program that displays pdf and can manipulate them. I want this program to be a default pdf viewer. When i choose my exe as a default pdf program I have no problem. Windows allows me to do it. And all pdf files become with icon just like my exe icon. So far so good. Here comes the problem: When i double click on any pdf file windows opens my program but my program doesn't open the pdf file. If i open my program and then the trough the program open fucnction I can see it. That means that my code should listen on start for some information from Windows about which file to open. Am I right? I tried by implementing comand line arugments but it doesn't work. When the file is open from windows I don't get any arguments. But if I start the program from cmd with arguments I can see them. Do you, guys, have any idea how my program could know if it was started from the exe, or it was started from a file, and of course to understand the full path of this file? Thank you very much! I have this: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=1486505265-document-file-export-sending-exit-send_81434.ico #pragma compile(AutoItExecuteAllowed, True) #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** If $CmdLine[0] > 0 then _arrayDisplay($CmdLine) Endif Edit The Solution: Thank you very much for helping me! The problem is SOLVED! The problem was that on my first try to open a pdf file with my program. The location of the program was on my desktop. Then I changed the location of the exe but in the registry the location of my exe file was still on my desktop. Now everything is perfect! Actually just to know where to check that is right here: Computer\HKEY_CLASSES_ROOT\Applications\YOURappEXEfile.exe\shell\open\command "C:\Users\Velislav\Desktop\Mix_PDFViewr_withOCR.exe" "%1" Edited April 14, 2020 by Velislav Link to comment Share on other sites More sharing options...
Developers Jos Posted April 14, 2020 Developers Share Posted April 14, 2020 What is the exact definition now in REGEDIT for .pdf ? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Velislav Posted April 14, 2020 Author Share Posted April 14, 2020 Hi! Thanks for the very quick response. here is what I have. Mix_PDFViewer_withOCR is my application Link to comment Share on other sites More sharing options...
Musashi Posted April 14, 2020 Share Posted April 14, 2020 34 minutes ago, Velislav said: When i double click on any pdf file windows opens my program but my program doesn't open the pdf file. Search the registry for your program. There should be an entry (entries) like : shell -> open -> command -> ..\PDFViewer\PDFViewer.exe" "%1" "%1" stands for the file name you pass to your viewer. BTW : Editing in the registry should only be considered if you know what you are doing !!! Velislav 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Velislav Posted April 14, 2020 Author Share Posted April 14, 2020 Hi, Musashi, I don't say I am master of registry but I have an idea how they work, so I will be very careful with them. Really thx for the alert. I tired to find this, but i couldn't. 8 minutes ago, Musashi said: shell -> open -> command -> ..\PDFViewer\PDFViewer.exe" "%1" I see the program few times in the registry but i think not related to what I am looking for. And even if i found it. How this will help my program to get the full path of the file that was double clicked(executed)? Link to comment Share on other sites More sharing options...
Velislav Posted April 14, 2020 Author Share Posted April 14, 2020 The only thing that comes to my mind is to find in the registry the recent pdf opened file and to open the last opened file. I guess this information is stored here but how can i read this data? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 14, 2020 Developers Share Posted April 14, 2020 Could you run this script on your system and paste the output in a <code box> : expandcollapse popup;*********************************************************** ; Scriptname: Get other_RegistrySettings.au3 ; Script to display Registry setting for a given fileextention ;*********************************************************** #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> ; _Check_Au3_Registry(".pdf") ; Func _Check_Au3_Registry($fext) Local $TotalMsg,$UserData Display_Console("******************************************************************************************************************************************" & @CRLF, $TotalMsg) Local $FixedOpen = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $fext, "Application") Local $FixedOpenW7 = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $fext & "\Userchoice", "ProgId") If $FixedOpen <> "" Then Display_Console("!* 1.Found always open with :" & $FixedOpen & @CRLF, $TotalMsg) Display_Console(" Reg->HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $fext & " key:Application" & @CRLF, $TotalMsg) EndIf If $FixedOpenW7 <> "" Then Display_Console("!* 2.Found always open with :" & $FixedOpenW7 & @CRLF, $TotalMsg) Display_Console(" Reg->HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $fext & "\Userchoice key:ProgId" & @CRLF, $TotalMsg) EndIf Local $au3prof = RegRead("HKCR\" & $fext, "") Display_Console('!* Registry key: "HKCR\' & $fext & '" - "Default" is currently set to: ' & $au3prof & @CRLF, $TotalMsg) Local $RegKeyBase = "HKCR\" & $au3prof & "\shell" Display_Console("******************************************************************************************************************************************" & @CRLF, $TotalMsg) Display_Console("* Explorer shell options:" & @CRLF, $TotalMsg) Display_Console("* " & $RegKeyBase & ": " & @CRLF, $TotalMsg) Display_Console("* => Default Action:" & RegRead($RegKeyBase, "") & @CRLF, $TotalMsg) Local $var, $var2 For $i = 1 To 30 $var = RegEnumKey($RegKeyBase, $i) If @error <> 0 Then ExitLoop Display_Console("* " & StringLeft($var & " ", 22), $TotalMsg) $var2 = RegEnumKey($RegKeyBase & "\" & $var, 1) Display_Console(" => " & $var2, $TotalMsg) Display_Console(":" & RegRead($RegKeyBase & "\" & $var & "\" & $var2, "") & @CRLF, $TotalMsg) Next Display_Console("******************************************************************************************************************************************" & @CRLF, $TotalMsg) ClipPut($TotalMsg) GUICreate($fext & " registry settings", 1000, 600) GUICtrlCreateEdit($TotalMsg, 1, 1, 998, 560,$ES_READONLY+$WS_VSCROLL+$ES_AUTOVSCROLL) GUICtrlSetFont(-1, Default, Default, Default, "Courier New") Local $HReg_Exit = GUICtrlCreateButton("Exit", 450, 570, 50, 25) GUICtrlCreateLabel("* information is stored on the clipboard.", 10, 575) GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Or $msg = $HReg_Exit GUIDelete() EndFunc ;==>_Check_Au3_Registry ; Func Display_Console($msg, ByRef $TotalMsg) ;~ ConsoleWrite($msg) $TotalMsg &= $msg EndFunc ;==>Display_Console Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Velislav Posted April 14, 2020 Author Share Posted April 14, 2020 Hi! All! Thank you very much for helping me! The problem is SOLVED! The problem was that on my first try to open a pdf file with my program. The location of the program was on my desktop. Then I changed the location of the exe but in the registry the location of my exe file was still on my desktop. Now everything is perfect! Actually just to know where to check that is right here: Computer\HKEY_CLASSES_ROOT\Applications\YOURappEXEfile.exe\shell\open\command "C:\Users\Velislav\Desktop\Mix_PDFViewr_withOCR.exe" "%1" 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