IPAD must-haves. And fun-to-haves.

Brighten your iPad with a colorful cover, stream to your TV, download pictures from your digital camera, and more. There’s already so much you can do with iPad and iPad mini

Apple Wireless Keyboard

The incredibly thin Apple Wireless Keyboard uses Bluetooth technology, which makes it compatible with iPad

Apple unveils iPad mini: ‘Thin as a pencil, light as paper’

iPad inspires creativity and hands-on learning with features you won’t find in any other educational tool

Lightning connector and FaceTime HD camera

Apple announces 4th generation iPad packing an A6X CPU

Pages

Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Monday, September 16, 2013

bash script

I have a nicely working bash script, and want to change the default setting so that it will run on a double-click, but don't know the proper "open by" name. Please?


View the original article here

bash script

I have a nicely working bash script, and want to change the default setting so that it will run on a double-click, but don't know the proper "open by" name. Please?


View the original article here

Monday, September 9, 2013

Apple script stops running program

Im am working on a project in apple script where basically you can talk to the computer in a way by pressing buttons for your response. But that is no the important part.... Whenever I try to run it it stops running at a certain point. Why is this?


View the original article here

Sunday, September 8, 2013

Apple script stops running program

Im am working on a project in apple script where basically you can talk to the computer in a way by pressing buttons for your response. But that is no the important part.... Whenever I try to run it it stops running at a certain point. Why is this?


View the original article here

Sunday, June 16, 2013

Need Help With Apple Script

I am trying to make an apple script that will detect when an application (minecraft) is open and then bring up a dialog that wont go away so that only I.T. can remove it.

 

It's a school project that im working on, we have to figure out a way (through applescript) to help students be more productive, everyone else has no experience with apple script but me. I managed to create this in a couple of minutes but there is a couple glitches and problems i cant solve.

 

here's the script:

 

repeat

     if appIsRunning("Minecraft") then

          display dialog "Gaming is not allowed, Your log of your computer programs running has been emailed to the I.T. department. Please visit the I.T. department immedietly to remove this message" buttons {"Report To I.T."} default button 1 with title "Gaming Alert" with icon stop

     end if

     tell application "Minecraft"

  quit

     end tell

end repeat

on appIsRunning(appName)

     tell application "System Events" to (name of processes) contains appName

end appIsRunning

end

 

it works ok...

exept for the fact it works on every application exept minecraft...

Minecraft just freezes and then the script just says error.

 

Im also trying to design a way that applescript will send an email to the school I.T. desk with the students user name. I have this so far...

 

tell application "Mail"

     set theNewMessage to make new outgoing message with properties {subject:"Gaming Alert [username here]"

  , content:"[username here] has been gaming, he is to report to I.T. by the end of the day", visible:true}

     tell theNewMessage

  make new to recipient at end of to recipients with properties {address:"itdesk@blahblahblah.net"}

  send

     end tell

end tell

 

exept the school uses office 365 mail not inbuilt mail, is there any way to make this work?

 

My key issues are

 

1. how to fix the bug

2. how can i combne the scripts?

3.will this work for other games?

4.Can this work with online email bases

5.any other genreral comments on the scripts.


View the original article here

Re: Need Help With Apple Script

  1. You didn't provide any information about the error, so I can't verify it since I don't have MineCraft to test.  I can't see any reason off hand why the application would hang, although your script will wait until the dialog is dismissed before continuing with the rest of the script.
  2. As hinted to above, you will need to quit the applications and send the email before putting up the dialog, since the script/application will wait while the dialog is up.
  3. Just add other application names to check for.
  4. To use other email clients you will need to use whatever scripting commands or other API they provide.

 

The following script application should combine your previous examples and allow for multiple applications - save it as a stay-open application.  You should also add a LSUIElement key set to true in the application Info.plist so that it doesn't show a menu or appear in the Dock.

 

 

property illegalApps : {"MineCraft"} -- add application names as needed

property longName : missing value

property shortName : missing value

 

on run -- setup

  tell (get system info)

    set longName to long user name -- for use in the email message

    set shortName to short user name -- for use in the shell script

  end tell

end run

 

on idle -- repeatedly executes after the run handler completes

  tell application "System Events" to set appList to get name of processes whose background only is false

  set editedList to {}

  repeat with anApp in appList -- filter for illegal apps

    set anApp to contents of anApp

    if anApp is in illegalApps then set end of editedList to anApp

  end repeat

  if editedList is not {} then notifyAndQuit(editedList) -- illegals found

  return 60 -- do it again in 60 seconds

end idle

 

on notifyAndQuit(quitList)

  tell application "Mail" -- send mail

    set theNewMessage to make new outgoing message with properties {subject:"Gaming Alert [" & longName & "]", content:"[" & longName & "] has been gaming, he is to report to I.T. by the end of the day", visible:true}

    tell theNewMessage

      make new to recipient at end of to recipients with properties {address:"itdesk@blahblahblah.net"}

      send

    end tell

  end tell

 

  repeat with anApp in quitList -- kill user processes with extreme prejudice

    do shell script "killall -9 -u " & shortName & " -c " & quoted form of anApp

  end repeat

 

  activate me

  display dialog "Gaming is not allowed, Your log of your computer programs running has been emailed to the I.T. department. Please visit the I.T. department immedietly to remove this message" buttons {"Report To I.T."} default button 1 with title "Gaming Alert" with icon stop

end notifyAndQuit



View the original article here

Thursday, March 28, 2013

syntax for do shell script output displayed as list in applescript


Hi guys,


I am looking for the correct syntax for a


do shell script command in applescript,


where the results of the do shell script command are displayed as a list in applescript,


whereupon i can then choose one of these given results and move on from there, this is where i have gotten to:





my issue is that the results are as follows when done in terminal:



but when done in applescript i only see this:



obviously the terminal results need to be handled in some special manner that i am unaware of,


to handle each line in the terminal results as a single option in my list. Anyone got any idea how to do this?


cheers


View the original article here

Thursday, March 21, 2013

Re: Applescript/Shell Script reference to the app itself


figured it out mate, my sound output app had a space in the name which was making applescript skitz out, i just placed an underscore to make it sound_output and all problems were solved, thx dude you're a legend, also had to remove SwitchAudioSource as it was now redundant, here is the finished and working script, thankyou so much for your help:



View the original article here

Applescript/Shell Script reference to the app itself


Hi guys,


i have made an applescript with the following source code:


"


set sound_output to button returned of (display dialog "Select Output Source" buttons {"Computer", "TV"} default button "TV")


if sound_output is "Computer" then do shell script ("cd /Applications/SwitchAudioSource-v1; ./SwitchAudioSource -s 'Built-in Output'")


if sound_output is "TV" then do shell script ("cd /Applications/SwitchAudioSource-v1; ./SwitchAudioSource -s 'HDMI'")


"


I am wondering if there is a way to refer to the abovementioned executable ./SwitchAudioSource (currently located in /Applications) in my compiled applescript somewhere? That is:


Show Package Contents > Contents > Resources > and dump the executabe ./SwitchAudioSource here, and then modify my script to somehow refer to within itself so that my applescript will work regardless of where i place it. Desktop, /Users, even pictures,


i hope this makes sense, thankyou for all your help in advance, cheers mate 


View the original article here

Wednesday, March 20, 2013

syntax for do shell script output displayed as list in applescript


Hi guys,


I am looking for the correct syntax for a


do shell script command in applescript,


where the results of the do shell script command are displayed as a list in applescript,


whereupon i can then choose one of these given results and move on from there, this is where i have gotten to:





my issue is that the results are as follows when done in terminal:



but when done in applescript i only see this:



obviously the terminal results need to be handled in some special manner that i am unaware of,


to handle each line in the terminal results as a single option in my list. Anyone got any idea how to do this?


cheers


View the original article here

Thursday, March 14, 2013

Applescript/Shell Script reference to the app itself


Hi guys,


i have made an applescript with the following source code:


"


set sound_output to button returned of (display dialog "Select Output Source" buttons {"Computer", "TV"} default button "TV")


if sound_output is "Computer" then do shell script ("cd /Applications/SwitchAudioSource-v1; ./SwitchAudioSource -s 'Built-in Output'")


if sound_output is "TV" then do shell script ("cd /Applications/SwitchAudioSource-v1; ./SwitchAudioSource -s 'HDMI'")


"


I am wondering if there is a way to refer to the abovementioned executable ./SwitchAudioSource (currently located in /Applications) in my compiled applescript somewhere? That is:


Show Package Contents > Contents > Resources > and dump the executabe ./SwitchAudioSource here, and then modify my script to somehow refer to within itself so that my applescript will work regardless of where i place it. Desktop, /Users, even pictures,


i hope this makes sense, thankyou for all your help in advance, cheers mate 


View the original article here

Thursday, February 28, 2013

Apple Script for copying a "part" from one txt file to a new txt file

I have a txt file which has data written in a particular format as below:

random data 1<\MyTag>random data 2<\MyTag>random data n<\MyTag>

 

My requirement is to copy the data within each tags to a separate file . eg: File1 should have random data 1<\MyTag>, File2 should have random data 2<\MyTag> and so on.

 

Please help..!!


View the original article here

Tuesday, February 26, 2013

Run Preinstall Script in PackageMaker

I'm using PackageMaker to install an app update and want to add a preinstall script to delete some files in the /Applications/ folder. The script is simply:

#!/bin/bash rm /Applications/...

etc.

If I run this script with Terminal using

bash preinstall.sh

it works fine.

However, when I add it to PackageMaker and run the .mpkg file the script opens in Text Edit but does not run. How do I get it to run but not open?


View the original article here

Tuesday, February 5, 2013

Help Expected end of line, etc. but found end of script.

here is the sctipt ive tried to write, its not finished so some of the things my seem a bit weird at the moment but here it is as it stands

 

global okflag

set okflag to false

set front_app to (path to frontmost application as Unicode text)

 

-- check if iTunes is running

tell application "System Events"

          if process "iTunes" exists then

                    set okflag to true --iTunes is running

          end if

end tell

 

if okflag is true then

 

          set Timer to ""

  display dialog "Sleep Time (Minutes)" default answer Timer buttons {"Cancel", "OK"} default button 2

          set Timer to text returned of the result

 

          delay Timer * 60

 

          tell application "iTunes"

                    set currentVolume to the sound volume

                    if (player state is playing) then

                              repeat

                                        --Fade down

                                        repeat with i from currentVolume to 0 by -1

                                                  set the sound volume to i

                                                  delay 1

                                        end repeat

                                        pause

                                        --Restore original volume

                                        set the sound volume to currentVolume

                                        exit repeat

                              end repeat

 

                    if okflag is false then

 

                    display dialog "iTunes not playing" buttons {"OK"} default button 1 with icon stop

 

                    end if

                    end

 

it doesnt seem to work after the tell "iTunes part i copied and pasted from another applescript

(the purple text)


View the original article here

Saturday, February 2, 2013

Apple script editor keeps rejecting my custom command as undefined parameter? What am I doing wrong?

I am trying to make an application apple scriptable. I have created a scripting definition by copying mail.sdef and modifying it to suit my needs as the documentation recommends. My app suite at this point only has one command in it. Here is the definition:

name="NAZone" code="NAZN" description="Classes and commands for the Zone application">

 

  name="accountLogin" code="zONeLgIn" description="Triggers account login.">

            class="LoginCommand"/>

  name="loginName" code="naun" type="text" optional="no" description="Specify the username for the account that you wish to log into">

  key="LoginName"/>

 

            name="passwordStr" code="napw" type="text" optional="no" description="Specify the account password you wish to log into">

  key="PasswordStr"/>

 

 

 

 

 

 

 

I am not sure what is wrong with my definition above, but AppleScript Editor keeps complaining: "Expected end of line but found identifier." at the statement where command is invoked. Here is how my test sript looks like:

tell application "NAZone"

    launch

          try

          accountlogin loginName "test@mail.com" passwordStr "abcdef12345"

          on error errStr number errNum

          display dialog errStr & errNum

          end try

end tell

 

AppleScript Editor complains anything following the command name. I don't think my command is somehow recognized.

I new to making applications scriptable as well as apple scripting.


View the original article here

Re: Apple script editor keeps rejecting my custom command as undefined parameter? What am I doing wrong?

Does your app show up in the Applescript Dictionary and if so what does it show for it?


View the original article here

Re: Apple script editor keeps rejecting my custom command as undefined parameter? What am I doing wrong?

Does your app show up in the Applescript Dictionary and if so what does it show for it?


View the original article here

Apple script editor keeps rejecting my custom command as undefined parameter? What am I doing wrong?

I am trying to make an application apple scriptable. I have created a scripting definition by copying mail.sdef and modifying it to suit my needs as the documentation recommends. My app suite at this point only has one command in it. Here is the definition:

name="NAZone" code="NAZN" description="Classes and commands for the Zone application">

 

  name="accountLogin" code="zONeLgIn" description="Triggers account login.">

            class="LoginCommand"/>

  name="loginName" code="naun" type="text" optional="no" description="Specify the username for the account that you wish to log into">

  key="LoginName"/>

 

            name="passwordStr" code="napw" type="text" optional="no" description="Specify the account password you wish to log into">

  key="PasswordStr"/>

 

 

 

 

 

 

 

I am not sure what is wrong with my definition above, but AppleScript Editor keeps complaining: "Expected end of line but found identifier." at the statement where command is invoked. Here is how my test sript looks like:

tell application "NAZone"

    launch

          try

          accountlogin loginName "test@mail.com" passwordStr "abcdef12345"

          on error errStr number errNum

          display dialog errStr & errNum

          end try

end tell

 

AppleScript Editor complains anything following the command name. I don't think my command is somehow recognized.

I new to making applications scriptable as well as apple scripting.


View the original article here

Wednesday, January 23, 2013

Can I embed a full shell script inside an applescript?

I have a friend who is running Tiger on a PPC Mac and wants to download a large number of files from the web. Unfortunately, this friend is barely able to do basic web browsing with Safari or Firefox.

 

I thought of just sending him a shell script with a lot of curl commands, but I don't suppose making it executable on my Mac would make it executable on his. I would like to be able to send him an Applescript that he could just run by clicking on it, but it would be awkward to make each curl command a separete shell script within the applescript..

 

Is there a way of directly including in an applescript a multi-line shell script as a single entity that invokes only one shell? I know I can do it by putting the shell script in a separate file and have the applescript give it the necessary permissions, but then I'd have to explain to my friend where to put the shell script!


View the original article here

Re: Can I embed a full shell script inside an applescript?

The path to resource command has an optional in directory parameter that can be used to get resources in subdirectories such as the Scripts folder - see the StandardAdditions scripting dictionary.


View the original article here