Jump to content

Commanding old Photoshop


Recommended Posts

I have CS3 (yeah, about 10 years old) and I want to do some automated tasks. I basically want to open a layered image, click on a layer, open the color dialog and paste a color value (e.g. F22222 - the saved value in the layer is FFFFFF).  So far I it is doing everything I want, and then ControlSetText pastes in the value. The value displays in the control. But when I click the OK button on the dialog (either manually or via AutoIt), or click on another edit control, the value reverts to the old one.  This is driving me crazy. Am I missing something?

I also used ControlGetText to read the control's value and it returns the edited value.

Here is the code I am running to execute these commands:

#include <MsgBoxConstants.au3>
run("c:\program files (x86)\adobe\adobe photoshop cs3\photoshop.exe c:\sample\sample.psd")
AutoItSetOption('MouseCoordMode', 0)

WinWait('Adobe Photoshop CS3 Extended')
WinActivate('Adobe Photoshop CS3 Extended')
MouseClick('primary', 933, 373, 2, 0)

Local $hWnd = WinWait('Pick a solid color:')
if not IsHWnd($hWnd) Then
   MsgBox(1,1,"not able to get window")
   exit 1
EndIf

WinActivate($hWnd)

WinActivate("ahk_class PSFloatC")

ControlSetText($hWnd, '', '[CLASS:Edit;INSTANCE:7]', 'F22222', 0)

Local $sText = ControlGetText($hWnd, "", "[CLASS:Edit;INSTANCE:7]")

MsgBox($MB_SYSTEMMODAL, "", "The text in Edit7 is: " & $sText)

 

 

Can somebody give me some guidance? What am I doing wrong? Thanks!

 

after controlsettext.png

after clicking on textbox above it.png

Link to comment
Share on other sites

@GHawk

It is obvious that the dialog has several ways to set the value (hex, RGB, HSB, etc)  It is probably is looking for keystrokes in order to figure out which value to use.  If you use the Send function to set the value, I bet it would work.

As you can see, after using ControlSetText, the other values were not updated.  i.e. the RGB values didn't change to 242 34 34.

Edited by TheXman
Link to comment
Share on other sites

@TheXman

Yes, I agree that the dialog is looking to process one character at a time.  If I type in the dialog F, then 2, 3, 4, 5, 6, it processes one keystroke at a time and updates the other values.

So do I need to select the particular textbox (Edit7), and then use the Send command? I tried doing that and it doesn't get any values inserted.  I tried using 1 send command, and several with just a single character.  My guess is I'm not connecting correctly to the textbox.

Can you provide more assistance?

Thanks!

Link to comment
Share on other sites

20 minutes ago, GHawk said:

So do I need to select the particular textbox (Edit7), and then use the Send command? I tried doing that and it doesn't get any values inserted.  I tried using 1 send command, and several with just a single character.

@GHawk

I will try to help.  Post the code that you attempted so I can see where the problem may be.  Most likely, you can just change

ControlSetText($hWnd, '', '[CLASS:Edit;INSTANCE:7]', 'F22222', 0)

To

ControlFocus($hWnd, '', '[CLASS:Edit;INSTANCE:7]') 
Send("F22222")

 

Edited by TheXman
Link to comment
Share on other sites

@TheXman

Awesome. I got it figured out!

I tested the Send("F22222") but it didn't quite work. It was apparent that the existing six characters already stored in the textbox were blocking the sent characters. So I issued a Send command with six {Delete} first, followed by the Send("F22222"). It worked great! 

I also had to add a Sleep after the Send so that all six characters were accepted before closing the dialog with the OK button, otherwise it was going too fast.

Thanks for your help! I couldn't have gotten to this point without it!

 

Link to comment
Share on other sites

You're welcome!  I'm glad that you got it all sorted out.  :D

 

Edited by TheXman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...