Results 1 to 6 of 6

Thread: [RESOLVED] Click OK Button in VB6

  1. #1

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Resolved [RESOLVED] Click OK Button in VB6

    I got the Display properties window up, but I have no idea to go about making vb6 click the ok button.

    I used WinID from Gigemboy's sig, and I got the results below.

    What info should I use and with what code?
    Last edited by kregg; Aug 11th, 2007 at 04:50 PM.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Click OK Button in VB6

    try this:
    VB Code:
    1. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
    2.     ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    3.    
    4. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
    5.     ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    6.    
    7. Private Const BM_CLICK = &HF5
    8.  
    9. Private Sub Command1_Click()
    10.     Dim lhWnd As Long
    11.    
    12.     lhWnd = FindWindowEx(0&, 0&, "#32770", vbNullString)
    13.     lhWnd = FindWindowEx(lhWnd, 0&, "Button", "OK")
    14.     SendMessage lhWnd, BM_CLICK, 0&, 0&
    15. End Sub

  3. #3

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Click OK Button in VB6

    Cheers I'll try that out tonight!

  4. #4

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Click OK Button in VB6

    Brilliant stuff there Bushmobile!
    One problem:
    Last edited by kregg; Aug 11th, 2007 at 04:50 PM.

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Click OK Button in VB6

    Quote Originally Posted by kregg
    Brilliant stuff there Bushmobile!
    One problem:
    No Worries

  6. #6
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    Re: Click OK Button in VB6

    Quote Originally Posted by kregg
    Brilliant stuff there Bushmobile!
    One problem:
    Don't worry, Kregg. Most of us have that problem.

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