/// <summary> /// Magic Wand selection /// </summary> /// <param name="app">Photoshop Application Object</param> /// <param name="x">x-Axis pixel source selection</param> /// <param name="y">y-Axis pixel source selection</param> /// <param name="tolerance"> Selection tolerance</param> /// <param name="antiAlias"> Anti-Alias option</param> /// <param name="contiguous"></param> /// <param name="mergedLayer"></param> public static void MagicWand(ps.ApplicationClass app,int x, int y, int tolerance = 32, bool antiAlias = true, bool contiguous = false, bool mergedLayer = false) { // Action recorded on photoshop and transcripted by the Action Listener script // This code is the result of the Action Listener script ps.ActionDescriptorClass desc = new ps.ActionDescriptorClass(); ps.ActionReferenceClass refe = new ps.ActionReferenceClass(); refe.PutProperty((int)cst.phClassChannel, (int)cst.phKeySelection); desc.PutReference((int)cst.phClassNull, refe); ps.ActionDescriptorClass positionDesc = new ps.ActionDescriptorClass(); positionDesc.PutUnitDouble((int)cst.phEnumHorizontal, (int)cst.phUnitDistance, x); positionDesc.PutUnitDouble((int)cst.phEnumVertical, (int)cst.phUnitDistance, y); desc.PutObject((int)cst.phKey_Source, (int)cst.phClassPoint, positionDesc); desc.PutInteger((int)cst.phKeyTolerance, tolerance);// tolerance desc.PutBoolean((int)cst.phEnumMerged, mergedLayer);// sample all layers desc.PutBoolean((int)cst.phKeyContiguous, contiguous);// contiguous desc.PutBoolean((int)cst.phClassAntiAliasedPICTAcquire, antiAlias);// anti-alias app.ExecuteAction((int)cst.phEventSet, desc, ps.PsDialogModes.psDisplayNoDialogs); }