Solved

How can I find the Classname of an app that is not listed in this Select statement?

Posted on 2009-05-07
15
349 Views
Last Modified: 2012-05-06
In the fIsAppRunning function that is described in PAQ (http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20564558.htm) how can I determine what the classname is of a different app like Adobe Acrobat so I cam set strClassName.

strClassName = "Acrobat" -> Does not work

Select Case LCase$(strAppName)
        Case "Acrobat":              strClassName = "Acrobat"
        Case "excel":                  strClassName = "XLMain"
        Case "word":                  strClassName = "OpusApp"
        Case "access":               strClassName = "OMain"
        Case "powerpoint95":     strClassName = "PP7FrameClass"
        Case "powerpoint97":     strClassName = "PP97FrameClass"
        Case "notepad":              strClassName = "NOTEPAD"
        Case "paintbrush":          strClassName = "pbParent"
        Case "wordpad":            strClassName = "WordPadClass"
        Case Else:                       strClassName = vbNullString
End Select

Open in new window

0
Comment
Question by:scuzz1
  • 6
  • 3
  • 3
  • +1
15 Comments
 
LVL 15

Expert Comment

by:Simon Ball
ID: 24333709
Case Else:              msgbox         strClassName

will this identify?
0
 
LVL 15

Expert Comment

by:Simon Ball
ID: 24333720
sorry
msgbox strAppName not strclassname
0
 
LVL 84
ID: 24334219
You're passing a value INTO the Select Case statement, and taking action based on that. I don't see how you can determine what class is running UNLESS you pass in the name of that class (i.e. the strAppName variable).

What exactly is this code supposed to do?
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 15

Expert Comment

by:Simon Ball
ID: 24336031
your PAQ url goes to a page not found error.
0
 
LVL 27

Expert Comment

by:MikeToole
ID: 24338124
Are you using Acrobat? - Adobe Reader doesn't support OLE automation
See this document on Inter-application communication
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
0
 

Author Comment

by:scuzz1
ID: 24338185
Sorry about the link. This is the code I am referring to. It is using apiFindWindow and passes that function either the (i'm guessing here) Application Name in strAppName or the Application's Class Name in strClassName. The program that I want to check for is Tech Illustrator. TI.exe is the program to execute but for some reason I cannot determine what to pass to the apiFindWindow function to tell whether or not it is running. I cannot even get it to tell me if Acrobat is running.

Jim

Private Const SW_SHOWNORMAL = 1
Private Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
 
Private Declare Function apiFindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal strClass As String, _
    ByVal lpWindow As String) As Long
 
Private Declare Function apiSendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal Hwnd As Long, ByVal Msg As Long, ByVal _
    wParam As Long, lParam As Long) As Long
   
Private Declare Function apiSetForegroundWindow Lib "user32" Alias _
    "SetForegroundWindow" (ByVal Hwnd As Long) As Long
   
Private Declare Function apiShowWindow Lib "user32" Alias _
    "ShowWindow" (ByVal Hwnd As Long, ByVal nCmdShow As Long) As Long
   
Private Declare Function apiIsIconic Lib "user32" Alias _
    "IsIconic" (ByVal Hwnd As Long) As Long
   
Function fIsAppRunning(ByVal strAppName As String, _
        Optional fActivate As Boolean) As Boolean
 
    Dim lngH As Long
    Dim strClassName As String
    Dim lngX As Long
    Dim lngTmp As Long
 
    Const WM_User = 1024
 
    On Local Error GoTo fIsAppRunning_Err
 
    Select Case LCase$(strAppName)
        Case "excel":        strClassName = "XLMain"
        Case "word":         strClassName = "OpusApp"
        Case "access":       strClassName = "OMain"
        Case "powerpoint95": strClassName = "PP7FrameClass"
        Case "powerpoint97": strClassName = "PP97FrameClass"
        Case "notepad":      strClassName = "NOTEPAD"
        Case "paintbrush":   strClassName = "pbParent"
        Case "wordpad":      strClassName = "WordPadClass"
        Case Else:           strClassName = ""
    End Select
   
    If strClassName = "" Then
        ' Use what was given.
        lngH = apiFindWindow(vbNullString, strAppName)
    Else
        ' Use the Class Name substituted by the Select Case.
        lngH = apiFindWindow(strClassName, vbNullString)
    End If
 
    If lngH <> 0 Then
        apiSendMessage lngH, WM_USER + 18, 0, 0
        lngX = apiIsIconic(lngH)
 
        If lngX <> 0 Then _
            lngTmp = apiShowWindow(lngH, SW_SHOWNORMAL)
 
        If fActivate Then _
            lngTmp = apiSetForegroundWindow(lngH)
 
        fIsAppRunning = True
    End If
 
fIsAppRunning_Exit:
    Exit Function
 
fIsAppRunning_Err:
    fIsAppRunning = False
    Resume fIsAppRunning_Exit
 
End Function

Open in new window

0
 

Author Comment

by:scuzz1
ID: 24355608
>>> You're passing a value INTO the Select Case statement, and taking action based on that.
I don't see how you can determine what class is running UNLESS you pass in the name of that class (i.e. the strAppName variable).

I understand that. What I am asking is how can I find out what the classname of an application is so I can pass it to the function.

Jim

0
 
LVL 27

Expert Comment

by:MikeToole
ID: 24355920
Sorry, I can't find any reference source for the illustrator classname
0
 

Author Comment

by:scuzz1
ID: 24358995
I wonder if everyone understands what I am asking.

How did the author of this code know that Excel's classname is XLMain or paintbrush is PBParent. Is there somewhere that one can look that information up?
0
 
LVL 84
ID: 24359028
The developer of the utility/program would be the best source. If you're looking for Illustrator, www.adobe.com would be the place to look.
0
 

Author Comment

by:scuzz1
ID: 24370990
You would think that "Adobe" or "Acrobat" or "Acrobat 8.0" would be the "AppName" but I have tried every name I can think of and the function does not recognize it. Even for Autotrols Tech Illustrator, I have tried "TI", Tech Illustrator Plus" (which is the name at the top of the window) but nothing works. I am starting to think that that function only works with the programs listed in the select statement.

Jim
0
 
LVL 27

Accepted Solution

by:
MikeToole earned 500 total points
ID: 24372312
This is extracted from
http://www.adobe.com/devnet/illustrator/pdfs/illustrator_scripting_reference_vbscript.pdf
- not sure if it will help.
The Adobe Illustrator application object, which contains all other Illustrator objects.
NOTE: If you have both earlier and later versions of Illustrator installed on the same machine and use the
CreateObject() or GetObject() method to obtain an application reference, use the optional numeric
version identifier at the end of the string Illustrator.Application. When the version identifier is not
present, the string refers to the latest installed Illustrator version. To specifically target a version:
¤ For Illustrator 10, use Illustrator.Application.1
¤ For Illustrator CS, use Illustrator.Application.2
¤ For Illustrator CS2, use Illustrator.Application.3
¤ For Illustrator CS3, use Illustrator.Application.4
¤ For Illustrator CS4, use Illustrator.Application.5 (same as Illustrator.Application)
0
 
LVL 84
ID: 24373143
Mike has done the heavy lifting for you on this; as I said, you often need to go back to the vendor to find out exactly what to use. There is no master list, as far as I know.

One method you might use is this:

Temporarily add a Reference in your project to the item you wish to work with. Now declare a variable and use Intellisense to see if you can locate the classname. IOW, type this:

Dim obj As

And Intellisense should present to you a listing of the various objects available for use. Once you know the object name, make sure to remove that reference.
0
 

Author Comment

by:scuzz1
ID: 24391399
Sorry about the delay's in responding. I have been pretty busy. I am going to research what Mike has suggested and see what I can dig up. I will get back.

Thanks for all your efforts. I really do appreciate it.
Jim
0
 

Author Closing Comment

by:scuzz1
ID: 31579043
Thanks,

I am going to go with your suggestion on the GetObject() method. It may take a while for me to get it to work for me but I'll get.

Thanks Again,
Jim
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 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