Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-05-07
15
Medium Priority
?
356 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 85
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 85
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 2000 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 85
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

782 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