GHawk Posted June 10, 2018 Share Posted June 10, 2018 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! Link to comment Share on other sites More sharing options...
TheXman Posted June 10, 2018 Share Posted June 10, 2018 (edited) @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 June 10, 2018 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
GHawk Posted June 11, 2018 Author Share Posted June 11, 2018 @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 More sharing options...
TheXman Posted June 11, 2018 Share Posted June 11, 2018 (edited) 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 June 11, 2018 by TheXman GHawk 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
GHawk Posted June 11, 2018 Author Share Posted June 11, 2018 @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 More sharing options...
TheXman Posted June 11, 2018 Share Posted June 11, 2018 (edited) You're welcome! I'm glad that you got it all sorted out. Edited June 11, 2018 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now