-
Posts
17 -
Joined
-
Last visited
Content Type
Blogs
Gallery
Downloads
Events
Profiles
Forums
Articles
Media Demo
Posts posted by Danilo
-
-
1 hour ago, vitor said:
Are you sure that’s the change you made? active tab has to change to current tab, it’s not just the browser’s name.
Yep, here's the current code:
on workflow() --display dialog "workflow()" tell application "Safari" set myurl to URL of current tab of first window set the clipboard to myurl end tell --display dialog myurl tell application "Downie" to activate tell application "System Events" to tell application process "Downie" click menu item "Open URLs..." of menu "File" of menu bar item "File" of menu bar 1 click menu item "Paste" of menu "Edit" of menu bar item "Edit" of menu bar 1 key code 76 using {command down} end tell end workflow on init(appName) if appIsRunning(appName) then --display dialog "running" workflow() else --display dialog "starting" set appNameAsText to appName as text tell application appNameAsText to activate delay 0.1 init(appName) end if end init on appIsRunning(appName) tell application "System Events" to (name of processes) contains appName end appIsRunning init("Downie")
-
On 7/5/2022 at 2:10 PM, vitor said:
@danillo Open the Run Script and change
tell application "Google Chrome" set myurl to URL of active tab of first window set the clipboard to myurl end tell
to
tell application "Safari" set myurl to URL of current tab of first window set the clipboard to myurl end tell
If @James Hobson is interested in supporting multiple browsers concurrently, I’ve made a post on how.
It was the first thing I tried here. I don't know why, but it didn't work. I tried using Webkit instead of Safari but it didn't work too.
-
On 7/5/2022 at 2:17 PM, vitor said:
I don’t use Music and you’re faking key presses, so I don’t know what the result is supposed to be to test. Without you sharing the Workflow I can’t even tell what input is supposed to be or why there’s parameters.
Doesn’t seem like you need any code for it. Try making the same with a Delay Utility and Dispatch Key Combo Output.Take a look ate these two shortcuts:
https://www.icloud.com/shortcuts/20a3dd5a728041ea85ba93de399d9f04
https://www.icloud.com/shortcuts/05e5d4172cbe47c586de77c5b2c14a46
Since Alfred runs AppleScripts much master than Shortcuts.app, I just wanted to "convert" these shortcuts into workflows. I tried to create the Workflow using Keyword as Input than I used the Run Script action.
https://www.dropbox.com/s/tnue4ex4zmx6rxo/Apple Music.alfredworkflow?dl=0
-
@vitor can you help to modify this workflow to work with Safari? I tried changing the code but it's not working. I know that Downie has a Safari Extension but I don't want to clutter the toolbar with various icons. Thank you in advance!
-
Hi @vitor. Please could you help with this one?
-
I have two Shortcuts that I frequently use to see the lyrics of the current playing track. The first one toggles the Music miniplayer showing the lyrics and the other one shows up the lyrics on the main Music window. I'm trying to convert these shortcuts to alfred workflows but I don't know what am I missing. The workflow structure is Keyword as Input and then Run Script. The codes I'm using are:
1) Show Lyrics on Music miniplayer
on run {input, parameters} tell application "System Events" delay 0.5 keystroke "m" using {command down, shift down} end tell return input end run
2) Show Lyrics on main Music window
on run {input, parameters} tell application "System Events" delay 0.5 keystroke "u" using {command down, control down} end tell return input end run
As Shortcuts these codes are working fine, but not as workflows. What am I missing? Can anyone help?
-
Vitor what code should I add if instead of wait then resize I wanted to just open the video in PiP mode? I found that script in the link below but i dont know how to add it to my code.
https://gist.github.com/danielrotaermel/201f549d5755ea886eb78bb660133722
-
26 minutes ago, vitor said:
The resize is happening before the video starts streaming. Tell it to wait until playback starts.
function run(argv) { const quicktime = Application("QuickTime Player") if (quicktime.running()) quicktime.windows().forEach(w => w.close()) quicktime.activate() quicktime.openURL(argv[0]) while (!quicktime.documents[0].playing()) delay(0.2) quicktime.windows[0].bounds = {x: 739, y: 262, width: 1498, height: 689} }
Now it worked, but that "Open File" window is being shown again when QT start to run.
-
20 minutes ago, vitor said:
I understand you’re figuring these out as they work, but if you give a better picture of the whole from the start we arrive at a better solution faster.
Your code works for me, though you can replace Application("QuickTime Player") with quicktime now. To assist further, I’ll need to see the full code as you have it, and a real URL.My code didn't work when the language was set to /bin/bash, but then I changed the it to /usr/bin/osascript (JavaScript) and replaced Application ("QuickTime Player") with just QuickTime. Now it is working.
The only problem is that the coordinates are not right as I thought it was and also after resizing and moving the window QT resizes the window again to the video resolution size.
Here's one copy of the Workflow with the full code and a real URL.
https://www.dropbox.com/s/2obcl2am9i0u4fy/Next TV test.alfredworkflow?dl=0
-
6 minutes ago, vitor said:
Alright, let’s improve the whole script at once with everything you want. Change the language to /usr/bin/osascript (JavaScript) and use this code:
function run(argv) { const quicktime = Application("QuickTime Player") if (quicktime.running()) quicktime.windows().forEach(w => w.close()) quicktime.openURL(argv[0]) quicktime.activate() }
That will close all QuickTime windows (not just the current one). If you don’t want QuickTime to be brought to the front, remove quicktime.activate().
Wow!!! Now it is working like I wanted. The last thing I was trying here was setting the screen position that QT would open, so I added a new line of code:
Application("QuickTime Player").windows[0].bounds = {"x":739, "y":262, "width":1498, "height":689}
However it didn't work. I'd like to resize and centralize QT window. What am I doing wrong?
-
1 hour ago, vitor said:
osascript -l JavaScript -e 'Application("QuickTime Player").windows[0].close()'
This one worked, but now when I run the workflow for the first time, QuickTime run and show that "Open File" window and then it open the player window:
Is it possible to prevent QT opening the "Open File" window?
-
11 hours ago, vitor said:
If so, share a smaller version of the Workflow you have and I’ll take a look.
Hi Vitor. I just set the Workflow and everything is working seamlessly. The only thing I'd like to change is QuickTime's behavior when it is already playing a URL and I send a new one to it. Instead of closing the current window, it opens a second QT window with the new URL. Is it possible to add something to the Workflow that would close the current QT window and then open the new http URL?
-
2 minutes ago, vitor said:
Are you sure it’s a URL QuickTime can play?
If so, share a smaller version of the Workflow you have and I’ll take a look.
Now it is working!!! I mistyped the script line.
I'll complete the workflow with all URL as argument and check it all again to see if it works seamlessly. If it does, then I'll let you know here.
Thank you so much Vitor!! 🙏🏼
-
3 minutes ago, vitor said:
Those are unnecessary, yes.
The correct code is open -a 'QuickTime Player' "${1}" (I fixed it in the post above too). One of the quotes wasn’t correctly replaced.
I deleted the unnecessary lines and fixed the code:
😔 but it still not working:
The List Filter argument is just a http url.
-
20 minutes ago, vitor said:
You’re on the right track but have a few errors.
- In the List Filter, have just the URL as argument.
- In the Run Script, Language has to be /bin/bash or /bin/zsh.
- In the Run Script, Script has to be open -a "QuickTime Player' "${1}".
Hi Vitor, thanks for answering!
So I let just the URL as argument:
Then I set the Run Script language to /bin/bash and added the Script open -a "QuickTime Player' "${1}".
Did I added the Script line in the wrong place? Do I have to delete query=$1 echo -n $query?
-
Hi all. I have a workflow that lists tv channels (http links) and then opens the chosen one on OPlayer using the Open URL action.
The workflow works seamlessly when I use OPlayer url scheme (oplayer://http://example.com.m3u8) as an argument in List Filter action. However, OPlayer for Mac has a few glitches, so I’d like to start using QuickTime Player in its place. The problem is that I didn’t find the QuickTime’s URL scheme and the only way I found out to send the link to QT is through a script. The script looks like:
open -a "quicktime player" http://example.com.m3u8.
I tried to use it as an argument but it didn’t work.
So I replaced the Open URL action with the Run Script action and it still not working.
This is the first time I’m trying to make a workflow and also I don’t know a lot about scripting, that’s why I need your help. I know I could do it all with one script, but since my scripting knowledge is limited, I think the structure of actions I’m using (List Filter -> Open URL) is easier for me to understand.
Can anyone help me with this? Can I use a script line as an argument? What action should I use to replace Open URL when the argument is a script line?
Thank you all in advance!
Show Music lyrics
in Workflow Help & Questions
Posted
Just got it to work. Thank you again @vitor and sorry for asking again and again, I'm a newby to coding and just started using Alfred.
Here's the Workflow if it interest to anyone.
https://www.dropbox.com/s/nkq0ini27slp5o7/Apple Music Lyrics.alfredworkflow?dl=0