Results 1 to 7 of 7

Thread: Windows API

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    6

    Windows API

    Ok guys,
    I used PAT or JK's API SPY 51.exe as an API spy. I then checked the option to generate the code that clicks the button I release the cursor on. The code generated is supposed to click the play button on winamp from my visual basic application. It generated this
    Code:
    Private Sub Command1_Click()
    Dim winampvx As Long
    winampvx = FindWindow("winamp v1.x", vbNullString)
    Call SendMessageLong(winampvx, WM_LBUTTONDOWN, 0&, 0&)
    Call SendMessageLong(winampvx, WM_LBUTTONUP, 0&, 0&)
    End Sub
    But see... FindWindow isnt declared nor is SendMessageLong. I believe I need a module for this? What do I need to make this work? I'm sorry for the bad explanation I don't know how else to put it. Thanks for the help in advance.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Put in a module :

    VB Code:
    1. Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    6

    same thing...

    Ok that didnt work... SendMessageLong still wasnt declared so i changed
    Code:
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    to

    Code:
    Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    And then i stopped getting errors, but it didnt work at all!!!

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Looking at the code, I see that it probably won't work since you would have to do a FindWindowEx to get the hwnd of the button. Now you are simulating a click on the main window of WinAmp, not the button on it. Try searching here for something similar...


    Has someone helped you? Then you can Rate their helpful post.

  5. #5
    Member
    Join Date
    Mar 2004
    Location
    Texas
    Posts
    53
    Well when u call

    VB Code:
    1. Call SendMessageLong(winampvx, WM_LBUTTONDOWN, 0&, 0&)

    That's a generic mouse button down, you do not specify where it happens, so the code wont work unless you pass the point where the left mouse button was clicked. I could never figure out how to do that but that's the reason the code wont click your button.

    NOW if u got the direct handle of the button you want to click this code would work, and is what i'd suggest doing.
    Good programming site:
    *http://www.planet-source-code.com

    Our CS Clan Page:
    *http://h2p.inter-gamer.com/index.html

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Originally posted by Insane_Magician
    NOW if u got the direct handle of the button you want to click this code would work, and is what i'd suggest doing.
    Funny... I just tried the API Spy and it doesn't give you a seperate handle for the buttons...


    Has someone helped you? Then you can Rate their helpful post.

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    You can use certain wm_command calls to control winamp and get info from it:

    http://www.scottandmichelle.net/scot...mv?codenum=009

    http://www.byalexv.co.uk/WinampControl.bas
    Remember, if someone's post was not helpful, you can always rate their post negatively .

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