Results 1 to 4 of 4

Thread: Findwindow & FindwindowEx Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    8

    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:
    1. Call SendMessage(FindWindow("Notepad", vbNullString), WM_KEYDOWN, vbKeyF1, 0)
    2. Call SendMessage(FindWindow("Notepad", vbNullString), WM_KEYUP, vbKeyF1, 0)
    THX ...

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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
    .

  3. #3
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width