Page 1 of 1

Need help with lua script to start Photoshop.

Posted: Mon Feb 24, 2014 10:20 pm
by JeremyLavine
I've been lurking this forum for ages, and it's really been helpful. Anyway I found a script to launch Gimp, but I haven't been able to get it to work with good old Photoshop Elements 5.0, and would really appreciate some help with this.

Here's what I've have:

Code: Select all

-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "SP_Photoshop"

-- **************************************************
-- General information about this script
-- **************************************************

SP_Photoshop = {}

function SP_Photoshop:Name()
	return "Photoshop"
end

function SP_Photoshop:Version()
	return "5.0"
end

function SP_Photoshop:Description()
	return "Launch Photoshop application"
end

function SP_Photoshop:Creator()
	return "Simple Scriptor, 2014"
end

function SP_Photoshop:UILabel()
	return("Photoshop")
end


-- **************************************************
-- The guts of this script
-- **************************************************
	function SP_Photoshop.getOS()
	if os.getenv("OS") ~= nil
	then
		local opSys = string.lower(string.sub(os.getenv("OS"), 1, 3))
		if opSys == "win" then
			return "win"
		else
			return "unix"
		end
	else
			return "unix"
	end	
	end

function SP_Photoshop:Run(moho)

 if (moho.layer:LayerType() ~= MOHO.LT_IMAGE)
        then
	LM.GUI.Alert(LM.GUI.ALERT_INFO, "This Script only works with Image Layers.", nil, nil, "OK", nil, nil)
        return
        end
	  
moho:LayerAsImage(moho.layer)
        
image = (moho.layer:SourceImage())
 
 if(SP_Photoshop.getOS()=="win") then
  os.execute(' "Photoshop" "C:\Program Files (x86)\Adobe\Photoshop Elements 5.0\PhotoshopElementsEditor.exe" ' .. '"' .. image .. '"')  --WINDOWS - EDIT path to Photoshop according to your system.
 else
 os.execute("Photoshop" .. image .."&")  --LINUX & Mac - edit path "Photoshop" if it doesn't work.
 end
 
 
LM.GUI.Alert(LM.GUI.ALERT_INFO, "Press 'OK' to reload image when you're done.", nil, nil, "OK", nil, nil)
moho.layer:SetSourceImage(image)
end

Re: Need help with lua script to start Photoshop.

Posted: Tue Feb 25, 2014 12:51 am
by synthsin75
I actually rewrote that Gimp script for PSE3 ages ago (should be an easy enough change to PSE5). All my old links to the script are dead, so give me some time to find it and repost it.

Re: Need help with lua script to start Photoshop.

Posted: Tue Feb 25, 2014 1:19 pm
by JeremyLavine
Hi synthsin75,

I've updated the script again since I noticed it referenced another by mistake, but it only works partially. When I start the script after selecting an image all I get is a pop-up stating "Press 'OK' to reload image when you'e done", but Photoshop still doesn't start.

I hope what you have works with PSE5. Does it also work with images within a switch?

Re: Need help with lua script to start Photoshop.

Posted: Wed Feb 26, 2014 1:35 am
by synthsin75
Here you go:
http://www.filedropper.com/dreditinpse

You'll have to change the path to reflect PSE5.

This should work with any selected image layer.

Re: Need help with lua script to start Photoshop.

Posted: Wed Feb 26, 2014 2:39 pm
by JeremyLavine
Thanks, synthsin75!

Your script works like a charm with PSE5! Gonna save me hours! :D

Re: Need help with lua script to start Photoshop.

Posted: Thu Feb 27, 2014 12:54 am
by synthsin75
Glad I could help.

Re: Need help with lua script to start Photoshop.

Posted: Thu Mar 27, 2014 5:04 pm
by Lukas
Synthsyn75, do you know how to get this to work with Photoshop CC on OS X?

Re: Need help with lua script to start Photoshop.

Posted: Fri Mar 28, 2014 12:27 am
by synthsin75
I've never worked with Macs, so I'm not sure what the exact path would be or how the image file would be provided as an argument for PS to open. It should certainly be possible though. Vern uses Macs, so may be he'd be willing to help.

Re: Need help with lua script to start Photoshop.

Posted: Wed May 07, 2014 8:53 pm
by gvboy
Using the modified code below worked for me on Mac... just need to edit the actual app name of your version of photoshop (mine is "Adobe Photoshop CS5")

Hope this helps.

Code: Select all

else
 os.execute('open -a "Adobe Photoshop CS5" ' .. image)  -- for MAC- Edit Photoshop App name
 end

Re: Need help with lua script to start Photoshop.

Posted: Thu May 08, 2014 10:51 am
by Lukas
gvboy wrote:Using the modified code below worked for me on Mac... just need to edit the actual app name of your version of photoshop (mine is "Adobe Photoshop CS5")

Hope this helps.

Code: Select all

else
 os.execute('open -a "Adobe Photoshop CS5" ' .. image)  -- for MAC- Edit Photoshop App name
 end
Thanks so much! Finally it works :)