资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net发送按键 vbnet button

vb.net 组合键Ctrl+Enter怎样发送

看了很多这方便的解决方案,很多都是一大段代码,版本也有差别,既然有可能别人用得起我也用不起。

成都创新互联公司是一家专业提供嘉鱼企业网站建设,专注与成都做网站、成都网站建设、成都外贸网站建设H5场景定制、小程序制作等业务。10年已为嘉鱼众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

我用一种最简单的方法,只要思路对所有人都能用得起。

其实非常简单,就是获取键值,Ctrl+Enter的健值是10,是不是思路一下就通了。以下是源码:

Private Sub 聊天输入框_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 聊天输入框.KeyPress

If Asc(e.KeyChar) = 发送快捷键值 Then

发送消息过程()

End If

End Sub

源内容出处:

vb.net通过按钮POST数据

Private Sub Command1_Click() ReferForm "WebBrowser1", 2, "message", Text1.Text End Sub Private Sub Command2_Click() ReferForm "WebBrowser1", 8, "submit" End Sub Private Sub Form_Load() WebBrowser1.Navigate (" ") End Sub '************************************************************************* '**函 数 名:ReferForm '**中文意译:表单提交 '**输 入:ByVal WebbrowserA(String) - webbrowser控件名 '** :ByVal FormType(Integer) - 集合 表单类型 '** Text = 0; password = 1; textarea = 2; Hidden = 3; CheckBox = 4; submit = 8; button = 9 '** :Optional FormName(String) - 表单名[可选] '** :Optional Value(String = "") - 表单值[可选] '**输 出:无 '**功能描述: '** : '**作 者:最恨VB '**日 期:2008-01-31 07:46:14 '************************************************************************* Sub ReferForm(ByVal Webbrowser$, ByVal FormType%, Optional FormName$, Optional Value$ = "") If FormType 0 Or FormType 9 Then Exit Sub End If Dim objDoc, objTag Set objDoc = Me.Controls(Webbrowser).Document For i = 0 To objDoc.All.length - 1 Select Case UCase$(objDoc.All(i).tagName) Case "INPUT" Set objTag = objDoc.All(i) Select Case FormType Case 0, 1 If objTag.Name = FormName Then objTag.Value = Value End If Case 3 Case 4 If objTag.Name = FormName Then objTag.Click End If Case 8 If objTag.Type = FormName Then objTag.Click End If Case 9 If objTag.Typ

C#/VB.NET中模拟按键问题...为什么我运行无效??

一、模拟键盘操作

以下示例程序当点击button1按钮,模拟键盘在文本框textBox1中作输入操作,详细说明请参看MSDN帮助中的SendKeys类。

//事件完整代码

private void button1_Click(object sender, System.EventArgs e)

{

this.textBox1.Focus(); //先必须让文本框得到焦点,因为焦点在button1上

SendKeys.Send("^a"); //Ctrl+A

SendKeys.Send("{DEL}"); //Delete

SendKeys.Send("+(ec)"); //Shift+"ec"

SendKeys.Send("{ENTER}"); //Enter

SendKeys.Send("+ec"); //Shift+'e'+'c'

SendKeys.Send("{ENTER}"); //Enter

SendKeys.Send("{h 10}"); //"hhhhhhhhhh"

SendKeys.Send("{ENTER}"); //Enter

SendKeys.Send("^%{DEL}"); //Alt+Ctrl+Del

}

二、模拟鼠标操作

以下示例程序当点击DBButton按钮,模拟鼠标双击窗体事件,并将鼠标向左上方移动10*10象素,其它操作类似。

//引入名字空间

using System.Runtime.InteropServices

//申明

[DllImport("user32")]

private static extern int mouse_event(int dwFlags,int dx,int dy, int cButtons, int dwExtraInfo);

const int MOUSEEVENTF_MOVE = 0x0001;

const int MOUSEEVENTF_LEFTDOWN = 0x0002;

const int MOUSEEVENTF_LEFTUP = 0x0004;

const int MOUSEEVENTF_RIGHTDOWN = 0x0008;

const int MOUSEEVENTF_RIGHTUP = 0x0010;

const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;

const int MOUSEEVENTF_MIDDLEUP = 0x0040;

const int MOUSEEVENTF_ABSOLUTE = 0x8000;

//事件完整代码

private void Form_DoubleClick(object sender, System.EventArgs e)

{

MessageBox.Show("你双击了屏幕");

}

private void DBButton_Click(object sender, System.EventArgs e)

{

mouse_event(MOUSEEVENTF_MOVE,-10,-10,0,0); //移动鼠标,否则事件发生在按钮上

Down,Up合为一次单击事件

mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);

mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);

mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

}

VB.net 怎么制作按键连发功能

用API函数,以下代码Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Const WS_EX_LAYERED = H80000

Private Const GWL_EXSTYLE = (-20)

Private Const LWA_ALPHA = H2

Private Const LWA_COLORKEY = H1Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMosT = -1

Private Const SWP_NOMOVE = H2

Private Const SWP_NosIZE = H1

Private Declare Function GetForegroundWindow Lib "user32" () As Long

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Const WM_KEYDOWN = H100

Const WM_KEYUP = H101

Const WM_CHAR = H102

Const VK_F1 = H70

Private Sub SendF1(hwnd) '调用这个过程即可对目标窗体发送F1键

Call PostMessage(hwnd, WM_KEYDOWN, VK_F1, 0)

Call PostMessage(hwnd, WM_KEYUP, VK_F1, 0)

End Sub这里是发送F1的实例,各个按键对应的虚拟键码,要到网上查


新闻名称:vb.net发送按键 vbnet button
文章路径:http://cdkjz.cn/article/dosiooj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220