吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 717|回复: 2
收起左侧

[求助] 以下随机按键咋没反应?

[复制链接]
冥界3大法王 发表于 2021-12-26 18:38
本帖最后由 冥界3大法王 于 2021-12-27 09:34 编辑


[Delphi] 纯文本查看 复制代码
unit Unit3;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm3 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure hotykey(var msg: TMessage); message WM_HOTKEY;
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;
  id1: Integer;
  A1: Integer;

implementation

{$R *.dfm}

procedure TForm3.FormCreate(Sender: TObject);
begin
  Randomize;
  A1 := Random(10);
  ShowMessage(IntToStr(A1));

  id1 := GlobalAddAtom('hotkey1');
  RegisterHotKey(handle, id1, MOD_CONTROL + MOD_SHIFT, Ord(A1));
end;

procedure TForm3.FormDestroy(Sender: TObject);
begin
  UnRegisterHotKey(handle, id1);
end;

procedure TForm3.hotykey(var msg: TMessage);
begin
  if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(Ord(A1)) < 0) then       //Ctrl+Shift+随机按键码
    ShowMessage('Ctrl+Shift+未知按键');
end;
end.

@bester
@tywolf
@topzhp
@sdzzb
@qeeqeeeq
@pzx521521

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 冥界3大法王 发表于 2021-12-30 18:46
@JuncoJet 还一问题,请教先生。
JuncoJet 发表于 2021-12-31 09:27
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-17 21:41

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表