Apple Script "do when pressed" command?

hey guys i need the right command that would activate a script once i press F1 (for example)
So it should be smthg like:
If F1 is pressed Then
     tell application "System Events"
          keystroke "123"
          keystroke tab
          keystroke "134"
     end tell
else
     do nothing
end if
and i save the script under what?
     I need it to work either in text edit- pages- safari.... ect... (wherever there's a text box)
THANK YOU

To run a terminal command it is usually sufficient to use do shell script. So for your command it would be
do shell script "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4"
note if the command requires administrator privileges you would need to do
do shell script "command"  with administrator privileges
will prompt for the password when the script is run.
do shell script "command" user name "me" password "mypassword" with administrator privileges
will store the password and username in the script. More convenient but much less secure.
See do shell script in AppleScript

Similar Messages

  • Iphoto window reduces when pressing command

    hi,
    I got into the habit of pressing command & holding down command & click on thumbnails to select several pics for emailing etc.  lately, when I press command the whole window reduces & only goes back to full screen after tapping the trackpad again. sometimes I loses the selecting altogether from tapping the trackpad.
    How can I rectify this little annoyance ?
    cheers
    HH

    Sounds like a trackpad issue.  Try changing  the trackpad preferences for sensitivity or speed.  If that fails delete the preference file that the trackpad uses.  I don't know which one it will be as I don't have a trackpad.  Go to the form for your particular Mac, Macbook Pro, iMac, Macbook, etc. and ask there for which preference file to delete.
    You can first try the following but I'm not sure it's relevant to the problem. It won't hurt to try, though:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
    User/Home/Library/Caches/com.apple.iPhoto folder (Snow Leopard and Earlier).
    or with Mt. Lion from the User/Library/Containers/com.apple.iPhoto/
    Data/Library/Caches/com.apple.iPhoto folder
    3 - launch iPhoto and try again.
    NOTE 1: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    NOTE 2:  In Lion and Mountain Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    OT

  • Imac-when pressed command H, word doc was locked .can't open. What to do?

    Hi
    Working onimac in WORD with a big document. When I pressed command H the doc went to its folder on desktop and will not reopen. How do I fix that , ie make it reopen.
    What did command H do? when I click on the doc it will not reopen.
    I may have hit control H like on a PC (to bring me to the top of the first page= home).
    If so, how would I fix that . Need to open a very big doc and keep working.

    Command-H hides the document.  Command-Tab brings you back to Microsoft Word.  Your document isn't lost.  You just simply switched to the Finder.  In Microsoft's infinite wisdom, they didn't make command-H the same as minimize, and hence why you are probably lost.  It doesn't minimize the window to the dock, which would make it easier to access.   Don't use command-H unless you really want to hide and switch applications.  This discussion explains alternatives.

  • How to make Apple Script do a terminal command

    Hey,
    I am wondering how can I make an AppleScript do the following command :
    "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4"
    Please mention step by step since I'm new to AppleScript
    Best Regards,
    Nadav.

    To run a terminal command it is usually sufficient to use do shell script. So for your command it would be
    do shell script "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4"
    note if the command requires administrator privileges you would need to do
    do shell script "command"  with administrator privileges
    will prompt for the password when the script is run.
    do shell script "command" user name "me" password "mypassword" with administrator privileges
    will store the password and username in the script. More convenient but much less secure.
    See do shell script in AppleScript

  • HT201376 Nothing happens when pressing Command+R during reboot

    I am trying to do a factory reset on my computer, and I have tried at least 30 times to restart and hold down the Command+R Keys and absolutely nothing happens.  I have tried during different intervals during the reboot, and have tried doing it after a shut down and startup.  Nothing happens at all. I have done it at least 15 times when the white screen with the apple pops up.  I have waited for the "wait" symbol to try it.  What am I missing?! Why won't this work? I cannot get to the point where I can erase everything.  When I go in manually through the disk utility, it will not let me erase this way.  Help!

    do I need that DVD? or can I upgrade to the newest version, would I then be able use the command R option for bringing up the disk utility partition?
    What exactly are you trying to do?
    OS X Lion and above includes the addition of a Recovery partition (not a "disk utility partition"). If you had OS X Lion or above, then Command-R would boot the Mac to the Recovery partition. From that partition, you could then run the Disk Utility application.
    With 10.6.8, you can boot from the DVD (Hold down the C key while restarting), once done, you could also run the Disk Utility application.
    Note: There is no way that we can tell whether you can upgrade from 10.6.8, since you haven't provided any specific information about your Mac other than it is a MacBook.

  • How do I run an Apple Script only when the computer is awake at the specified time and NOT upon waking after the specified time?

    I've been using Steve Lambert's SelfControl to block myself from certain time-sucking internet sites for a certain period of time every day. I've automated the program launch using an AppleScript that runs based on an iCal alarm, but the problem is that if my computer has been asleep or shut off, the script will run as soon as I wake it up or start it up, and that can be very inconvenient if I'm intending to use my computer not during the hours when I intended to restrict access to such websites.
    So, is there any way to schedule an AppleScript to run *only* if the computer is running at the designated time and not upon waking/starting up after the alarm has passed if the computer was asleep/off?
    I started investigating launchd, as I understand this is the successor to cron/crontab in OS X Lion, but it appears that launchd has the same behavior I dislike in the iCal alarm approach--the script will run upon waking even if the time when it was supposed to run has already passed...unless there is a way to change this behavior?

    The obvious/easy solution would be to add some logic to the script to see what the time is.
    If you expect the script to run at, say, 1pm, but the script checks the time and sees that it's 5pm then you can assume the machine was asleep at the time and thefore you can bail out gracefully.
    if (hours of (get current date)) = 13 then
      -- it's sometime in the 1pm hour...
    end if
    You can fine-tune the check as much as you like

  • Sending email using apple script...

    I have created a watch folder using apple script that when a file is dropped on it, it automatically opens, formats, and sends out a custom email.
    What I don't understand is, how can I include multiple variables in the "content" section (also known as the body section of the email)? I want to put custom type in the content section that says "There is a file awaiting your review." I also would like to choose an email signature from my mail program to use. Third, I would like to include the name of the file that is being sent....
    I found that by doing {content:iteminfo} I could get the file name...If I do {content:"There is a file awaiting your review."} I could get the custom type I wanted....
    BUT, I can't figure out how to get BOTH of them together in ADDITION to adding a custom email signature...
    I know there are some really smart people out there...Any tips?

    I can't figure out how to get BOTH of them together
    This is just standard AppleScript text concatenation with the &:
    ... {content: "There is a file awaiting your review: " & iteminfo}
    Here you can see I'm concatenating a literal string (enclosed in quotes) and a variable. You can extend this ad infinitum.
    As for the signature:
    tell theMessage to set message signature to signature "My Sig"
    (which assumes you have a signature named 'My Sig'. Adjust as necessary.

  • My mini ipod appears off and not respond to any commands when pressed the buttons to reset, apple logo appeared and then the apple support site and it shuts down. already tried all the steps, but none worked, and when I plug it into my computer it does no

    My mini ipod appears off and not respond to any commands when pressed the buttons to reset, apple logo appeared and then the apple support site and it shuts down. already tried all the steps, but none worked, and when I plug it into my computer it does not appear in the iTunes bar. what do I do?

    If MacKeeper corrupted the Recovery partition then even I underestimated its potential for damage. Garbage "cleaning" apps will cause misery but I have not found that the Recovery partition to have been affected by using MacKeeper or anything like it. I doubt that it did so, but I have learned not to underestimate the potential for such things to result in system corruption.
    Before concluding your Mac has a hardware failure, try booting OS X Internet Recovery by holding command option r on startup (three fingers). That will force your iMac to bypass the Recovery partition altogether, and convey the ability to create a new one.
    An Internet connection will be required (wired or wireless).
    At the Mac OS X Utilities screen, select Disk Utility. Select your startup volume (usually named "Macintosh HD") and click the Repair Disk button. Describe any errors it reports in red. If Disk Utility reports "The volume Macintosh HD appears to be OK" in green then you can be reasonably (though not completely) assured your hard disk is in good working order.
    Assuming the HD remains usable you can then use Disk Utility to erase it. Reinstall OS X, restore your essential software and other files, and don't reinstall the junk.

  • HT4718 I can't reach recovery system when I reboot- I press 'command' and 'r' quickly, but nothing happens, the progress bar begins to load... Any thoughts?

    I can't reach recovery system when I reboot- I press 'command' and 'r' quickly, but nothing happens, the progress bar begins to load... Any thoughts? It gets about halfway through loading and then stops, no mouse, no nothing. I think I'll be able to move past it if I can reach the Recovery options.
    Thanks!

    If you are really sure that it's impossible to click in Recovery mode, then something is wrong with the machine.
    Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.
    Back up all data on the internal drive(s) before you hand over your computer to anyone. There are ways to back up a computer that isn't fully functional — ask if you need guidance.
    If privacy is a concern, erase the data partition(s) with the option to write zeros* (do this only if you have at least two complete, independent backups, and you know how to restore to an empty drive from any of them.) Don’t erase the recovery partition, if present.
    Keeping your confidential data secure during hardware repair
    Apple also recommends that you deauthorize a device in the iTunes Store before having it serviced.
    *An SSD doesn't need to be zeroed.

  • I pressed command d when starting my macbook air but i pressed it for too long and now it is searching for something? heeelp please!!!!

    pleeeasee help!!! i dont know what to do! at first, i was just cleaning my macbook keyboard and i pressed something that changed keyboard language, but i checked everything and it all said that everything was alright, later, i turned off macbook- in hope that when i turned it on, everything would be normal, but then,  i couldn't even sing in my account  because i had a password set on it, and every time i try typing the password it types something completely different, and then, i read a post, that in cases like this, we should press command+d while the computer is turning on, and let release the keys as soon as i see grey screen. BUT (i am so dumb) that i pressed it longer... and now, i don't know what it is doing, but i's telling me to choose network, but when i am trying to choose it, and  write the password, it doesn't do  anything! pleasee help me somehow!!!

    It is easy to change the keyboard language by pressing apple/command plus space.
    What other keyboards besides US did you have activated on your machine?

  • I bought my iphone 5s a week before and now its volume "up" button is not working when pressed.Does anybody know what to do to make it work?I have a one year warranty.Should i give it to apple retail shop or is there any way to solve this problem?

    I bought my iphone 5s a week before and now its volume "up" button is not working when pressed.Does anybody know what to do to make it work?I have a one year warranty.Should i give it to apple retail shop or is there any way to solve this problem?

    IF it is a manufacturing defect and you bought the device from Apple or an authorized Apple retailer, then take it into Apple.

  • I am from Bangladesh. I can't log in with my gmail Apple ID. When I put in the mail and password, and press sign in, it says it has to review on iTunes. Then I am directed to opening a new account. But why should I , since I have one. Plz help :(

    I am from Bangladesh. I can't log in with my gmail Apple ID. When I put in the mail and password, and press sign in, it says it has to review on iTunes. Then I am directed to opening a new account. But why should I , since I have one. Plz help

    Hi Ishrak,
    I apologize, I'm a bit unclear on exactly what you are trying to log into with your Apple ID, or what exactly you are seeing (alert message, directions, etc) when you try to do so. If you continue to have issues with your Apple ID, you may find one or more of the articles linked from the following page helpful:
    Apple ID - Apple Support
    Regards,
    - Brenden

  • Can I use Apple Script to press a button?

    Is there some way I can create an Apple Script to run and press a button in another application, or create a "plug-in" type script for the program to make the button into a something that can be used by a keyboard shortcut?
    I ask because I have an application that I can use to operate my digital camera, however, the button that Auto-Focuses then Shoots a photo does not have a keyboard shortcut. This is a problem because I also have the App "Snatch" on my iPhone, and, long story, short, I discovered I could use Snatch on my laptop on an Ad-Hoc network from about 1,000 feet away, maybe more. If I could find a way of making the "AF and Shoot" button into a keyboard shortcut, or create a script that could be triggered by a keyboard shortcut to press the button, I could use Snatch to control my camera remotely, far better then any part I would by from Nikon, or a third-party (Trust me, I have used a lot of them, and this method beats them all, save for the fact that I can't use bulb.)
    Anyway, thanks for any input, if any.

    Even if an application is not scriptable, you can generally use [GUI Scripting|http://www.macosxautomation.com/applescript/uiscripting/index.html] to press a button. For example, using Canon's RemoteCapture DC software, the script below will press the "Release" button of the main window:
    tell application "RemoteCapture DC" to activate
    tell application "System Events"
    tell process "RemoteCapture DC"
    click button 4 of window "RemoteCapture DC"
    end tell
    end tell
    If you then put the above script in the AppleScript menu in the menu bar, you should be able to use a third party application, like Quicksilver, to assign a keyboard shortcut to it.
    Message was edited by: Pierre L.

  • I updated my iMac to Mountain Lion. All the files were deleted. I have Time Machine backups. When I restart the mac pressing Command R to restore from backup it shows the previous OS X (Leopard) beside the date of the backup. Will it go back if I restore?

    I updated my iMac to Mountain Lion. All the files were deleted. I have Time Machine backups. When I restart the mac pressing Command R to restore it from the backup it shows the previous OS X (Leopard) beside the date of the backup that I want to select. Will it go back to Leopard if I restore it from the backup?

    No, it won't revert to the prior OS X but you you may have third party apps installed that were compatible with Lion that may not be compatible with Mountain Lion.
    App Compatibility Table - RoaringApps - App compatibility and feature support for OS X & iOS
    After you restore from TM, check HD > Incompatible Software

  • Sudo command in apple script? Encrypting apple script?

    Hi,
    1. I need a way to enter my root user password in applescript (when you run sudo in terminal you are prompted for a password, this is not so in apple script. So how do you tell apple script what the password is?)
    2. Can i encrypt my applescript with a password so that only i can open it?
    Thanks,
    Patrick.

    # 2 works great, #1 not so much... ive been trying
    tell application "Terminal"
         do shell script "su"
    end script
    any way i can auto enter my password following "do ....Su"?

Maybe you are looking for

  • RMI exception calling web service from proxy class

    I am getting the following error attempting to call a web service from a proxy. It appears to relate to the type of objects I am trying to send vs the type that is expected. Following the exception I am adding a copy of the control where calling the

  • HT1386 AFter installing Windows 8 on PC the PC no longer will sync with my ipad Shuffle. I tried deauthorizing and reauthorizing but it did not help.

    After inc with my ipad Shuffle.nstalling WIndows 8 (I had to reformat C:), iTunes will no longer sync with my ipod shuffle. I had to deauthorize itunes before installing Windows 8, and then reauthorized it after reinstalling it. It syncs with my new

  • PR - Pending for Release

    Hi Friend, i) How can I get the list of Purchase Requisition which are pending for release. ii) Is it possible to set reminder, if the PR is not released at one level for say 10 days, to go to next level? What is the use of tcode ME5F? Munna

  • Error in purchase

    Yesterday I try to purchase a subscription. I wrote my credit cart data and I received a charge, but I can not download anything. I run purchase process again and get another charge but I can not download anything. I look up for help but it was late

  • Using Formatting Objects Processor ....

    Нi All! I have a data stored in my DB in UTIF-8. I' m using Formatting Objects Processor to transform Oracle APEX 2.2.report output into PDF document. It's a dust on the screen after loading my report in Adobe Photoshop. The text on the screen in CP1