check the activedocument has selection or not

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

lxl13596

check the activedocument has selection or not

Post by lxl13596 »

I want to check the activedocument has selection or not.
I could not find the ways to check the "Selection"
thks
thks
xbytor

check the activedocument has selection or not

Post by xbytor »

This works.

function hasSelection(doc) {
var res;
try {
doc.selection.bounds; // throws if there's no selection
res = true;
} catch(e) {
res = false;
}

return res;
}
lxl13596

check the activedocument has selection or not

Post by lxl13596 »

xbytor wrote:This works.

function hasSelection(doc) {
var res;
try {
doc.selection.bounds; // throws if there's no selection
res = true;
} catch(e) {
res = false;
}

return res;
}

Good idea! THS
Itry to use vbs according to your code

On Error GoTo err0
objApp.ActiveDocument.Selection.TranslateBoundary 0, 0
MsgBox "have"
Exit Sub
err0:
MsgBox "no"
THS