Can anybody fix this apple script for me so all the responses work
iv been working on a jarvis wake up script and iv continued to add on commands to if theResponce parts of the script but now most of them wont work and i get a syntax if i dont have like 8 end if's at the end of the script could somebody please overview it, fix the script and resubmit it to me in the comments. will be so grateful if somebody fixes this pleasee.!!!!
set theHours to hours of the (current date)
if theHours > 18 then
say "good evening sir"
else if theHours > 12 then
say "good afternoon sir"
else if theHours > 6 then
say "good Morning sir"
else if theHours > 0 then
say "get out of bed sir!"
end if
say "It is " & getTimeInHoursAndMinutes() using "Tom"
on getTimeInHoursAndMinutes()
set timeStr to time string of (current date)
set Pos to offset of ":" in timeStr
set theHour to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
-- Get the "minute"
set Pos to offset of ":" in timeStr
set theMin to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
--Get "AM or PM"
set Pos to offset of " " in timeStr
set theSfx to characters (Pos + 1) through end of timeStr as string
return (theHour & ":" & theMin & " " & theSfx) as string
end getTimeInHoursAndMinutes
set CityCode to 1098081
set t_format to "C"
set v_format to "S"
set a_format to "Y"
set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode
set file_content to (do shell script "curl " & IURL)
--looking for the line with actual condition
set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText
set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1
set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b
if t_format is equal to "C" then
set actual_temp to (5 / 9) * (actual_temp - 32) as integer
end if
set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText
set today_min_temp to word 9 of sub_2
set today_max_temp to word 12 of sub_2
if t_format is equal to "C" then
set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
end if
set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4
set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5
set tomorrow_min_temp to word 9 of sub_6
set tomorrow_max_temp to word 12 of sub_6
if t_format is equal to "C" then
set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
end if
set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8
if a_format is equal to "Y" then
say "The current conditions in Perth are " & actual_condition & " ,and the current temperture is " & actual_temp & " degrees"
end if
if v_format is equal to "L" then
say "Today it will be : " & today_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees .
Tomorrow we are expecting it to be: " & tomorrow_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees " using "Tom"
else
say "Today it will be : " & today_forecast & ", between " & today_min_temp & " , and " & today_max_temp & " degrees .
Tomorrow we are expecting it to be: " & tomorrow_forecast & ", between " & tomorrow_min_temp & " ,and " & tomorrow_max_temp & " degrees " using "Tom"
say "will that be all sir?"
tell application "SpeechRecognitionServer" to set theResponse to listen for {"get my mail ", "yes", "notes", "repeat", "Music", "Sleep in"}
if theResponse is "Sleep in" then
delay 6
say "Time to get up sir,or you will be late"
tell application "SpeechRecognitionServer" to set theResponse2 to listen for {"Ok pat im getting up"}
if theResponse2 is "Ok pat im getting up" then
set volume 35
tell application "iTunes"
set the sound volume to 0
play user playlist "Wake up"
repeat 10 times
if sound volume is less than 40 then
set sound volume to (sound volume + 10)
delay 2
end if
end repeat
end tell
if theResponse is "Music" then
set volume 20
tell application "iTunes"
set the sound volume to 0
play user playlist "Wake up"
repeat 10 times
if sound volume is less than 60 then
set sound volume to (sound volume + 10)
delay 2
end if
end repeat
end tell
if theResponse is "yes" then
delay 1
set theOptions to {"very good, sir, have a nice day"}
set theChoice to some item of theOptions
say theChoice displaying theChoice with waiting until completion
end if
if theResponse is "get my mail " then
tell application "Mail" to launch
end if
if theResponse is "notes" then
tell application "Stickies" to launch
end if
if theResponse is "repeat" then
set CityCode to 1098081
set t_format to "C"
set v_format to "S"
set a_format to "Y"
set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode
set file_content to (do shell script "curl " & IURL)
--looking for the line with actual condition
set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText
set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1
set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b
if t_format is equal to "C" then
set actual_temp to (5 / 9) * (actual_temp - 32) as integer
end if
set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText
set today_min_temp to word 9 of sub_2
set today_max_temp to word 12 of sub_2
if t_format is equal to "C" then
set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
end if
set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4
set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5
set tomorrow_min_temp to word 9 of sub_6
set tomorrow_max_temp to word 12 of sub_6
if t_format is equal to "C" then
set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
end if
set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8
if a_format is equal to "Y" then
say "The current conditions in Perth are " & actual_condition & " ,and the current temperture is " & actual_temp & " degrees"
end if
if v_format is equal to "L" then
say "Today it will be : " & today_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees .
Tomorrow we are expecting it to be: " & tomorrow_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees " using "Tom"
else
say "will that be all sir?"
tell application "SpeechRecognitionServer" to set theResponse3 to listen for {"get my mail ", "yes", "notes", "Music"}
if theResponse3 is "Music" then
set volume 20
tell application "iTunes"
set the sound volume to 0
play user playlist "Wake up"
repeat 10 times
if sound volume is less than 60 then
set sound volume to (sound volume + 10)
delay 2
end if
end repeat
end tell
else
if theResponse3 is "get my mail " then
tell application "Mail" to launch
end if
if theResponse3 is "yes" then
delay 1
set theOptions to {"very good, sir, have a nice day"}
set theChoice to some item of theOptions
What you do in this situation, is split the file into parts.
Start with:
set theHours to hours of the (current date)
if theHours > 18 then
say "good evening sir"
else if theHours > 12 then
say "good afternoon sir"
else if theHours > 6 then
say "good Morning sir"
else if theHours > 0 then
say "get out of bed sir!"
end if
Add in a few lines of code to this file and see what happens.
add the on run, this would be clearer. It is the default on unit to run.
on run
set theHours to hours of the (current date)
if theHours > 18 then
say "good evening sir"
else if theHours > 12 then
say "good afternoon sir"
else if theHours > 6 then
say "good Morning sir"
else if theHours > 0 then
say "get out of bed sir!"
end if
end run
Now, it is time for debugging.
It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on. Here is an example.
Author: rccharles
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
on run
-- Write a message into the event log.
log " --- Starting on " & ((current date) as string) & " --- "
-- debug lines
set desktopPath to (path to desktop) as string
log "desktopPath = " & desktopPath
end run
Similar Messages
-
Cannot launch LR. Photoshop crashes after few seconds. How can i fix this? Thx for help
Hi members & mvp's
I face same problem, after creating Adobe ID and after installing Creative Cloud app, the installed Ps and Lr can't be launched... Lr at all, no action, but Ps works for a few seconds. I could achieve "system info" from help menu as follows:
Adobe Photoshop Version: 2014.0.0 20140508.r.58 2014/05/08:23:59:59 x64
Operating System: Windows 7 64-bit
Version: 6.1 Service Pack 1
System architecture: Intel CPU Family:6, Model:10, Stepping:9 with MMX, SSE Integer, SSE FP, SSE2, SSE3, SSE4.1, SSE4.2, HyperThreading
Physical processor count: 2
Logical processor count: 4
Processor speed: 1895 MHz
Built-in memory: 3990 MB
Free memory: 1477 MB
Memory available to Photoshop: 3303 MB
Memory used by Photoshop: 70 %
I guess my PC is powered enough, but I'm afraid other trial versions and registry rubbish are locking CC server communication. Do you know some tool to clean up previous installation of Adobe products?
Thanks in advance!
Jose -
Can anybody provide AIX shell script for Oracle Apps R12 instance backup
Hi
Can anybody provide AIX shell script for Oracle Apps R12 instance backup? Manually, i am able to backup but i donot have shell script to schedule through crontab.
Help me please.
ThanksRman can be used for Database, not for Application tier. Again, I assumed you are looking for a script to backup the database. For the application tier, you can simply do a filesystem backup.
I still do not understand your concern? Is it about using crontab? If so, then check here --> man crontab <-- -
Since updating my iPhone 4 to iOS5, my music stats (play count, last played, etc.) no long sync to iTunes. How can I fix this? Thanks for the help.
If you have any podcasts in your iTunes library you should see a Podcasts sync setting tab to the right when you connect your phone and click on its name on the left sidebar (see image below). On this tab check to sync podcasts and sync your phone.
-
Someone hacked my computer and set up a new administrative account by re-registering my computer. I can not access this account nor delete it. How can I fix this and get my computer back to the way it was? And also prevent this from being able to happen again. I have the link the kid used (http://www.ihackintosh.com/2009/05/how-to-hack-the-user-password-in-mac-os-x-wit hout-an-os-x-cd/) Apparently he used hack 2. HELP PLEASE!
Not sure why you can't delete that account. If you have admin privileges, you should be able to. Sounds like you only removed the Home Folder for that account.
You should highlight/select the account you want to remove and then click the minus button. Might need to unlock the padlock with your admin password.
Have a look at these articles from Apple, if necessary.
http://docs.info.apple.com/article.html?path=Mac/10.5/en/8235.html
http://docs.info.apple.com/article.html?path=Mac/10.5/en/8162.html
http://support.apple.com/kb/DL1399 -
I've installed the Adobe Reader Plug In. Yet every time I click to see a PDF, it opens another browser and it is blank. The Browser reads about:blank. How can I fix this so that PDF's open in the browser?
Check your settings in Options > Applications: https://support.mozilla.com/en-US/kb/Opening%20PDF%20files%20within%20Firefox#w_check-firefox-settings
Also see:
*https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox
*http://kb.mozillazine.org/File_types_and_download_actions
'''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
Not related to your question, but...
You need to update some plug-ins:
*Plug-in check: https://www-trunk.stage.mozilla.com/en-US/plugincheck/
*Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.com/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox] -
If I change my Apple ID for iMessage, will all the iMessages under my previous Apple ID be deleted off my phone?
No, not unless you delete them.
-
Each time I try to watch my iTunes U podcast and try to skip forward my iTunes freezes and gives me an error report and shuts off, this happens also when I try to convert the podcast to my iPod. How can I fix this problem to be able to use iTunes U?
Hello, bisco,
This forum is for questions from people who administer iTunes U sites. You'll be most likely to get help with this issue if you ask in the iTunes or iPod forums.
Regards. -
when I try to back up my iPad to the computer it gives me a message saying it can't sync and there is not enough room in iTunes library. How can I fix this? I need to back up iPad content to restore on a new one
juliefrombaton rouge wrote:
when I try to back up my iPad to the computer it gives me a message saying it can't sync and there is not enough room in iTunes library.
Pretty sure it doesn’t say there is not enough room in iTunes library because it is not backed up to the iTunes library.
What is the exact message? -
On June 30th, I was playing a game called Lil Einstein's Manhattan project over at Newgrounds.com and the game although fine at first, later on in the advanced levels of the game, started to cause my browser to lag intensely and heavily. Now, when I try and watch other flash movies and animations, the flash doesn't run as smoothly, there are skips in the flash animations and movies, and it slows down.
I tried scan disks, I tried defragmenting my computer, I tried uninstalling and re-installing Firefox.. Nothing worked to restore the Flash.
But when I view Flash movies and animations on Internet Explorer, they run fine... but not anymore on Firefox.
Other Firefox users who have played this game also reported problems as well..
How can I fix my Firefox Browser and return the Flash running to normal?
== This happened ==
Not sure how often
== June 30th, 2010If you have already scanned PC with an updated Anti-Virus and still the issue exists then I would suggest some troubleshooting techniques to resolve this problem:
Update browser
Remove unwanted Add-ons
Remove unwanted Tool-bars
Repair Registry
Repair ActiveX objects and shared DLLs
In case of facebook and Zynga I would suggest to Check for Problems with your Internet Connection.Try to Update Java and Reduce the Number of Running Internet Applications.
Sometimes Multimedia content lag due to Hardware Acceleration, so disabling Hardware Acceleration should fix your problem.
Open Flash Video in browser
Right click on Video Player | Settings
Open Display Panel
Uncheck Enable Hardware Acceleration
If issue still exists then you can find some more techniques described in detail here:
http://www.shockwaveflashcrash.com/Easiest-fix-for-shockwave-flash-plug-in-Crash.html -
Can anyone make an Apple Script for me?
I'm looking for an Apple Script so that when I press cmd+F1 on my Macbook Pro Retina it turns the brightness to 0 instantly. Rather than having to hold F1 down to make the brightness go down to 0.
Is this something that is even possible?
Thank YouThere is evidently no direct way to do this, but there is an indirect way:
Download an app called SleepDisplay: Download SleepDisplay for Mac - Put your display to sleep instantly. MacUpdate.com
put SleepDisplay in your Applications folder
open Automator.
Select service for type of document
at the top, for service receives, select no input, and after in, any application
in the column on the left, select Utilities
in the next column, drag Launch Application over to the right, and select SleepDisplay for the app
close the window with the red circle in the left upper corner, and give the service a name, like Dark.
go to system preferences > keyboard > shortcuts
select services in the box on the left, and scroll down in the box on the right until you find the service you just created. select that service.
when you select it, a white oval should appear that says "add shortcut". Type in the shortcut you want to use. I couldn't get ⌘F1 to work, but control-option-⌘-D did work. It must be a unique shortcut, not already in use. -
How can I fix this wrong script?
A- Using a script I polpulate filemaker pro with a number of emails
One fo the fields (Attachments) tells the path of the attachment.
This perfectly working Applescript allows me to copy the Attachments to a folder different from the Mail folder where they are naturally located through Applemail
The attachments are in various formats: PDF, RTF. DOC, DOCX and more
However I am always able to select the whole text and copy it.
I created a Filemaker script as follows:
Perform Applescript:
tell application "FileMaker Pro Advanced"
tell database "Email Archive"
tell table 1
set Ifile to field "Attachments" -- getpath
end tell
end tell
end tell
tell application "Finder"
activate
open Ifile as alias
end tell
later thr FMP calls another script with a dialogue asking me if I want to copy the clipboard content to another field in my database or simpy move to the nex record
The attachment folder field contains the path as folows
MAYMAC:Users:D:Desktop:Jobss:D:INBOX:curriculum_vitae_davide_sanna-4d4ef2ada5932 .doc (or ODF or RTF or DOCX)
However I always get this error in Filemaker;
Finder got an error : Can’t make "MAYMAC:Users:D:Desktop:Jobss:D:INBOX:curriculum_vitae_davide_sanna-4d4ef2ada59 32.doc"
into type item.
How can I avoid this error and get the chance to populate the Curri9cul Field in my DB with the content of the clipboard?Hi,
try this
open item Ifile -
I got this new Ipod for christmas,& I started importing songs before it was fully charged. I thought thast caused the problem till I added new songs to the old one. Then it started doing the same thing. The old one never had this problem. Even one of the new songs I just bought stops 15 seconds in then jumps to the next song. I can't afford to replace them all.
Try:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Unsync/delete all music and resync
- Reset all settings
Go to Settings > General > Reset and tap Reset All Settings.
All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device. -
i used this feature before and a message appeared in tool bar that privacy was on, this no longer happens i have tried the tools / options / privacy setting with no luck. any fixes available?
This feature has likely been provided by an extension that is disabled or no longer installed, possibly because you have reset Firefox.
*https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes -
Ever since having to replace my hard drive on my laptop and also the operating system, I cannot get my ipod to work with my laptop. I continually get this message. I have tried every troubleshooting procedure repeatedly and also have tried all the posts on the support communities. Can anyone help?
Nevermind that first part as I forgot that nothing shows up for the Nano at all in Device Manager,
The 2nd half of my reply still applies:
Otherwise, try uninstalling all USB root controlllers from your system, rebooting your PC, and reconnecting your Nano. This root controller drivers will automatically be re-installed upon reboot.
B-rock
Maybe you are looking for
-
How to create 2-page parallel autoconnected flow tags...
FM10 (from TCS3), unstructured. Advanced user. I want to create a chapter template with two flows that appear on either the left pages (only) or the right pages (only). Currently, we have a number of conditional text content identifying audience-spec
-
How to create a DataBase File like MDB or DBF to web
Hi People, I'm a Delphi Developer and I'm new in Java. I need to make a DataBase File like MDB or DBF to work online. I will make a Form to sign users. All of user's information, for example: user name, address, mail, phone, will need to record in my
-
Bonjour not wakeing up after sleep - again
It happens again, and again: after wakeing up from sleep, the network services do not wake up. After my iMac wakes up, Safari tells me, that no "Internet Connection" is established. However, with ping etc., everything is fine. In "Bonjour Browser" I
-
Can garageband be used with interactive whiteboards?
Hi:) Does anyone know if the garageband software program can be used with an interactive whiteboard? I am doing an assignment on the use of interactive whiteboards in classrooms and was hoping to include garageband as an example of a motivational sof
-
Commenting and Markup Toolbar in IE
We have created a PDF with Commenting set to Allowed. We then uploaded the PDF to a Windows Server 2003 host and put it through Pitstop. When the PDF is opened from the server in Internet Explorer, commenting is set to not allowed. When the file is s