delphi系统键盘输入捕获或手势捕获

Delphi事件捕获操作 有的控件不具备事件的属性功能,比如WEBBROSER控件不具备鼠标的操作功能,那就需要手动的截获这些消息,可以按照以下步骤进行: 1、在窗体上放置一个TApplicationEvents控件,编写OnMessage事件; procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); begin if Msg.message = WM_CLOSE then //判断是否关闭消息 begin 阅读详情

delphi系统键盘输入捕获或手势捕获

 

一、直接用ASCii码值捕获键盘输入

窗体FormKeyDown(  //:键按下
  Sender: TObject; 
  var Key: Word;     //:用于捕获   

      // UInt16  = Word;  //:Word无符号的SmallInt : (0..65535) (0.. 2^{31}-1) SmallInt  : (-65536..65535) (-2^{31}.. 2^{31}-1) 

      // UInt16  = Word;  :用于扩展ASCii编码:(0..255) :  (0.. 2^{8}-1):即:UInt8:Byte字节 :应用于比如某些设备上个性化的按键

                                                // ASC编码: (0..127) :(0.. 2^{7}-1)
  var KeyChar: Char; 
  Shift: TShiftState //:用于捕获
  );   或 FormKeyUp  //:键按下后松开

某个TFmxObject输入组件KeyDown(    //:键按下
  Sender: TObject; 
  var Key: Word;
  var KeyChar: Char; 
  Shift: TShiftState
  );    或 KeyUp  //:键按下后松开

ASC编码码值对照表详见:

https://mp.youkuaiyun.com/console/editor/html/104353336

方法: #加ASCii编码:  比如:#46 :直接用ASCii码值捕获键盘的输入Del键

案例:

procedure TYourForm.FormKeyDown(
  Sender: TObject; 
  var Key: Word;     //:用于捕获  
  var KeyChar: Char; 
  Shift: TShiftState //:用于捕获
  );
begin
  KeyChar:=Char(Key); 
  //:KeyChar是用于返回捕获后的键对应的字符用的
    //:KeyChar并不能做捕获用

  //:捕获要用 Key 和 Shift(系统数组常量,代表用的是左边还是右边的ctrl或shift的组合)
    //:BackSpace等控制键是返回不了字符的:系统内部的乱码:控制符
  if ( Char(Key)=#8) or ( Char(Key) =#46 ) then  //:#46 :直接用ASCii码值捕获键盘的输入Del键
  //:或:if (Key=vkBack) or (Key=vkDelete) then //uses System.UITypes;
  begin
    ShowMessage('按下了Backspace键或del键:'+KeyChar);
    //memo1.Lines.Add(IntToStr(Key));
  end;

二、用表达友好常量的捕获键盘输入

方法: 用下面{}中的:ASCii编码($是其对应的16进制编码)对应的友好常量调用  

    比如:vkDelete :代表#8的ASCii码值捕获键盘的输入Del键。

案例:

    if (Key=vkBack) or (Key=vkDelete) then ; //uses System.UITypes;

uses System.UITypes; 

http://docwiki.embarcadero.com/Libraries/Rio/en/System.UITypes

const
  { Virtual Keys, Standard Set }
  vkLButton          = $01;  {   1 }
  vkRButton          = $02;  {   2 }
  vkCancel           = $03;  {   3 }
  vkMButton          = $04;  {   4 }
  vkXButton1         = $05;  {   5 }
  vkXButton2         = $06;  {   6 }
  vkBack             = $08;  {   8 }
  vkTab              = $09;  {   9 }
  vkLineFeed         = $0A;  {  10 }
  vkClear            = $0C;  {  12 }
  vkReturn           = $0D;  {  13 }
  vkShift            = $10;  {  16 }
  vkControl          = $11;  {  17 }
  vkMenu             = $12;  {  18 }
  vkPause            = $13;  {  19 }
  vkCapital          = $14;  {  20 }
  vkKana             = $15;  {  21 }
  vkHangul           = $15;  {  21 }
  vkJunja            = $17;  {  23 }
  vkFinal            = $18;  {  24 }
  vkHanja            = $19;  {  25 }
  vkKanji            = $19;  {  25 }
  vkConvert          = $1C;  {  28 }
  vkNonConvert       = $1D;  {  29 }
  vkAccept           = $1E;  {  30 }
  vkModeChange       = $1F;  {  31 }
  vkEscape           = $1B;  {  27 }
  vkSpace            = $20;  {  32 }
  vkPrior            = $21;  {  33 }
  vkNext             = $22;  {  34 }
  vkEnd              = $23;  {  35 }
  vkHome             = $24;  {  36 }
  vkLeft             = $25;  {  37 }
  vkUp               = $26;  { &

深入解析Delphi中的异步键盘事件处理 本文介绍了在Delphi中使用GetAsyncKeyState函数检测键盘状态的方法。通过分析代码片段,解释了GetAsyncKeyState(117)检测F6键的原理,以及返回值-32767表示按键状态变化的意义。文章还提供了实际应用示例,展示如何利用TTimer定时检测F6键来触发保存操作,并指出代码中未使用的冗余变量。该方法适用于需要独立于窗口焦点检测键盘状态的场景。 阅读详情

相关推荐

Delphi 7触摸屏软键盘控件实现与应用

在本章节中,我们将探讨Delphi 7环境下的软键盘控件开发。Delphi 7作为一款经典的集成开发环境(IDE),因其高效的开发模式和丰富的组件库,在20世纪初广泛应用于桌面和嵌入式系统的软件开发。软键盘控件的引入,为没有物理键盘的设备提供了灵活的文本输入解决方案。我们将首先审视Delphi 7中控件的使用基础,例如如何在设计时将软键盘控件添加到窗体中,并设置其属性以满足特定需求。之后,我们将深入分析软键盘的内部逻辑,包括事件驱动模型和消息处理机制,这对于理解Delphi中的组件编程至关重要。

weixin_35307279的博客 788

delphi 中鼠标移动事件

鼠标移动事件的应用 procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin self.X := X; self.Y := Y; Dbgrid1.Repaint; end;

智能网联汽车电子电气架构(下)

从资产的表现形式, 可以分为数据、 软件、 硬件、 服务等, 而从需要保护的业务过程和活动、 所关注信息的角度, 资产类型可包括基于 ECU 的控制功能、 与特定车辆相关的信息、 车辆状态信息、 用户信息、 配置信息、 特定的软件、 内容等。面向新一代 EEA 的安全需求, 基于芯片提供的 OTP, 或SHE\HSM 的安全存储能力, 实现系统关键数据(身份、 密钥等关键信息) 的安全存储, 保证系统的关键数据不被盗取、 破坏、 改写。结合攻击者的动机与识别出的系统用例, 分析对汽车电子系统可能的攻击。

m0_58838529的博客 1474

电赛备赛笔记:用STM32驱动AD9959信号发生器模块,从接线到出波保姆级教程

本文详细介绍了如何使用STM32驱动AD9959信号发生器模块,从硬件接线到软件调试的全流程。AD9959作为高性能DDS芯片,适用于电子设计竞赛中的信号生成需求。文章包含硬件连接指南、寄存器配置解析、多通道控制技巧以及常见问题解决方案,帮助参赛者快速掌握AD9959的应用。

weixin_31858171的博客 368

YOLOv8中Bottleneck模块详解

Bottleneck 模块在YOLOv8中的作用是进行特征提取和增强,是网络中的核心构建模块之一。它的主要功能是通过卷积操作来处理输入特征图,并在适当情况下应用残差连接,使得信息能够有效地通过网络层进行传播

zzzyyy8的博客 8068

17、自适应和学习索引:在线物理设计调整的新维度

本文探讨了现代数据库管理系统中自适应索引和数据库裂解的新方法,通过结合学习模型与多臂老虎机(MAB)框架,实现在线物理设计调整。文章详细介绍了自适应索引的工作原理、数据库裂解技术以及如何利用机器学习进行索引选择和优化,并讨论了MAB框架在动态调整索引结构中的应用及其实际案例。

go5gopher的博客 84

人工智能 (Artificial Intelligence, AI) 原理与代码实例讲解

人工智能 (AI) 机器学习 (Machine Learning) 深度学习 (Deep Learning) 算法 模型 代码实例 应用场景 1. 背景介绍 人工智能 (Artificial Intelligence, AI) 作为一项前沿科技,近年来发展迅速,已渗透到生活的方方面面

AI架构师小马 1233

Odoo 入门 | 什么是 Odoo?

Odoo是一套全球开源的ERP/CRM系统,最初的名字为TinyERP,08年5月之后称之为OpenERP,之后又改为Odoo。

洛阳泰山的博客 6212

openclaw update时出现Skipped:this OpenClaw install isn‘t a git checkout,and the package manager解决方案

本文主要介绍了openclaw update时出现openclaw update时出现Skipped:this OpenClaw install isn’t a git checkout,and the package manager解决方案,希望能对使用openclaw的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 12万+

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

上一篇: delphi XE Restful:RestClien案例RESTDebugger.dproj和RESTDemos.dproj的调用参数及格式设置
下一篇: delphi应用代码执行的过程和步骤
专讲冷知识
博客等级 码龄15年 568粉丝 292原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

专讲冷知识

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值