AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Opening a file in an already open program

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Da Rossa



Joined: 06 Dec 2007
Posts: 161

PostPosted: Mon Jul 07, 2008 3:11 am    Post subject: Opening a file in an already open program Reply with quote

Hi,
Look @ this situation: I have Foxit reader set up as my default PDF reader. However, sometimes I need to use Acrobat to do some things. If I access the file simply, Foxit will open. Let's say I have Acrobat already open and minimized on the taskbar, with no document loaded. Also, I have, in my desktop, a just-downloaded pdf file that I'm intending to view in Acrobat, not Foxit. Can some hotkey/command be assigned to have the file be opened in Acrobat instead of having to minimize all then, with the mouse, drag and drop the document into the Acrobat interface? Tks!
_________________
AHK is perfect.
Back to top
View user's profile Send private message
Icarus



Joined: 24 Nov 2005
Posts: 439

PostPosted: Mon Jul 07, 2008 8:28 am    Post subject: Reply with quote

Of course you can do it, its all a matter of how "nice" the solution will be.
The most obvious thing to try, is to call Acrobat executable with the new document.

Run %ProgramFiles%\Acrobat\Acrobat.exe "%PdfFile%"
Or something similar.

Now, you mentioned you already have acrobat opened - so I do not know how will this work for you.
If Acrobat is multi instance, you will probably have a newly opened acrobat reader. If this is not the desired result, you may want to first check if Acrobat is open (IfWinExist Acrobat) and if so, restore its window, and send input directly to it so it will open your document.

Makes any sense?
_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Da Rossa



Joined: 06 Dec 2007
Posts: 161

PostPosted: Mon Jul 07, 2008 2:41 pm    Post subject: Reply with quote

Unfortunately this
Quote:

Run %ProgramFiles%\Acrobat\Acrobat.exe "%PdfFile%"
Or something similar.

might not work because the filename is variable, since it's about the PDF files that I just downloaded, and most of them come with those strange filenames. I was thinking about something like:
Select the file on the desktop, hit a hot combo and have it open in Acrobat. Acrobat should be already open or not, is it possible?
_________________
AHK is perfect.
Back to top
View user's profile Send private message
Icarus



Joined: 24 Nov 2005
Posts: 439

PostPosted: Mon Jul 07, 2008 3:31 pm    Post subject: Reply with quote

Of course the filename is a variable... I do not see the problem.
If you are already going to your desktop or download folder, and clicking the file - why not just right click -> open with acrobat? instead of doing a script to do just that?

Is there any hidden purpose for your question, or do you just want to be able to open a file with a different application than the default?

In any case, see this code.
Select a file in a Windows Explorer folder or on your desktop, and press F12
Code:

#SingleInstance Force

Return

F12::
  IfWinActive Program Manager         ; Desktop
    Class = Progman
 
  IfWinActive ahk_class CabinetWClass   ; Windows Explorer
    Class = CabinetWClass
 
  ControlGet ControlDetails, List, Selected, SysListView321, ahk_class %Class%, FolderView

  StringSplit Detail, ControlDetails, %A_Tab%
  File := Detail1
  msgbox I see the file %File%
 
  If( InStr( File, ".pdf" ) ) {
    Run %A_ProgramFiles%\Acrobat\Acrobat.exe "%File%"
  }
Return


^ESC::ExitApp

_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Da Rossa



Joined: 06 Dec 2007
Posts: 161

PostPosted: Thu Jul 10, 2008 7:12 am    Post subject: Reply with quote

No, actually I want it not only for Acrobat & PDF files, but for the AHK files themselves: if I hit enter or click a .ahk file anywhere, the script will launch. But many times I only want to EDIT the file on Textpad or notepad... this makes me drag and drop, what is anoying.

Also, it appers to be a lil glitch on that code: uf I select a file and hit F12, it works, but when I do it a second time with another file, it launches the first file again Sad
_________________
AHK is perfect.
Back to top
View user's profile Send private message
Icarus



Joined: 24 Nov 2005
Posts: 439

PostPosted: Thu Jul 10, 2008 7:34 am    Post subject: Reply with quote

Why arent you just using the built in OS functions?
Right click on AHK file -> Edit?

Most files in the OS usually already have a secondary list of commands, and if you do not find yours there, you can always add items to the context menu.

Or are you trying to do it with AHK, just as practice?
_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Da Rossa



Joined: 06 Dec 2007
Posts: 161

PostPosted: Thu Jul 10, 2008 3:51 pm    Post subject: Reply with quote

The purpose is to reduce the mouse usage, and get rid of the need to right click then 'open with'.
Whoa, how do I add items to the context menu??
_________________
AHK is perfect.
Back to top
View user's profile Send private message
Icarus



Joined: 24 Nov 2005
Posts: 439

PostPosted: Thu Jul 10, 2008 4:43 pm    Post subject: Reply with quote

Da Rossa wrote:
Whoa, how do I add items to the context menu??


  • In Windows Explorer open Tools -> Folder Options
  • Select the File Types tab
  • Select your file type (for example TXT) you want to edit
  • See the bottom - if you see a button Restore, press it
  • Then pressed the Advanced button at the bottom.
  • This shows you some of the item's menu commands
  • Click New
  • In the new dialog, type a description in the Action field
  • Select any application that you want it to open with (for example Firefox)
  • Then, at the end of the application line add "%1" ("C:\Progra...\Firefox.exe" "%1") - this %1 will be the file name that yo uare selecting.
  • Ok all dialogs and you should now have a new action in the context menu for that file type.

_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Thu Jul 10, 2008 5:38 pm    Post subject: Reply with quote

you don't need a mouse to rightclick. See Appskey.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Da Rossa



Joined: 06 Dec 2007
Posts: 161

PostPosted: Mon Jul 14, 2008 6:47 am    Post subject: Reply with quote

Thanks Icarus and Engunneer!
_________________
AHK is perfect.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group