Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

using sendkeys

Posted on 1998-12-31
8
Medium Priority
?
468 Views
Last Modified: 2008-03-17
I'm having problems getting sendkeys to work in photoshop. I could get it to work in notepad. I think with Photoshop is that when it first starts up, there is a splash screen that comes up and stays there for a while. During that time, I'm using sendkeys to photoshop and they're not getting through. Below is the code.

Private Sub cmdNotePad_Click()
   Dim RetVal
   RetVal = Shell("Notepad.exe", 1)
   SendKeys "ab", True
   SendKeys "%fa", True
End Sub

Private Sub cmdPhotoshop_Click()
   Dim RetVal
   RetVal = Shell("D:\Program Files\Adobe\Photoshop 5.0\Photoshp.exe", 1)
   SendKeys "%fn", True
End Sub

My question is how do I wait for that splash screen to go away and then send the sendkeys command?
0
Comment
Question by:furley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 2

Expert Comment

by:VBDesigns
ID: 1453473
Doesn't Photoshop have an ActiveX/OLE interface you can use to communicate with it?  (I know it doesn't answer your sendkeys, but that would be the way to use it)
0
 

Author Comment

by:furley
ID: 1453474
yes it does. It's called OLE Automation. Even if I use it, I would still need to use sendkeys. Unfortunately, Photoshop's support for OLE doesn't seem to be very reliable. I've tried the above code on Word, which has a splash screen come up and everything worked fine, so it may not be a splash screen problem.
0
 
LVL 2

Expert Comment

by:kswinney
ID: 1453475
Change your code to look like this:

Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Private Sub cmdPhotoshop_Click()
   Dim RetVal
   RetVal = Shell("D:\Program Files\Adobe\Photoshop 5.0\Photoshp.exe", 1)
   'The 3000 makes it sleep for 3 seconds. Add for longer sleep
   Sleep 3000
   SendKeys "%fn", True
End Sub

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:furley
ID: 1453476
That didn't work. I don't think the splash screen is the problem and I don't think there's anything wrong with the code. I think there's something wrong with Photoshop.
0
 
LVL 3

Expert Comment

by:groone
ID: 1453477
Try the keyb_event, I think this should work in photoshop

' in a bas module past
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

' your code
Private Sub cmdNotePad_Click()
       Dim RetVal
       RetVal = Shell("Notepad.exe", 1)
       keybd_event 65, 0, 0, 0 'A press Down
       keybd_event 65, 0, 2, 0 'A released
       keybd_event 66, 0, 0, 0 'B press Down
       keybd_event 66, 0, 2, 0 'B released

       keybd_event 18, 0, 0, 0 'Alt press Down
       keybd_event 70, 0, 0, 0 'f press Down
       keybd_event 65, 0, 0, 0 'A press Down
       keybd_event 70, 0, 2, 0 'f released
       keybd_event 65, 0, 2, 0 'A released
       keybd_event 18, 0, 2, 0 'Alt released
    End Sub

    Private Sub cmdPhotoshop_Click()
       Dim RetVal
       RetVal = Shell("D:\Program Files\Adobe\Photoshop 5.0\Photoshp.exe", 1)
       SendKeys "%fn", True
    End Sub
0
 
LVL 2

Expert Comment

by:hobster
ID: 1453478
where did you get those numbers for each keybd_event?
0
 
LVL 3

Expert Comment

by:groone
ID: 1453479
in vb help, do a search for  "Key Codes" then select the "key codes constants" its a great list.
0
 

Accepted Solution

by:
edunc earned 20 total points
ID: 1453480
make a new timer and make sure enabled = false
then use this code:
Private Sub cmdPhotoshop_Click()
   Dim RetVal
   RetVal = Shell("D:\Program Files\Adobe\Photoshop 5.0 Photoshp.exe", 1)
   timer1.interval = 100 * 'how ever many seconds the splash screen usually takes
   timer1.enabled = true
End Sub

private sub timer1_timer
  SendKeys "%fn", True
end sub

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question