emendelson

WinClose doesn't close "Metro" app in Windows 8

7 posts in this topic

I've got a script that uses WinClose to close a window displaying a PDF file (typically in Adobe Reader or PDF-Xchange or Nitro PDF); it uses the filename of the PDF file to identify the window to close.

This is reliable with every PDF application I've tried except the Reader Metro-style application in Windows 8. Is there any reliable way to close a Metro app that I haven't discovered?

Thanks for any help.

Share this post


Link to post
Share on other sites



Is the pdf being opened by autoit? if so then you can assign a control to that window and you would always know what id each window had. If you didn't open the pdf from within autoit then is there more than one pdf file open at the same time? If so then you could use processclose. We need more data fro you.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

The PDF was already opened before the compiled AutoIt script runs. And there may or may not be more than one PDF open - but I only want to close the window or tab with one specific PDF.

What the script does is use _FileIsUsed to see if the PDF file is open; then, if the PDF is open, uses WinClose to close it. I'll look into ProcessClose - thanks for the suggestion (but if this message tells you anything that may be useful, I'll be grateful for any more help).

Share this post


Link to post
Share on other sites

All the metro stuff is like in a separate environment from the desktop stuff.

You may be able to use ProcessClose() to kill the entire reader, but I would just ensure that your default pdf viewer is the desktop version instead of the Metro version.

Share this post


Link to post
Share on other sites

All the metro stuff is like in a separate environment from the desktop stuff.

You may be able to use ProcessClose() to kill the entire reader, but I would just ensure that your default pdf viewer is the desktop version instead of the Metro version.

​This is clearly the right answer. Unfortunately, I'm trying to create a script that I can distribute to other people. I'll just have to warn them that Metro PDF reader won't work correctly with it.

Share this post


Link to post
Share on other sites

You should be able to set the default program in your script :)

Should be stored in: HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts

On my Win8.1 machine my entry looks like this for metro reader:

 

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf\OpenWithList]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf\UserChoice]
"Hash"="/3gK004oRcQ="
"ProgId"="AppX86746z2101ayy2ygv3g96e4eqdf8r99j"

 

After installing Adobe Reader DC and changing my default it looks like this:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf\OpenWithList]
"a"="AcroRd32.exe"
"MRUList"="a"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf\OpenWithProgids]
"AcroExch.Document.DC"=hex(0):

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf\UserChoice]
"Progid"="AcroExch.Document.DC"
"Hash"="/qqqowQ0wmk="

 

I think the hard part will be seeing what key corresponds to what version of your pdf viewer is installed if you have multiple versions in your environment. 

Not sure if there is an easier way than registry or a UDF for this kind of thing.

Share this post


Link to post
Share on other sites

Sorry to have taken so long to thank you for this. It's an approach I hadn't thought of, but it clearly works.

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