# Copying A Selection Driving Me Nuts

**URL:** <https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319>\
**Category:** UXP Plugin API\
**Created:** [July 19, 2021, 2:16pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319 "2021-07-19T14:16:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [July 19, 2021, 2:16pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/1 "2021-07-19T14:16:31Z")

</div>

After manually making a selection the whole routine is supposed to something like this…

Copy the selection and paste inplace to another document.  
It seems to be falling over at the first step on Windows.

Any help on this would be very welcome.

```auto
const batchPlay = require("photoshop").action.batchPlay;
   const result = await batchPlay(
   [
      
      {
         "_obj": "copyEvent",
         "copyHint": "pixels",
         "_isCommand": true,
         "_options": {
            "dialogOptions": "dontDisplay"
         }
      }
   ],{
      "synchronousExecution": false,
      "modalBehavior": "fail"
   });

```

 ![Screenshot 2021-07-19 150637](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/0/022c87630cc43303379f59ad5d4cfa92e9945dd6.jpeg)

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [July 19, 2021, 2:33pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/2 "2021-07-19T14:33:15Z")

</div>

```auto
"_options": {
  "dialogOptions": "dontDisplay"
}

```

seems to be the problem here. If you remove it, the alert doesn’t pop up.

---

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [July 19, 2021, 2:59pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/3 "2021-07-19T14:59:55Z")

</div>

That does remove the alert but it doesnt appear to copy anything because under the Edit Menu, Paste is Disabled

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [July 19, 2021, 3:03pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/4 "2021-07-19T15:03:15Z")

</div>

Do you have some non-transparent pixels when you copy?

---

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [July 19, 2021, 3:05pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/5 "2021-07-19T15:05:59Z")

</div>

No I dont. I even filled the whole document with black and it still doesnt copy anything.

I dont have my Mac here at the moment so unable to confirm it its just a Windows issue

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [July 19, 2021, 3:10pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/6 "2021-07-19T15:10:20Z")

</div>

I’m a bit confused 🙂 So you don’t have non-transparent pixels? Or you do have? Because you mentioned all black 🙂 My guess was, that nothing is copied if all pixels are transparent

---

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [July 19, 2021, 3:15pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/7 "2021-07-19T15:15:41Z")

</div>

What I mean is that I have even created a new document, filled it with Black, made a selection with the Lasso Tool and tried to copy that selection and still nothing appears to get copied

---

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [July 19, 2021, 3:52pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/8 "2021-07-19T15:52:42Z")

</div>

No idea why, but it appears to be working now.

Thanks for everyones input.

I spoke to soon ☹  
It works perfect on the MAC but just not on Windows.

---

<div class="post-metadata">

**Author:** ![photonic](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/photonic/32/2513_2.png) [@photonic](https://forums.creativeclouddeveloper.com/u/photonic)\
**Post date:** [December 29, 2022, 2:37am UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/9 "2022-12-29T02:37:00Z")

</div>

Did you find a solution??

I can’t make it work and it is driving me nuts too!

I’m on windows 11 btw

---

<div class="post-metadata">

**Author:** ![photonic](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/photonic/32/2513_2.png) [@photonic](https://forums.creativeclouddeveloper.com/u/photonic)\
**Post date:** [December 29, 2022, 9:22pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/10 "2022-12-29T21:22:50Z")

</div>

I found the solution and it works fine now on Windows 11

This was the code I was using before, same as you:

```auto
async function copyPixels() {
  try {
    await batchPlay([
      {
        "_obj": "copyEvent",
        "_isCommand": true,
        "_options": {
          "dialogOptions": "dontDisplay"
        }
      }
    ], {});
  } catch (e) {
    console.log(e);
  }
}

```

Seems that if you remove this key and its value, the function works fine:

```auto
"_isCommand": true,

```

It should be something like this:

```auto
async function copyPixels() {
  try {
    await batchPlay([
      {
        "_obj": "copyEvent",
        "_options": {
          "dialogOptions": "dontDisplay"
        }
      }
    ], {});
    // console.log('here');
  } catch (e) {
    console.log(e);
  }
}

```

I’m testing it right now and it seems works fine. Hope it works for you as well.

Again, I’m on Windows 11.

**EDIT:**

I also noticed that this works aswell:

```auto
async function copyPixels() {
  try {
    await batchPlay([
      {
        "_obj": "copyEvent"
        }
      }
    ], {});
    // console.log('here');
  } catch (e) {
    console.log(e);
  }
}

```

Kind regards,

---

<div class="post-metadata">

**Author:** ![rascheln](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rascheln](https://forums.creativeclouddeveloper.com/u/rascheln)\
**Post date:** [January 25, 2023, 11:37pm UTC](https://forums.creativeclouddeveloper.com/t/copying-a-selection-driving-me-nuts/3319/11 "2023-01-25T23:37:08Z")

</div>

Whoa, thanks so much for this suggestion on removing “\_isCommand”: true,

But… why, though?! Why does this make the action work?
