• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Rép: Windows properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép: Windows properties


  • Subject: Rép: Windows properties
  • From: KOENIG Yvan <email@hidden>
  • Date: Sun, 12 Feb 2012 22:26:44 +0100


Searching heavily in Google, it seems that I got it :

on decode_URL(txt)
return do shell script "/usr/bin/python -c " & ¬
quoted form of "import sys, urllib; print urllib.unquote(sys.argv[1])" & space & ¬
quoted form of txt
end decode_URL

set theURL to "file://localhost/Users/yvankoenig/Library/Containers/com.apple.Preview/Data/Desktop/Hȁussermȃn.pdf"
decode_URL(theURL)

I found also urllib2 but I don't understand the difference and this alternate code :

on decode_URL(txt)
return do shell script "/usr/bin/python -c " & ¬
quoted form of "import sys, urllib2; print urllib2.unquote(sys.argv[1])" & space & ¬
quoted form of txt
end decode_URL

set theURL to "file://localhost/Users/yvankoenig/Library/Containers/com.apple.Preview/Data/Desktop/Hȁussermȃn.pdf"
decode_URL(theURL)

behave the same way.

Both return :
"file://localhost/Users/yvankoenig/Library/Containers/com.apple.Preview/Data/Desktop/Hȁussermȃn.pdf"

So, my original script is now :
activate application "Preview"
tell application "System Events" to tell application process "Preview"
title of every window
--> {"Hȁussermȃn.pdf (page 1 sur 3)"}
set theURL to value of attribute "AXDocument" of window 1
(*
Leaves theURL undefined if the document was never saved before.
If the doc was saved once, returns something like
"file://localhost/Users/yvankoenig/Library/Containers/com.apple.Preview/Data/Desktop/Hȁussermȃn.pdf"*)
end tell
try
decode_URL(POSIX file theURL as text)
--> "Macintosh HD:Users:yvankoenig:Desktop:Hȁussermȃn.pdf"
on error
"never saved"
end try

on decode_URL(txt)
return do shell script "/usr/bin/python -c " & ¬
quoted form of "import sys, urllib; print urllib.unquote(sys.argv[1])" & space & ¬
quoted form of txt
end decode_URL

Yvan KOENIG (VALLAURIS, France) dimanche 12 février 2012 22:09:58



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Windows properties
      • From: Christopher Stone <email@hidden>
    • Re: Windows properties
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Windows properties
  • Next by Date: Re: Windows properties
  • Previous by thread: Windows properties
  • Next by thread: Re: Windows properties
  • Index(es):
    • Date
    • Thread