<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: whiskeypls</title>
    <description>The latest articles on DEV Community by whiskeypls (@whiskeypls).</description>
    <link>https://dev.to/whiskeypls</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1046170%2Fcd94f012-9455-4ced-9ad2-095219197465.jpeg</url>
      <title>DEV Community: whiskeypls</title>
      <link>https://dev.to/whiskeypls</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/whiskeypls"/>
    <language>en</language>
    <item>
      <title>Count Open Space - Mission Control</title>
      <dc:creator>whiskeypls</dc:creator>
      <pubDate>Thu, 16 Mar 2023 03:06:34 +0000</pubDate>
      <link>https://dev.to/whiskeypls/count-open-space-mission-control-5d7a</link>
      <guid>https://dev.to/whiskeypls/count-open-space-mission-control-5d7a</guid>
      <description>&lt;p&gt;&lt;strong&gt;Here's the main goal:&lt;/strong&gt;&lt;br&gt;
I'm writing an application that opens 13 spaces before it opens my programs and apps in specific spaces. &lt;/p&gt;

&lt;p&gt;Sometimes I'll already have 2 or 3 spaces open before I run the app so I'd like it to count the total open spaces and only open a total of 13&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;br&gt;
The problem isn't how to have the code repeat 13 or less times. The problem is that when I count the number of spaces that are open it's returning 1 even if 6 spaces are open. I believe the reason for this is that when a shortcut is used to activate mission control like "Control Up" only the titles of the spaces appear. It's not until the mouse is moved over the top mission control bar that the spaces are visible. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Questions&lt;/strong&gt;&lt;br&gt;
How do I either count the titles of the spaces ie Display 1, Display 2, etc, or how do I make the spaces visible before they are counted?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set totalSpaces to 13

tell application "System Events"
    do shell script quoted form of "/System/Applications/Mission Control.app/Contents/MacOS/Mission Control"
    set spacesCount to count of group 1 of group "Mission Control" of process "Dock"
    do shell script quoted form of "/System/Applications/Mission Control.app/Contents/MacOS/Mission Control"
    delay 0.5
    key up control
end tell

set repeatSpaces to totalSpaces - spacesCount

if repeatSpaces &amp;gt; 0 then
    display dialog "Number of spaces to repeat: " &amp;amp; repeatSpaces
else
    display dialog "No spaces need to be repeated."
end if

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>applescript</category>
    </item>
  </channel>
</rss>
