Findwindow & FindwindowEx Help
i used Findwindow Api and i got the handle i wanna but i want add to listbox the handle of each App like (i have 2 notepad opened ) Findwindow will get the first handle i want to know the first and the sec handl and add them to listbox to sendmessage for the selected ...
and i have a sec question :
how can i sendmessage as a keybord Event not as a char
And i tried this code for sendMessage F1
Code Code:
Call SendMessage(FindWindow("Notepad", vbNullString), WM_KEYDOWN, vbKeyF1, 0)
Call SendMessage(FindWindow("Notepad", vbNullString), WM_KEYUP, vbKeyF1, 0)
THX ...
Re: Findwindow & FindwindowEx Help
Not sure why but using WM_IME_KEY* instead of WM_KEY* works on notepad under WinXP.
Code:
SendMessage Handle, WM_IME_KEYDOWN, vbKeyF1, 0
SendMessage Handle, WM_IME_KEYUP, vbKeyF1, 0
To get a list of all notepads search for code using EnumWindows.
If you're still stuck post back, I can probably modify some code I already have
.
Re: Findwindow & FindwindowEx Help
I am trying to do similar, but to a "File download" window from a webbrowser. The program finds and downloads a file, but I am trying to automate clicking "save" in the window with the title "File Download" (alt-s would be considered the same thing) then "save" in the window with the title "Save As" (Enter is the same thing here). Saving the file any other way (through inet, et al) is not an option. I obviously have the window title, but getting a hwnd from that is eluding me as I don't have the full details as required above.
Alternatively, is there a way to set a webbrowser to automatically save files without requiring input from the user? I would assume it's something to do with settings somewhere for IE, but I don't know for sure how to do it :)
Re: Findwindow & FindwindowEx Help
Quote:
Originally Posted by smUX
I am trying to do similar, but to a "File download" window from a webbrowser.
You can try this,
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const BM_CLICK = &HF5
Code:
Dim r As Long, BtnSave As Long
r = FindWindow("#32770", "File Download")
If r > 0 Then
BtnSave = FindWindowEx(r, 0, "Button", "&Save")
If BtnSave > 0 Then SendMessage BtnSave, BM_CLICK, 0, 0
End If
You could put the code in a timer or loop, then once it finds the window and sends a click to the save button you'd stop/exit the timer/loop
.