[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Get App Name?

Posted on 2003-11-05
9
Medium Priority
?
309 Views
Last Modified: 2010-05-03
how can I get the name of the window/application oppened?
For example if user oppened WINDOWS EXPLORER. then the application will msgbox
WINDOWS EXPLORER OPENED
or whatever...
how can it be done?

thanks for any help
0
Comment
Question by:deathman5
[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
9 Comments
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9688628
you could monitor all the windows and when a new one is made you could grab the name from that.  but then your using timers.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 186 total points
ID: 9688636
"System Wide Shell Hook Dll (Version 2.0)"
http://www.freevbcode.com/ShowCode.Asp?ID=1308
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9688713
i swear ive seen that name somewhere, azrasound....  are you around in DC any?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 28

Expert Comment

by:AzraSound
ID: 9688771
No, I live in Houston.  Perhaps from another forum?  Perhaps you listen to house music?
0
 
LVL 16

Assisted Solution

by:Richie_Simonetti
Richie_Simonetti earned 96 total points
ID: 9688800
Logging use of executables in Windows

This handy little tip can be used to log the use of .exe, .lnk, .pif, .bat, and .com files on your computer. All it needs is a little registry tinkering. Place this code in a module, and set the project startup object to 'Sub Main'

Procedure

Sub Main()
If Command$ <> "" Then
Open "c:\apps\exelog.txt" For Append As #1
Print #1, Command$ & " " & CStr(Now)
Close #1
Call Shell(Command$, vbNormalFocus)
End If
End
End Sub

Registry Changes

The registry changes are:

HKEY_CLASSES_ROOT\exefile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\lnkfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\piffile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\batfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\comfile\shell\open\command to: "C:\exewrap.exe" "%1" %*

What happens it that instead of running the program directly, Windows calls our program, which logs filename and time, and then calls the program.
 
This code belongs to Allapi.net - Url is no longer available
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9688831
hehe, i live in ohio, by DC i meant direct connect.  this is going to bug me forever now.

But on to the question,
Are you trying to halt execution of certain programs or did you want to just log what programs are being used?  
0
 

Assisted Solution

by:toddpasley
toddpasley earned 93 total points
ID: 9691332
Hi,

I assume you mean a applicaiton you have just executed??? If so, then you have the HWnd

From the Hwnd, you can use GetWindowText WIN API to access the title.

Like....
' Add the following declarations to get window title.
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long


' then use the following code to get the title.
    Dim wincapt As String
 
    'Get the windowtext length
    wincapt = Space$(GetWindowTextLength(hwnd) + 1)
    'get the window text
    GetWindowText hwnd, wincapt, Len(wincapt)
    'remove the last Chr$(0)
    wincapt = Left$(wincapt, Len(wincapt) - 1)

    ' wincapt holds the title of the window with the handle hwnd.
    MsgBox wincapt + " just opened"




If you instead mean that you want to monitor as the user opens stuff rather than your applicaiton... then simply hook into the windows message queue and wait for WM_ACTIVATE or WM_ACTIVATEAPP messages. When one is sent, grab the hwnd and apply the code above.

Hope this helps,

Todd.
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9692020
I am not sure what are you up to:
This example will list all the windows activate at the time
http://www.thescarms.com/VBasic/alttab.asp

If you want to monitor all the windows a user open using this example, my advice is to use a timer (interval = 1000), and record the difference if new program added to the list.

However, if you already have the hwnd, then it is advisable to use the API GetWindowText & GetWindowTextLength

~ fantasy ~

0
 

Author Comment

by:deathman5
ID: 9693685
thx everybody, but Shell Hook Dll was what I wanted :)
But thx 4 anybody how helped
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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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