为什么会执行两次???(与HOOK有关)

jacky_shen 2002-12-22 03:33:30
在HOOK中截获一个键,然后去打开一个记事本,为什么会打开两次。
if (_WPARAM = VK_CONTROL) then ShellExecute(0, 'Open', 'notepad.exe', nil, nil, SW_SHOWDEFAULT);
...全文
226 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jacky_shen 2003-05-08
  • 打赏
  • 举报
回复
问题我自己已经搞定。
ahjoe 2003-04-06
  • 打赏
  • 举报
回复
确定是KeyDown和KeyUp
笑天居士 2003-04-06
  • 打赏
  • 举报
回复
通过判断lParam参数,可以实现:

Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. This parameter can be a combination of the following values:

Value Description
0-15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key.
16-23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0.
25-28 Reserved.
29 Specifies the context code. The value is 1 if the ALT key is down; otherwise, it is 0.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up.
31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released.


For more information about the lParam parameter, see Keystroke Message Flags.

第30、31位可以判断到是按下还是释放!
大大怪老张 2002-12-25
  • 打赏
  • 举报
回复
bsign : boolean ;

if (_WPARAM = VK_CONTROL) then
if bsign = true then
begin
ShellExecute(0, 'Open', 'notepad.exe', nil, nil, SW_SHOWDEFAULT);
bsign := false ;
end
else
bsign := true ;

忘了写end了。
大大怪老张 2002-12-25
  • 打赏
  • 举报
回复
加个标志是否可以。

bsign : boolean ;

if (_WPARAM = VK_CONTROL) then
if bsign = true then
begin
ShellExecute(0, 'Open', 'notepad.exe', nil, nil, SW_SHOWDEFAULT);
bsign := false ;
else
bsign := true ;

第一次检测到按键,标志:= true ,再次检测到按键如果标志=true,则执行操作。
ICMGDCHN 2002-12-25
  • 打赏
  • 举报
回复
关注ing,我也出现过这种问题还没解决
jacky_shen 2002-12-24
  • 打赏
  • 举报
回复
那么如何分开呢?
ahjoe 2002-12-23
  • 打赏
  • 举报
回复
同意,是KeyDown和KeyUp
票票飞扬 2002-12-23
  • 打赏
  • 举报
回复
是因为 KeyDown和KeyUp事件的原因。
CloneCenter 2002-12-23
  • 打赏
  • 举报
回复
按一个键会产生两次键盘中断。
智商无下限 2002-12-22
  • 打赏
  • 举报
回复
把KEYDOWN和KEYPRESS分开处理!

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧