Skip to main content
Participant
September 12, 2025
Answered

Has anyone managed to trigger the Object Selection Tool via script?

  • September 12, 2025
  • 1 reply
  • 142 views

I’m trying to figure out if it’s possible to call the Object Selection Tool in Photoshop using a script — in the same way as pressing the W key on the keyboard.

So far I’ve tried:

  • Switching tools with Action Manager code (select with objectSelectionTool).

  • Using app.currentTool.

None of these approaches reliably activate the Object Selection Tool across different Photoshop versions.

Has anyone successfully scripted this so that it behaves exactly like pressing W?
If yes, could you share the code snippet or approach you used?

Thanks in advance!

Correct answer Stephen Marsh

@marcin_1620 

 

It's not that obviously named.

 

selectTool('magicLassoTool');

function selectTool(tool) {
    var desc9 = new ActionDescriptor();
    var ref7 = new ActionReference();
    ref7.putClass(app.stringIDToTypeID(tool));
    desc9.putReference(app.charIDToTypeID('null'), ref7);
    executeAction(app.charIDToTypeID('slct'), desc9, DialogModes.NO);
}

 

1 reply

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
September 12, 2025

@marcin_1620 

 

It's not that obviously named.

 

selectTool('magicLassoTool');

function selectTool(tool) {
    var desc9 = new ActionDescriptor();
    var ref7 = new ActionReference();
    ref7.putClass(app.stringIDToTypeID(tool));
    desc9.putReference(app.charIDToTypeID('null'), ref7);
    executeAction(app.charIDToTypeID('slct'), desc9, DialogModes.NO);
}

 

Participant
September 12, 2025

Thanks a lot, Stephen! I’ve been stuck on this for 3 hours, and now it finally makes sense 🙏