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

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
?
354 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
[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
  • 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
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!

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

670 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