AppleScript: Activate the frontmost Safari and run Javascript.

I have the applescript like this below:
on run argv
  set pid to item 1 of argv
  set fileLocation to item 2 of argv
  tell application "System Events"
  set theprocs to every process whose unix id is pid
  repeat with proc in theprocs
  set the frontmost of proc to true
  using terms from application "Safari"
  set theScript to "document.querySelector(\"input[name='fileField']\").click()"
  tell (application "Safari" whose frontmost is true) to do JavaScript theScript in current tab of first window
  end using terms from
  tell proc
  keystroke "G" using {command down, shift down}
  delay 2
  key code 51
  delay 2
  keystroke fileLocation
  delay 10
  key code 52
  delay 5
  key code 52
  delay 5
  end tell
  set the frontmost of proc to false
  end repeat
  end tell
end run
The above code, set the frontmost of the given pid to true. The pid given will be of Safari. It will bringing the given pid of safari to front most. But after that this breaks in the line:
  tell (application "Safari" whose frontmost is true) to do JavaScript theScript in current tab of first window
with exception:
hacking.scpt: execution error: Can’t get application "Safari" whose frontmost of it = true. Access not allowed. (-1723)
Where I'm making mistake?

Hi,
you're right. The script does not compile. I don't know the reason, perhaps Shane reads the thread and knows the answer. Macscripter.net may be a good point for posting this.
A workaround: Create the whole ID-Tellblock as string and do a vanilla run script command.
tell application "Finder"
    activate
    set myApps to {"CS3", "CS4", "CS5.5"}
    set selectedApp to choose from list myApps with prompt "Choose Application:" with title "Launch Application"
    if the result is not false then
        set myApp to "Adobe InDesign " & selectedApp
        set myFile to "Applications:" & myApp & ":Scripts:Scripts Panel:Sample.jsx"
    end if
end tell
set myString to "tell application " & "\"" & myApp & "\"" & return ¬
    & "do script alias " & "\"" & myFile & "\"" & " language javascript" & return ¬
    & "end tell"
run script myString
It runs here.

Similar Messages

  • I've installed the new safari and it didnt load any web pages

    i've installed the new safari and it didnt load any web pages  and i dont knw wut to do thank and pleas help as quick as possible

    Hello,
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair. Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    Let us know after that what happens.

  • Tough Problem: This action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the problem

    Please, please help us!
    We have an intermitant problem which is badly affecting a group of our users.  Can anyone help identify what SERVER this message is talking about???
    Details:  CF-19 Panasonic Tough Book, McAfee Enterprise 8.7i, Windows XP 2005 Tablet Ed. SP3. 
    Problem at login intermittantly we get a unmanagable/unresponsive window stating the following:
    Window Name:  Server Busy
    Text:  This action cannot be completed because the other program is busy.  Choose ‘Switch To’ to activate the busy program and correct the problem
    Buttons:  Switch To, Retry, Cancel (Grayed out)
    Event Viewer Message:
    Source: DCOM, Type Error,
    Description:  The server
    {D6E88812-F325-4DC1-BBC7-23076618E58D} plus others with {6B19643A-0CD7-4563-B710-BDC191FCAD3B} did not register
    with DCOM within the required timeout.
    I searched the registry for {D63.....} and found keys relating to "TCServer.exe"  Little info available.  But found 
    ((KB895953 - Memory Leak in Windows XP Tablet PC Edition )) but this seems related to a pre SP3 update....  we have SP3 installed can I still install this patch?
    I searched {6B1....} and found keys relating to "TSFManager".  Again little information available.
    How can I identify the servers with the long {XXXXXXXXX} keys, and what is tcserver.exe?
    Please help,
    Tony Heslington.

    Hi,
    If the problematic XP PC is in a domain, please provide us more information on it, such as how many DCs, member servers and the OS versions. Does the error only
    occur on one XP PC? Does the issue occur when logging on as some certain users? When did the issue begin to occur? Have you installed software, hardware or updates recently?
    Please check whether the error occurs in Clean Boot mode.
    1. Click "Start", go to "Run", and type "msconfig" in the open box to start the System Configuration Utility.
    2. Click the "Services" tab, check the "Hide All Microsoft Services" box and click Disable All (if it is not gray).
    3. Click the "Startup" tab, click "Disable All" and click "OK".
    4. Restart your computer. If the "System Configuration Utility" window appears, please check the box and click "OK".
    What is the result? For further assistance, please help gather the following information for research:
    Event log
    =========
    1. Click "Start", click “Run”, input "eventvwr" and press Enter.
    2. Expand the "Windows Logs" node on the left pane, right-click on "Application" and click "Save All Events As"; in the pop-up window, click to choose the Desktop
    icon on the left frame, input "app" in the "File name" blank, and then click save.
    3. Right click on "System", with the same method, save it as "sys".
    4. Locate the two saved log files on the Desktop and send them to us.
    Collect HiJackThis log
    ==============
    1. Please download HijackThis from the following link:
    http://www.techspot.com/download317.html
    HijackThis is a tool to collect some system settings information which is useful for further troubleshooting.
    Please Note: The third-party products discussed here are manufactured by vendors independent of Microsoft. We make no warranty, implied or otherwise, regarding
    these products' performance or reliability.
    2. Right click the downloaded “HJTInstall.exe” file and choose "Run as administrator".
    Provide administrator password or click “Allow” if you are prompted to do so.
    3. Click the "Do a system scan and save a logfile" Button.
    4. A Notepad window will appear, please click “File”, “Save As...” to save it as HJT.log (or other file name you like) on the Desktop
    and sent it to us.
    Upload these file to the following workspace.
    You can upload the information files to the following link. 
    (Please choose "Send Files to Microsoft")
    Workspace URL: (https://sftus.one.microsoft.com/choosetransfer.aspx?key=900ac54d-301d-42da-876d-4546dc81a342)
    Password: Y^dh$J1KR2u%UKL
    Note: Due to differences in text formatting with various email clients, the workspace link above may appear to be broken. Please be sure to include all text
    between '(' and ')' when typing or copying the workspace link into your browser. Meanwhile, please note that files uploaded for more than 72 hours will be deleted automatically. Please ensure to notify me timely after you have uploaded the files. Thank you
    for your understanding.
    Thanks.
    Nina
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Upon opening LR I receive a "Server Busy" dialoge box: "This action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the problem." I have no other programs open and when I wait a bit it cle

    Upon opening LR I receive a "Server Busy" dialoge box: "This action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the problem." I have no other programs open and when I wait a bit it clears with the 'retry' button. Happened following a recent update. I'd really like this to go away - any ideas?

    For me this happens when I have Zenfolio or Facebook open in Google Chrome, even if Google Chrome is not active.  If you use Chrome, when the error shows up open Chrome and close each one of the tabs and click on the retry in Lightroom.  Also happens if Internet explorer is running with either of these two programs.

  • My wife and i both have an itunes library installed on to our separate pc's, we are now de-commissioning the pc's and are moving over to a single mac mini, can we install both libraries on to the mac mini and run them as separate libraries?

    my wife and i both have an itunes library installed on to our separate pc's, we are now de-commissioning the pc's and are moving over to a single mac mini, can we install both libraries on to the mac mini and run them as separate libraries?

    graham218 wrote:
    are moving over to a single mac mini, can we install both libraries on to the mac mini and run them as separate libraries?
    Generally YES.
    It's possible to hold separate iTunes library's on a single machine.
    Generate two new folders inside the Music folder of the Mini and name them differently; e.g. man and woman.
    Copy your whole library into "man" and your wifes into "woman"
    Go to sharing in the system settings of the Mini and share the Music folder in your network.
    After copying the whole library's to the Mini you may point iTunes to the new location at startup by holding the option key (alt) at the keyboard.
    iTunes will then ask you where the library is located.
    Point it to the matching library on the Mini.
    That's all.
    Lupunus
    PS ... If you both use only the Mini you have to setup a user account for each and just copy the whole library to the Music folder in particular.
    Message was edited by: lupunus

  • Is the license terms allow you to generate pages using Wizzard Business Catalyst and publish them on other servers. As the export side and run?

    Is the license terms allow you to generate pages using Wizzard Business Catalyst and publish them on other servers. As the export side and run?

    Our iPads work just fine behind a firewall and the Lightspeed filtering solution in an education environment.  If your proxy solution cannot be configured to support IOS maybe you should be looking at another vendor.  Products such as 8e6 and Lightspeed can be deployed without the use of a traditional proxy set up.
    http://www.m86security.com/products/web_security/m86-web-filtering-reporting-sui te-deployment.asp
    http://www.lightspeedsystems.com/products/Web-Filter.aspx

  • Activate the TRM (Task and Resource Management)

    Could you tell me where to activate the TRM (Task and Resource Management) in WM?

    Hi Stefanie,
    First, you create the TRM site in:
    SPRO>Logistics Execution>Task and Resource Management>Master Data>General Settings for TRM
    You can assign your TRM site to you warehouse number here:
    SPRO>Logistics Execution>Warehouse Management>Interfaces>Task and Resource Management>Assign Site
    And you can also activate/deactivate the interface WM-TRM for some Source Storage Types / Destination Storage Types / Movement Type:
    SPRO>Logistics Execution>Warehouse Management>Interfaces>Task and Resource Management>Control WMS-TRM Interface for Transfer Orders
    Then, you continue with the rest of TRM customizing work.
    Hope this will be helpful for you.

  • Can someone pls. Tell me how long it would take to have the iPad up and running from removing the plastic on the box?

    Can someone pls. Tell me how long it would take to have the iPad up and running from removing the plastic on the box?

    Upon applying for Telstra contract, salesman filled out all details & I was approved immed.  He grabbed a new iPad 2 from the store's stock, all plastic wrapped, a white 32 gb.  He then asked me if I needed to go and do some shopping as he had mucked something up and had to redo application.  Everything had been completed and approved on screen, so I wasn't sure why he had asked me to come back in half an hour.  I did so, and upon arriving back he was standing at the desk, iPad in hand together with receipt and box, no evidence of shrink wrap.  As I already had bought a red cover, he basically grabbed that and slipped the iPad straight into it, without really asking me, and said, all ready to go.  Was a bit surprised but accepted that.  Did not see it being unwrapped, sim inserted or anything.  Thought it to be odd, and without any further advice, was handed bag, box and receipt.  Got home, thought it looked a bit fingerprinty, then wondered why it was basically set up ready to go.  He knew I was a gadget freak, owning 25 wifi related devices, but had never bought apple products so he said I'd have no problems.  There was virtually no set up to go through except for asking if I had an apple ID which I didn't so I created that and away I went.  I was looking through the settings a bit later and noticed the ITunes said to sync back with WILLS-MSI when it was available.  WILLS is the name of the store.  There was a 32 gb white iPad 2 as a display model and now I am seriously wondering if he has taken that off the shelf and given to me.  I have never in my life bought a display model and never would.  From my description do you think I may be right? ( even the silver back looked 'not quite new').
    OPINIONS appreciated, is there anyway of checking to see if a reset has been done as I am not at all happy & will be going straight to store manager on opening of store.

  • Open PDF from database in a browser and run Javascript within PDF

    What we're trying to accomplish is to query a PDF in the database and open the PDF in the browse. Once opened if a user click on a link to open another PDF, it launchs a URL to Coldfusion, that queries the database and opens the PDF link. This all works but we also want to have the open PDF goto a section or bookmark within the PDF. We currently have JavaScripts within the PDF links that do that but only if the PDF is in the file system. We're using the app.openDoc to get a reference to the opened PDF. But when opening the PDF from the database we pass the control to Coldfusion using app.launchURL or app.getURL. These do not pass back a reference to the opened PDF and the JavaScripts fails.
    I'm looking for different methods or ideas.
    Is there another way to do this, I'm new to acrobat JavaScripting?
    Thanks, Rob

    I tried tapping and holding the attachment icon, it just shows "Open / Bookmark/ Copy"...
    Also i tried opening the attachement first and then tapping on it, it just shows "open in Safari"
    Is there any settings to be done to add the options of Opening in Adobe Reader/or any other Docu Sign app . the exhibition booth systems one would work i think
    Appreciate if someone could help

  • TS3408 I am unable to use Safari because the web pages fail to load or does not load graphics.  I am not pleased with the current Safari and will now have to use a secondary browser.

    My issues is with multiple websites.  Buttons do not work, pages do not load completly or the graphics are not visible.  I need to use another browser such as FIrefox or Chrome.

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you boot, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, reboot as usual (not in safe mode) and verify that you still have the problem. Post the results of Steps 1 and 2.

  • How to activate the song, artist and album windows so you can type in those entries

    how do you activate the windows for song, artist, album in iTunes library? I used to put the cursor over the category, double click on it, then type in the song name, artist name, album, genre etc., but that technique doesn't seem to work now.

    madappleuser94 wrote:
    So I just got a new iphone4s. I plugged it into my computer and it wiped my itunes library completely clean....
    Highly Unlikely.
    If you have Updated your version of iTunes on your computer to Sync your New iPhone...
    See here  >  http://support.apple.com/kb/TS1967
    From here  > http://www.apple.com/support/itunes/install/

  • My Macbook Pro runs VERY slow when unplugged. The battery charges and runs ok. Ran an SMC reset (no success), Safe mode (did not work), and hardware check (came back ok). What can I try next to fix this?

    Hello all,
    I am new to posting on this forum but I really hope that someone out there can help me out. I have a 13" MacBook Pro, 2.53 GHz Core 2 Duo, 4GB 1067 MHz DDR3, running OSX 10.6.8. My problem is that when I unplug the laptop form the charger and run it on the battery, the computer becomes unresponsive to any commands at all. It basically really slows down to a crawl. Even when rebooting it will take 5-10 minutes or more to do so. The odd thing is, when it gets plugged back in while any of this is going on, within a minute or two it works perfectly. It has been in a mac authorized repair shop for 7 weeks and has had a new logic board and a new hard drive replaced. The battery was tested and charges fine, holds a charge when unplugged, and the system profile shows the battery at Normal. Recently, many knowledgeable mac enthusiasts gave me tip that might help. Here is what I did: Ran an SMC reboot (no success), rebooted the computer under safe mode then unplugged it to test (no success), and ran a hardware test on the install disk (showed hardware ok)
    I am at a loss as to what to do next. It has become impossible to use this laptop for my classes when it is unplugged. I am about ready to just go buy a new one, and call this one a goner.
    I am hoping someone reading this can help with any other ideas on its problem. Help? Anyone?
    Steve

    LPBassman,
    since the tech in your IT department was able to copy your daughter’s data from her MacBook Pro’s internal disk, I’d suggest completely erasing the internal disk (using Disk Utility in Recovery mode, reformatting it with a “Mac OS Extended (Journaled)” filesystem), reïnstalling its original version of Mac OS X (either Snow Leopard from the grey Mac OS X Install DVD if it originally came with two grey DVDs, or Lion via OS X Internet Recovery if no grey DVDs originally came with it), running Software Update to get it to 10.6.8 or 10.7.5 respectively, reïnstalling Mavericks, running Software Update again to get it up to date, and finally restoring your daughter’s data.

  • I have Windows 7 and Firefox 3.6.1, when I am typing text such as email when I hit the shift key and certain letters it activates the shortcut keys and is very annoying how do I get this to stop?

    This has happened multiple times. While typing email and also in forums. This is a new computer with Windows 7 so not sure if problem is something in Windows or with Firefox. Sometimes when I hit Shift and t a new tab will open, or shift and w will cause a pop up to come asking if I want to navigate away from this window. I have had other things pop up as well but not sure what they were or what keys I hit that caused them to show up. It tends to happen as I am typing faster. But when this happens, such as the shift t thing, I will close the tab and go back to what I was typing. Watching carefully that i am not hitting the ctrl key I hit shift t and the new tab will pop up again. The only way to get this to stop is to hit the esc key then I am able to to type fine again until it starts again. Once I was typing and my entire text highlighted and disappeared and I lost everything, so yes it can be extremely annoying. Hopefully someone can help me to solve this problem.

    Yes, I have rebooted the computer several times. Logged off for the night and login this morning.
    It still is happening.
    It happens when I type a message in yahoo; when I login to yahoo, both trading platforms and several other applications.
    After a while it stops - don't know if there is a key I strike that deactivates what every it is that is making the the keys perform the shortcut function. Sometimes by hitting ESC more than 4 times but less than 10 seems to stop it (or so it appears as the next time I type a msg in Yahoo mail the keys don't activate the toolbar "edit" function. Sometimes striking the backspace key over and over again when there is nothing to delete appears to stop it from happening.
    Anymore suggestions? Greatly appreciated. Tired of retyping 3 or more times. Have gotten to the point where I type in word or notepad and paste my username and password into the appropriate areas or into the message area.
    Will capture image next time.

  • Mac won't start following change of permissions. I have started In recovery and run repair disk and reset permissions to all disks inc backups. What do I do now to get the mac up and running without loosing thousands of pics and all other data? I

    The problems occurred after photoshop elements said I did not have the necessary permissions to save changes to a photo. I then allowed all to permissions to all disks, I have three external hard drives but I cannot restore from any as they all appear to have some kind of problem. I have repaired all disks in recovery mode and verified all inc mac hd. All permissions are repaired and all disks are saying repaired. So where do I go from here to get the mac back on running mavericks without loosing thousands of photos and all other data ?
    Do I need to reinstall Mac OS ?
    The only options I get to reinstall is mountain lion?.. I have been running the latest mavericks .?.
    Do I reinstall and then update?
    The external drives are not smart drives so how do I ensure I retain all my files?

    your best option is to connect an external drive and reinstall OS X on that external to run the system from. then copy all your files over to the new install for safe keeping. then try doing a reinstall of Mavericks over the top of the current install on the internal drive and test.

  • Delaying a function so ADF will get all the selected rows and run only 1 time ?

    Hello,
    I'm using JDeveloper 12.1.2.0.0.
    I have a group of functions that are executed after i click on one or more rows, which is called:
    public void onDimProjectSelect(SelectionEvent selectionEvent)
    Whenever i shift-click some rows (lets say, for the purpose of this example, that i shift-click the 1st row to the 5th row, so i shift select and i get selected the rows: 1,2,3,4 and 5).
    I did notice that what happens is that the function onDimProjectSelect will execute with the 1st row, and after it runs all the functions, it will run again the function onDimProjectSelect with the 1, 2, 3, 4 and 5 rows as it should in the first place.
    Why is this happening? I've tried to add a delay but i did not work.
    This is really a pain because its spending time executing a function without all of the rows that is suppose to have, so it will run again.
    I think the problem here is how ADF does the selections for the function but i don't know how to change it.
    Any ideia of why is this happening? What can i do to correct this?
    Regards,
    Frederico.

    Hey Frank,
    I mean that my function onDimProjectSelect has other functions inside that need to be executed so when i say that is runs all the functions i mean the functions that are suppose to execute when onDimProjectSelect is executed.
    Maybe the problem is my implementation approach but it was required to use the selection. But the funny part is that i select with the shift-click and he knows that, since it will run the function with all the rows that are selected but firstly he will execute the function with just the first selected row.

Maybe you are looking for