CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Location
    Canada
    Posts
    7

    Sendkeys and Photoshop

    I've been trying to automate Adobe Photoshop 5.0 using Sendkeys. It ain't workin'.

    AppActivate "Adobe Photoshop", True
    For t = 0 To Files.ListCount - 1
    SendKeys "^o", True
    For x = 1 To 1000
    DoEvents
    Next x

    etc, etc.

    This is supposed to send CTRL-O to Photoshop, but Photoshop does not register the CTRL part and just gets O. As far as I know, Photoshop 5 doesn't support scripting in any other way and I've got an if statement in this sucker since I want to convert all the pictures of an entire directory to 800x600, then save them in a certain fashion, but only if they were larger than 800x600 to begin with.

    Any ideas of what I can try? Full code follows:

    Private Sub Command1_Click()
    Dim DoIt As Boolean
    If Text2.Text <> "" Then
    If Right(Text2.Text, 1) <> "\" Then Text2.Text = Text2.Text & "\"
    Text2.Visible = False
    Text1.Visible = False
    Command1.Visible = False
    Text3.Visible = True
    Files.Path = Text2.Text
    AppActivate "Adobe Photoshop", True
    For t = 0 To 0 'Files.ListCount - 1
    SendKeys "^o", True
    For x = 1 To 1000
    DoEvents
    Next x
    SendKeys Text2.Text & Files.List(t), True
    SendKeys "~", True
    For x = 1 To 1000
    DoEvents
    Next x
    SendKeys "%i", True
    SendKeys "i", True
    SendKeys "^c", True
    AppActivate "Convert", True
    Text3.Text = ""
    SendKeys "^v", True
    DoIt = True
    If Val(Text3.Text) > 800 Then
    FileCopy Text2.Text & Files.List(t), "L:\Pictures\Backup\" & Files.List(t)
    ElseIf Val(Text3.Text) < 800 Then
    DoIt = False
    End If
    AppActivate "Adobe Photoshop", True
    If DoIt Then
    SendKeys "800~", True
    For x = 1 To 1000
    DoEvents
    Next x
    SendKeys "^s", True
    For x = 1 To 1000
    DoEvents
    Next x
    End If
    SendKeys "^w", True
    End If
    Next t
    Text1.Text = "Done"
    Text2.Visible = True
    Text1.Visible = True
    Command1.Visible = True
    Text3.Visible = False
    AppActivate "Convert"
    End Sub


  2. #2
    Join Date
    May 2001
    Posts
    24

    Re: Sendkeys and Photoshop

    You need put the right file in the shell to run Photoshop,
    by the click button.

    Dim lngTaskID As Long

    Private Sub Command1_Click()

    On Error GoTo Activate_Err
    lngTaskID = Shell("C:\Program Files\Photoshop.EXE", vbNormalNoFocus)
    AppActivate lngTaskID, False
    SendKeys "^o", True

    Activate_Exit:
    Exit Sub

    Activate_Err:
    Resume Activate_Exit
    End Sub




  3. #3
    Join Date
    May 2001
    Location
    Canada
    Posts
    7

    Re: Sendkeys and Photoshop

    Sorry, my fault. I failed to explain that Photoshop is ALREADY RUNNING when I try this code...

    I've done this before with another program (ULead's IPhoto Plus) and it worked fine. The problem here is that Photoshop is NOT REGISTERING THE CONTROL element of the Sendkeys. Thus if my command is SendKeys "^o", then Photoshop behaves as though I had simply pressed "o" and not CTRL-o.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured