Home » » Pressing the button with code

Pressing the button with code

Here's how to push Button / Button using code, so without doing click using the mouse pointer.

Write the following code in the event '(Declarations)' of Form


[VB 6.0]
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
[VB.Net]
Private Declare Function SendMessage Lib"user32.dll" Alias "SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Object) As Integer

Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Now for practice use code like the following:
[VB 6.0]
SendMessage Command1.hwnd, &HF3, 1, 0
Sleep 150
SendMessage Command1.hwnd, &HF3, 0, 0

Command1.Value = True 
[VB.Net]
SendMessage(Button1.Handle, WM_LBUTTONDOWN, 0, 0)
Application.DoEvents()
Threading.Thread.Sleep(150)
SendMessage(Button1.Handle, WM_LBUTTONUP, 0, 0)

Button1.PerformClick()
Jika Anda menyukai Artikel di blog ini, Silahkan klik disini untuk berlangganan gratis via email, dengan begitu Anda akan mendapat kiriman artikel setiap ada artikel yang terbit di Creating Website

0 comments:

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Sanjaya Catur Blogging - All Rights Reserved
Template Modify by Creating Website
Proudly powered by Blogger