Solved

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

Posted on 2009-05-07
15
347 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
Comment Utility
Case Else:              msgbox         strClassName

will this identify?
0
 
LVL 15

Expert Comment

by:Simon Ball
Comment Utility
sorry
msgbox strAppName not strclassname
0
 
LVL 84
Comment Utility
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
 
LVL 15

Expert Comment

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

Expert Comment

by:MikeToole
Comment Utility
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
Comment Utility
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
Comment Utility
>>> 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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 27

Expert Comment

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

Author Comment

by:scuzz1
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now