Get Handle Of Window That Has Focus
How can I get the handle of the window (window, text box, etc.) that currently has focus?
The GetActiveWindow() API function only works in my program.
The GetForeground() API function gets the handle to the parent window of whatever control has focus. I need the handle to the actual control.
Edit: Sorry, didn't find it on the forum search but found one on Google.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Getting A Window Handle From A Process Handle
I have the process handle of an external process
created from within my application. I know that the
process is windowed and has a parent/top-level window.
How do I get the window handle from the process
handle? Please suggest an API that gets the window
handle of the top-level window by taking a process
"handle" (clarified, not process ID).
Pl. Help Me.... How Handle Shell Executed Window And Media Player Window
Hello With Regard
How are you
i have a big probloum sir please help me other wise i will be fired... my prob is ...
I m developing project my project is completed and running very fine but only 1 problom i have, My program start and running movie files with using media player property over movie i m using scrolling metter using IPLAY SCB files in overlay mode . when play first movie file it playing and overlay scrolling is good and when finish first movie file start 2nd movie file current media player window is gone and IPLAY scrolling file also gone.
i open IPLAY file with shell command like
SO sir how can i handel shell file it should constantly play over movie file some time i want to hide and after some time it should play over movie again. Sir also tell me way how movie files alwayes open in same window Or Pl. Sir Send me Code, How Media Player will open all movie files in same window and how manage Shell execute files
Please Sir Help me i will be fired ...I will highly obelized
i m using OS is Win XP or Win2000
Code i m using r writen Below
Dim fnam(10), ss
Private Sub Form_Load()
MP.AutoStart = True
MP.DisplaySize = mpFullScreen
Private Sub ply()
' Sir Please set here path for 3 movie clips
fnam(0) = "C:sks2promo.dat"
fnam(1) = "C:sks2part1.dat"
fnam(2) = "c:sks1song3.dat"
Dim i As Double
i = 0
For i = 0 To 2
If i = 0 Then
MP.FileName = fnam(0)
' Sir Here is NOT Required Overlay Shell Executed File_
' Shell Executed File Should Be Behind or Hidden
MP.FileName = fnam(i)
' Sir Only Here (On This Part Required)_
' Overlay Shell Executed File Only
Do While MP.PlayState = mpPlaying
Private Sub loadshell()
' Sir scroll.scb file i m sending u, for Play_
' scroll.scb file Pl. download free IPLAY (scala player)_
' from www.scala.com
ss = (Shell("c:Program Filesscalaiplayiplay c:sksscroll.scb", 1))
Get Active Window Handle / Minimize Window
I have two (hopefully) simple questions that I hoped could be answered.
How do you obtain the currently active window's handle? I have tried GetActiveWindow, it doesn't seem to work.
How do you minimize a window through the use of the window handle? I do not want to have to focus on the window I am trying to minimize.
Edit: I just thought of another question I need answered.
Could somone please tell me how to use the API SetCursor, and whether SetCursor persists through a restart?
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Popup Window (Focused Window Doesn't Lost Focus)
Hi all, I searched here in all the Forum and I din't found anythig about this question, but I spy into a popup window and I got the next Styles of a popup window and I give it to my form (it works)
The window need to be a NONE Border style from the Designer (Run time changes doesn't works, Don't ask me why ? :P)
When you need a Popup window you will need to use the ShowFloating sub instead of the Show method.
And voila !!, a popup window working.
Any fixes and suggestions about this code would be great and helpful to improve the way of doing this.
Private Const GWL_EXSTYLE As Long = -20
Private Const GWL_STYLE As Long = -16
Private Const SW_NORMAL As Long = 1
Private Const WS_EX_NOACTIVATE As Long = &H8000000
Private Const WS_EX_TOPMOST As Long = &H8&
Private Const WS_CHILD As Long = &H40000000
Private Const WS_CHILDWINDOW As Long = (WS_CHILD)
Private Const WS_CLIPCHILDREN As Long = &H2000000
Private Const WS_CLIPSIBLINGS As Long = &H4000000
Private Const WS_EX_LEFT As Long = &H0&
Private Const WS_EX_LTRREADING As Long = &H0&
Private Const WS_EX_RIGHTSCROLLBAR As Long = &H0&
Private Const WS_OVERLAPPED As Long = &H0&
Private Const WS_VISIBLE As Long = &H10000000
Private Const WS_POPUP As Long = &H80000000
Private Const HWND_TOPMOST As Long = -1
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOSIZE As Long = &H1
Private Const SWP_SHOWWINDOW As Long = &H40
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Sub ShowFloating()
'Setting the Widow Styles
SetWindowLong Me.hwnd, GWL_STYLE, WS_VISIBLE Or WS_CHILDWINDOW Or WS_CLIPCHILDREN Or WS_CLIPSIBLINGS
'Setting the Extended Window Styles
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_NOACTIVATE Or WS_EX_TOPMOST Or WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROOLBAR
'Set the Screen as Parent of the Window
SetParent Me.hwnd, 0
'Showing the window and set the TopMost window
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW
Closing A Window Using Window Handle.
I use a standard EXE to run an ActiveX EXE. The ActiveX EXE displays a form as a result. Along with the display of the form, a window handle was returned to the standard EXE. Later, I could use the window handle to close the window using DestroyWindow API, but I don't know how to close the running ActiveX EXE (closing the form doesn't stop the ActiveX EXE), because I can still a copy of it in Task Manager. I tried to use GetWindowThreadProcessId to the process ID, then use TerminateProcess to terminate the process that belongs to ActiveX EXE, but no luck.
Window Handle And Close Window
I try to get a handle on a window which is popped up by a special remote library. The programm stops as long as I have pressed the O.K. button on the window. After this I would get the handle, but this is to late. I want to get the handle when the window pops up. I think threads could solve this problem but they don't exist in VB. Has anyone an idea how can I get the handle? I have to start two functions similary but how does it work?
Thanks and greetings, tksvc ;-)
SendKey To A Window NOT In Focus - But Keep Focus?
Fyi, I'm fairly new to VB.
Anyway, to the point.
I have two applications, both running in full screen.
What I want to accomplish is that while one of the applications are running in focus (full screened), I want my VB program to run in the background and send a key on a regular basis to the other application (the one that is NOT in focus) without having to tab out of the focused application.
I managed to achieve some of this partly with the help of FindWindow and ShowWindow:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_NORMAL = 1
Private Const SW_MAXIMIZE = 3
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_RESTORE = 9
Dim hinst As Long
Dim hinst2 As Long
hinst = FindWindow(vbNullString, "PrgNotInFocus") ' The program that should not be in focus, but have keys sent to
hinst2 = FindWindow(vbNullString, "PrgInFocus") ' Should be in focus at all times
If Not IsNull(hinst) Then
ShowWindow hinst, SW_NORMAL
ShowWindow hinst, SW_MAXIMIZE
This allows me to bring forth the window that I don't want in focus and "makes it press 1".
But that's hardly the effect I'm looking for, since it:
-Tabs out of my current application and focuses the wrong one
-Requires the window I want to SendKeys to to be focused
Getting A Window Handle In VBA?
I have written a program in VBA that prints the contents of another window using the program's built in functions and .Sendkeys. When this happens, popus up a messagebox that gives the status of the print. If I send another command to the main window while the messagebox is active, my program gets lost. I need to code a "soft wait" as coding a "hard wait" (example: .Wait 1500ms) is not an option that will work 100% of the time.
How do I grab that messagebox window handle and test in a loop to see if it exists or not?
WinSpy++ Tells me it's a Child Window of the main program, with the class "PcsGrpHardcopy"
I don't know where to go from there.
i have been reading the forum posts and still don't understand what i want.
if i open an exe file wth shell, send some key strokes, how do i know when the app has finished. on nearly every forum post all i see is see shell and wait code! this does not help us newbees. please can someone actually write the code required. i assume we need to get the window handle and then analyise it. please help
Window Handle Always On Top
can i set a window to always on top, even if normal it isnt AND its not part of my app? in which case how do i get the hWnd of another windows application in the first place?
When I use the code below or any other Api to find a window handle it dosen't work unless I provide the classname. I need to be able to close a window without a classname, because the classname is different every time I start the program I want to kill. I see code like this every where that just uses the caption but without ther className I get 0 for a handle.
Thanks for any help
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Sub CloseProgram(ByVal Caption as String)
Handle= FindWindow(vbNullString, Caption)
If Handle = 0 Then Exit Sub
SendMessage Handle, WM_CLOSE, 0&, 0&
Public Const WM_CLOSE = &H10
Handle To A Window?
is there a way to get a handle of a window. Like there is Notepad open, and i want to get the handle of Notepad. How can this b achieved???
Window Handle, No What?
I have gotton a window handle, what can I use this for?
the most I have gotten from it is the window title... what else????
Getting Window Handle
hello, i am trying to get the hwnd of the start button on windows.
I can get it in C++ but in vb6 i cannot.
i have this: (yes all these functions are declared, correctly.)
Dim blnLock As BooleanDim strText As StringDim whWnd As LongDim lResult As Single blnLock = chkLock.Value strText = txtToChange.Text whWnd = GetDlgItem(FindWindow("Shell_TrayWnd", vbNull), 103) 'i believe 103 is where my error is coming from.'in c++ 103 would be 0x103 so im assuming this is where the problem is.. Debug.Print whWnd 'returns whWnd as 0 If whWnd = 0 Then lblError.Caption = "Error: " & _ Err.LastDllError & ": Error finding start button handle."'last dllerror gives me error 1400, window handle not found Exit Sub End If lResult = ChangeText(whWnd, blnLock, strText) Select Case lResult Case 1 lblError.Caption = "Changed without error" Case 0 lblError.Caption = "Error setting text" Case -1 lblError.Caption = "Error locking start button" End Select
i have comments in the code about my problem. if anyone knows what im doing wrong with getdlgitem please help me out.
m a newbie in vb so need ur help ...
Iam opening an application using my VB program...the window is not visible to the user ie its Hidden. I want to get the handle of that window....how to go bout it ?? Plz help
Help Please, I Cannot Get A Window Handle.
I am making an application that needs to find the handle, and I am trying a sample finding "Notepad" by the Find Window API with its classname. It recovers the wrong Handle.
Private Declare Function GetPixel Lib "gdi32" ( _ ByVal hdc As Long, _ ByVal x As Long, _ ByVal y As Long _) As LongPrivate Declare Function GetWindowDC Lib "user32" ( _ ByVal hwnd As Long _) As LongPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWndParent As Long, _ ByVal hWndChildAfter As Long, _ ByVal lpszClassName As String, _ ByVal lpszWindowName As String _) As LongPrivate Sub Autoread_Timer()Dim hWndNotepad As LonghWndNotepad = FindWindow("Notepad", vbNullString)a1.Caption = hWndNotepadEnd Sub
It will recover a handle but if I use Spy++ to find out what the handle actually is, its different.
I've been trying to find a way to Search all of the captions of all of the windows open for a speciific string for 4 days! ie. "Diablo II" or "StarCraft" but I can't find a good tutorial that works. Plus, what happens if 2 windows with the classname I am searching are open?
Edit: Added [vbcode][/vbcode] tags for more clarity. - Hack
How do you find a window's handle?
Like the system tray is called "traywnd".
Getting Handle Of A Window
if there are 2 parent windows of the same name , then how can i get access to the window which i want to?
Getting Handle Of A Known Window
1st of all, to clear it out for you, I know how to get the handle of any window or control. However, I need to know how can I get the handle of a known window each time!
I mean, as the window owner application ends and starts again, its windows handles change! How can I know the handle of MSN Messenger main window supposidly each time I run my program?
Is there a way to get a windows handle just by clicking it?
How Do I Get The Handle Of A Window?
I know Winamp's main window class name is "Winamp v1.x" so I can use the following to help find the location:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long hWndWinAMP = FindWindow("Winamp v1.x", vbNullString)
Does anyone know how to find classnames of other windows? For example, I want to find it for the Playlist window.
Get Handle Of A Window
I know this topic has been posted, but I still don't understand how it works. I start an exe with another VB exe. So I have the process ID, I checked, it's the correct one, and I have the name of the exe. Now I want to get the handle of the window of that process, but it always return 0. I'm trying to do this with the FindWindow Method, but it doesn't work. If I terminate the process using the process, it's no problem, using FindWindow is. Am I missing something? I mean, the task is there, the exe is running, I can kill it, but I can't get a window handle from it. Somebody have an idea what I'm doing wrong?
Thx in advance.
Get Window Handle
How to display the handle of all open windows on my desktop (even if they are not active)
Get Window Handle
How to get the handle of all open window (even if they are not active).
for example i have word, explorer and calc running, i'd like to have my program displaying 3 msgbox with the handle of this 3 windows
Get A Window's Handle
I've created a Word application in my VB app using the Word Object Library. I need to be able to get the handle of this word application, as I want to show a form through my VB app with Word as it's owner,
Ie: frmWordFunctions.Show 1, hWndWordApp
Any ideas ????
Ps. Any info on getting another windows handle full stop would also be appreciated.
Hi, how can I find a window handle from its ProcessID? I'm launching an executable from a list of a few hundred and don't know the resulting window's caption, so FindWindow doesn't always work.
Thanks in advance,
Does anyone know how to get the handle of a window when the mouse is pulled over it. It is not a window in my application. I would like to try and make it like the interface in Spy++'s Find Window function.
Thank you to anyone that can help!
Is there a way in .net to get a window handle or do I still need to use an API call? I'm need to determine if a window with a certain name exists and if it does activate it and send keystrokes to it. I've done similar in VB6 with API but figued 2005 had some better way to do it.
Getting The Window Handle
I am looking for a function that can return the window handle (hWnd) of a window that is not part of my application. This isn't really my 'area of expertise' so I couldn't make heads or tails out of what I was reading on MSDN.
Edited by - zAnYzAcH90 on 1/23/2005 9:14:05 AM
Getting Window Handle
Any body help me in finding window handle number of any object from any application.
Getting The Window Handle
I am launching an application or file using ShellExecute function. I want to get the handle of the window which resulted as a result of my call to ShellExecute.
How do i do that?
ShellExecute is just one command I know. Is three any other command which can launch and applications and files.
I want to get the reference of any appplication running on
my computer for that I used getobject() ,this is working only
for word and excel. for out look and all Its giving error that
"Activex component cant create the object"
If I use Findwindow()(It's window API) Its' returning long
How to convert to object..
does anyone know hot to get the window handle of a word97 app.
dim objapp as word.application
dim objdoc as word.document
neither objapp or objdoc have a hwnd option.
Handle Of A Window?
Anyone knows how to find out the name of the handles of different windows in different programs?
is there any special program to do that (like i click onto window and it tells me it's handle name?) Or maybe some other way?
Getting IE Window Handle
suppose i add an VB6.0 standard exe( say app1 ) in IE4.0 favorites . and run that exe ( app1 ) from ie . is it possible for app1 to get the window handle of that particular ie instance .
How Do I Get A Window Handle
I am trying to get the the handle for the present window, from inside the Serialize function within the Doc class. This is what i am using:CWnd* m_pMainWnd = GetParent();
but it doesn't work. I'm at a loss as to what I should use. Any help would be greatly appreciated!
Still trying to get past the learning curve on this end...
Window Handle From Part Name
i need to get the window handle to an extranal app. have always used findwindow or findwindowex. however this particular window name is always changing. the first half of the name is always the same however. basically the second half of the name has a percentage built into. so the longer the window is open the percentage increases. therefore i can only search for the first part of the window name.
how do you search for a window handle when you only have part of the window title. findwindow won't accept a wildcard.
Get Window Properties By Handle
Hi, i am using FindWindow to get the handle of a window which i want to talk a screenshot of. How can i get the follow attribute values off the window and assign them to a variable.
Retrieving Window Handle
I need to retrieve the window handle to a particlar window. The trouble is that I cannot rely on the class name or the window name. Is there a way to retrieve the handle without shelling it from my application?
Find Window Handle
How can I find a window's handle by dragging something onto the window, like in Spy++ if you choose Search > Find Window?
Grabbing The Window Handle
Is there a way to grab the window handle of the currently active textbox in a program other than one you wrote, eg the address box in ie, username & password box of dial up connection, etc. I want to make a web browser which is able to interact with the standard windows browser and would like it to be able to load settings from the dialup window when it is first installed etc.
Edit: Also, is there a way to get the handle of the window containing the point (x,y)
Bitmap Window Handle?
Do Bitmaps that are displayed in an application have a window handle? If so (or not) can any information about the image be obtained via the API?
I'm trying to write an app that will be able to determine what bitmap image is being displayed on a another application that is running concurrently. I've been successful in pulling information out of other controls such as a RichEditBox, ListBox, etc....but I've had no such luck with an image.
Thanks for your help!