Boricua27 Posted March 28, 2021 Share Posted March 28, 2021 Hello all, I often use several windows at a time when I'm on the computer. I currently have a workflow that opens all the URLs and apps that I want, but I want to see if there's a way to get the different windows to open on different parts of the screen using a screen organizer app—the one I use is Divvy. Divvy lets me set a hotkey to move a window to a predetermined part of the screen, so I figure there has to be a way to add a command in the workflow that lets me: 1) open a specific URL or app and 2) move the new window to a predetermined part of the screen based on the Divvy hotkey. I was experimenting and tried using the "Dispatch Key Combo" output, both before and after the open URL/app commands, but it's not working—see attachment. I am unfamiliar with script... I don't know if this would be the way to do it. Thanks for any feedback! Link to comment
deanishe Posted March 28, 2021 Share Posted March 28, 2021 (edited) 6 hours ago, Boricua27 said: I was experimenting and tried using the "Dispatch Key Combo" output, both before and after the open URL/app commands, but it's not working That's likely because you're firing the Key Combo too quickly. When you tell an app to open something, or simulate a Key Combo, it's asynchronous. Alfred fires off a message to the OS, the OS puts it in the target application's message queue and tells Alfred "OK". It doesn't wait for the application to actually handle the command/Key Combo. This is fundamental to the way GUIs work. As a result, you probably need to add a delay before firing the Key Combo to give the application time to be ready to receive it. Also, don't use Run NSAppleScript. It behaves poorly. Use a regular Run Script action with Language = "/usr/bin/osascript (AS)" instead. 6 hours ago, Boricua27 said: see attachment Please don't post screenshots of workflows. They say almost nothing. If your workflow isn't working, please upload it somewhere (Dropbox?) and post a link, so we can actually see the problem for ourselves. Edited March 28, 2021 by deanishe Link to comment
Boricua27 Posted March 28, 2021 Author Share Posted March 28, 2021 Hey deanishe, I’m new to this so thanks for the feedback! I added the delays and it seems to have worked at least partially—the windows start trying to move around but they don’t seem to move to the right place or with the right size. For example, one of the windows I'm trying to move is the Kindle app, which I want to open in a big window on the left side of the screen but either it’s opening in a smaller window on the left side of the screen or one of the other windows opens big on the left side of the screen, as if it were the Kindle app. It’s not consistently reproducing any one particular result so it seems like there may be some interference between the different commands…? I uploaded the workflow to Dropbox, here’s the link: https://www.dropbox.com/s/eeuzpw9p9uo6uas/Move%20Windows.alfredworkflow?dl=0 Link to comment
Boricua27 Posted March 28, 2021 Author Share Posted March 28, 2021 The AppleScript is something I found online, someone posted it as a tool you could use to open specific URLs in a different window... I just copy pasted it and it worked. I don't understand script 😅 Link to comment
deanishe Posted March 29, 2021 Share Posted March 29, 2021 I can't run the workflow because I don't have most of the apps. The following assumes that ⌘1, ⌘2 etc. are your Divvy hotkeys: The obvious problem is that you're running everything at the same time. Alfred will run all of the things you've connected to Quit All Apps in parallel. That means there's absolutely no telling which order the apps and URLs will be opened in, and by extension, no way of knowing which application will have focus when any one of your Key Combos fires. You need to ensure that at least the Key Combos are run serially (one after another) and that the correct application is focussed for each one (in AppleScript tell application "Name of the Application" to activate). 12 hours ago, Boricua27 said: I just copy pasted it and it worked. I don't understand script Yeah. That script isn't actually doing anything. Delete it. It's supposed to open the URL you pass it in Chrome, but you aren't passing it any URL… Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now