Sign in to follow this  
Followers 0
reverse

Help with my script

4 posts in this topic

#1 ·  Posted (edited)

Hi there.

I wrote a script to personalize my photoshop projects (it adds names and surnames from txt file).

It works semi-automatic because I still have to click the gui etc.

Here's what I made:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $file = FileOpen("lista.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf


; Read in lines of text until the EOF is reached
While 1
    Local $line = FileReadLine($file)
Local $i
    If @error = -1 Then MsgBox(262144,"The End", "The End !!!") ExitLoop
       
       Clipput($line)
          
      
      GUICreate("H", 250, 175,880,200,1,$WS_EX_TOPMOST)
GUICtrlCreateLabel($line, 30, 10)
$okbutton = GUICtrlCreateButton("Next", 20, 70, 60)
$okbutton2 = GUICtrlCreateButton("Save", 90, 70, 60)
$okbutton3 = GUICtrlCreateButton("!!!", 160, 70, 60)
$okbutton4 = GUICtrlCreateButton("++", 160, 105, 60)
GUISetState(@SW_SHOW)


While 1
  $msg = GUIGetMsg()

  Select
  Case $msg = $okbutton

      GuiDelete("H")
      Sleep(200)
      ControlSend("[CLASS:Photoshop]","","","^{NUMPADENTER}") 
      Sleep(200)
      ExitLoop
   
   Case $msg = $okbutton2

      GuiDelete("H")
      Sleep(200)
      ControlSend("[CLASS:Photoshop]","","","^{NUMPADENTER}") 
      sleep(1000)
      send("^s")
    Do
    sleep(200) 
    until PixelGetColor(342, 299)=0xFFF791
    
    sleep(200)
    $i=$i+1
    Send($i)
    Sleep(200)
    Send("{ENTER}")
    Do
    sleep(200) 
 until PixelGetColor(416, 319)=0x21A121
 Send("{ENTER}")
      Sleep(200)
     ExitLoop 
      Case $msg = $okbutton3

      GuiDelete("H")
      Sleep(200)
      ControlSend("[CLASS:Photoshop]","","","^{NUMPADENTER}") 
      sleep(1000)
      send("^s")
    Do
    sleep(200) 
    until PixelGetColor(342, 299)=0xFFF791
    
    sleep(200)
    $i=$i+1
    Send($i)
    Send("{!}")
    Send("{!}")
    Send("{!}")
    Send("{!}")
    Send("{!}")
    Send("{!}")
    Sleep(200)
    Send("{ENTER}")
    Do
    sleep(200) 
 until PixelGetColor(416, 319)=0x21A121
 Send("{ENTER}")
      Sleep(200)
      ExitLoop
   
   
   Case $msg = $okbutton4

      GuiDelete("H")
      Sleep(200)
      ControlSend("[CLASS:Photoshop]","","","^{NUMPADENTER}") 
      sleep(1000)
      send("^s")
    Do
    sleep(200) 
    until PixelGetColor(342, 299)=0xFFF791
    
    sleep(200)
    $i=$i+1
    Send($i)
    Send("{+}")
    Send("{+}")
    Sleep(500)
    Send("{ENTER}")
    Do
    sleep(200) 
 until PixelGetColor(416, 319)=0x21A121
 Send("{ENTER}")
      Sleep(200)
      ExitLoop
   
  EndSelect
WEnd 
      
WEnd

 

FileClose($file)

I'm homegrown coder so I need your help with it.

I need it to be fully automatic.

I'd like it to read lines from file, paste it to the given location (after selecting text) and then save file.

The problem for me is I can't figure out how to make it save the file every second or third "pasting".

The files I work with (in Photoshop) are divided in two or three parts.

Script should run like this:

Read first line from txt file and copy it to clipboard, Paste data from txt to line 1, go to the second line in txt file and copy it to clipboard, paste data to line 2, save file, go to third line in txt file and copy to clipboard, paste data to line 1, copy and paste the fourth line from txt to line 2, save file... and repeat steps till the end of txt file.

I just don't know how to make the script save file every second (or third) loop.

I hope you understand what I'm trying to accomplish.

Sorry for my english and Thx for your help :)

Edited by reverse

Share this post


Link to post
Share on other sites



If you just want to watermark/tag stuff a great free program I use is called IrfanView and it can do batch processing and is easily automated via cmd/autoit.

Not saying its the solution just wanted to offer it up incase it works better for you.

 

As far as your current project, as far as I can tell you already got it automated just your doing it with a GUI.

Strip the GUI away and create a loop to run most of your commands.  It should be pretty straight forward as long as you have a way to wait/check for each step in the loop.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thx for answer.

My projects are text based photoshop files so Irfan is not the solution.

The problem I have is I can't make the script to save file every second or third loop.

I'm able to make it save file every time the loop ends, but I need it to work like: loop, loop, save, loop, loop, save.... and so on.

 

I was wondering if adding new variable and checking if it can be devided by 2 (or 3) will help but I don't know how to do it (or is it good idea at all).

Edited by reverse

Share this post


Link to post
Share on other sites

You can If/Then Statements, Case/Switch, or embedded loops.  

Maybe an example would be.

While 1 ;Outer Loop
    While 1 ;Inner Loop
    ;Do Something Part 1
    ;Do Something Part 2
    WEnd ;End of Inner Loop
;First Inner Loop Ended Now Save
WEnd ;End of Outer Loop

If I grasped what your doing exactly and what was in each loop that is not working for you as a single loop I could probably give a better example. 

Share this post


Link to post
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
Sign in to follow this  
Followers 0