mardi 27 janvier 2015

Customize Dictation to run AppleScript for Specific Monitor


I've enabled Dictation for command prompts via voice [got it from the OS shipped Chess application in Lion]. Decided to give it a go System Wide now in 2015 running Yosemite. I fancy it so far, certainly looks better and performs better as opposed to Lion (which should be the case) There are a few customizable options when you 'Enable Advanced Commands' like open file, run workflow, open application, paste text, paste data, & keyboard shortcut.


However, call me lazy but it's still something that matters to me, I frequent Netflix & Hulu and other websites at minimum 4 times a day. I would like to add a functional command that will automatically open a webpage correlating to that command. since open file is different than run file, i'm trying to autonomously open Safari + the name of the website in URL form with dictation? The good thing about this is it automatically makes whatever application you reference the front-most window. So coding should be minimal, and I really don't want to create a service for this [my services are growing, currently at +55 in total].


I am an Automator aficionado however, and well versed with it so I'm using the Dictation Command tool, but what i am not, is an AppleScript scholar. After reading through the applescript library for about 60 minutes i finally figured out how to open a new window of Safari, activate the application in case it was not open and launch the url:



tell application "Safari" to activate
tell application "Safari"
make new document with properties {URL:"http://netflix.com"}
end tell


Additionally, I have 3 monitors. I always have movies, tv etc played on Number 2! I tried putting Safari in the monitor 2 screen with applescript but as an iOS developer, in good conscience am too embarrassed to share my code, it's sloppy . Can anyone lead me in the right direction? Or does anyone know a more simplified way around all of this? I really want this to work. I am in the military so our rooms aren't that big so my 2nd monitor (27") is my tv, so I have created an iPhone app for my needs only that strictly simulates the double fn press needed to activate Dictation so I can watch tv from my bed [don't have apple tv].




EDIT: My main goal is to be able to use voice activation to populate a Safari specific website using Dictation for a specific monitor. I don't want to sacrifice my 'Spaces' or 'Mission Control' settings as I have done a lot of work to make those beneficial to my workflow. I have 3 monitors, which are set up in succession (i.e, monitor 1 & 3 are right next to one another on my desk station, monitor 1 is left & 3 is right, monitor 2 is no where near 1 or 3 it is facing my bed see pic 1 for reference. However, they are set up in succession 1 goes to 2, 2 goes to 3. I have spaces set up where specific apps use monitor number 3 exclusively (Xcode) which doesn't make it as much of a hassle as it sounds, this is why i don't want to sacrifice my spaces settings because I use 2 as my dedicated "TV", this isn't that big of a deal though and can be changed, I don't even know why I do this, but it works so I haven't really bothered to try anything else)


PIC 1: pic1




miken32's suggestion works, but only to display it, not to minimize. Minimizing is important, because I will have to minimize the active Safari website, lets say Hulu, just to open Netflix because full-screen apps can't overlap. So I will inevitably do another voice activation or otherwise to minimize so I can transfer websites without blimps. Note: sometimes I don't want to close, sometimes I save my spot so minimizing is a good resource for me. This is what happens with miken32: it minimizes but I think it's trying to go back the origins we set in the script, but negatively as in (-). NOTE: I know the origins you see in the applescript of the movie don't reflect the absolute origin for my specific monitor, I changed the origins for testing, but for recording the movie I had to put it on that screen so I kept it as is just so you can see where it goes when you minimize. Other than that works great for the amount of code!. I'm glad you guys included the full screen option even when I didn't ask for it, that's absolutely what I had in mind but didn't want to disturb anyone trying to figure that out, my main goal was just getting it on the 2nd monitor.


http://ift.tt/1Cfy7cd




markhuntes answer works flawlessly, the amount of time it took to load on the first run was about 15 seconds, nothing to worry about, but definetly not optimal for every day use, however, subsequent runs were minimal (3-6 seconds max). What I do like about his suggestion is that it automatically finds the second monitor instead of me having to hard code it, which is great from a consumer point of view, the less I have to tamper with the better, this is a great feature for the future, say I change my set-up or I get a different sized monitor etc I don't have to re-code an absolute origin. There is a drawback as of now, I'm going to play around with it for a couple of days just to make sure its not conflicting with my other system preferences. It minimizes where it should which is great, it populates accurately but i've found if Safari is already the front-most application it (sometimes, more precisely, rarely, it populates in the same Space or (monitor 1) that Safari is already active. The reason I wanted it to show specifically in Monitor 2 is because of course I don't just use Safari in that monitor alone. Again, it could be my settings, I have a lot of hot corners and mission control keys and spaces preferences set up so I'm going to tinker with it just to make sure its not me and get back to you





Aucun commentaire:

Enregistrer un commentaire