识别特殊键 [英] Identify Special key keycode

查看:81
本文介绍了识别特殊键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 8笔记本电脑.我的旧笔记本电脑有一个组合键,即fn + f5,它将使计算机进入睡眠状态.我的新笔记本电脑的侧面有一个电源按钮,其功能类似于手机上的电源按钮,它将PC置于待机/睡眠状态.但是我不喜欢硬件按钮,因为它们会磨损. 我插入了具有专用键和电源按钮符号的Logitech键盘,当您按下它时,它会执行相同的操作. (我没有安装任何软件或驱动程序,只是插入了电源)我的目标是使用autohotkey分配键组合以发送相同的键码.内置了一些Windows函数(我不知道该怎么称呼它们.Shell命令?),这些函数本应使PC进入睡眠状态,但它们始终使计算机进入休眠或关闭状态,而不是我想要的,这这就是为什么我要诉诸于此.有人知道如何截取键码或其他东西吗?

I am using a windows 8 laptop. My old laptop had a key combo, fn+f5, which would make the computer go to sleep. My new laptop has a power button on the side that acts like the one on your phone, it puts the PC to standby/sleep. But i don't like hardware buttons because they wear out. I plugged in a logitech keyboard that has a dedicated key with the power button symbol and when you press it, it does the same thing. (i did not install any software or drivers btw, just plugged it in) My goal is to use autohotkey to assign a key combo to send the same keycode. There are baked-in some windows functions (I don't know what to call them. Shell commands?) that are supposed to put the PC to sleep but they always put it into hibernation or shut it down, not what i want, which is why i am resorting to this. Does anyone know how to intercept keycodes or something?

推荐答案

将其粘贴到文本文件中并另存为.AHK并运行.

Paste this into a text file and save as .AHK and run.

#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
NP:="Untitled - Notepad"

IfWinExist, % NP
WinActivate
else
IfWinNotExist, % NP
Run, Notepad.exe,, UseErrorLevel, nPID
nPID=%nPID%
if (ErrorLevel){
    MsgBox, there is a problem
}else{
    ToolTip, Notepad running as PID: %nPID%
    Sleep, 1000
    ToolTip
}
WinActivate, % NP
WinWaitActive, % NP
Send, {Raw}Hello %A_UserName%,`n`nRight click on the H icon on your traybar`ngoto -> "Open" ->          "View" - > "Key History and Script Info"`n`nThis area shows you your past keypresses. =]`n`n-islanq
return

AHK关于特殊键的文献-链接

关于InstallKeyboardHook的AHK文献-链接

这篇关于识别特殊键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆