SoFunction
Updated on 2025-04-12

Easy Language API hotkey monitoring example

When writing software or game assistance in Easy Language, API hotkey monitoring is often used. We will share the example code below. You can copy it directly to test it.

AIP hotkey monitoring

.Version 2
.Support library JY

.Subprogram Monitoring hotkeys2, Integer type, public, Return to the hotkey successfullyID,Failed to return0。
.parameter 响应Subprogram, Subprogram指针, , 热键被按下时要触发的Subprogram,该回调函数可有一个parameter用来接收热键ID。
.parameter Key Code, Integer type, , 可以使用易语言中的Key Code常量
.parameter Function key code, Integer type, Available, Key code values ​​are constant,Multiple additions can be made into combination keys,Leave blank or0It means not to use it。
.Local variables Count times, Integer type
.Local variables Data, HotKeyData0

.If true (Key Code = 0 or 响应Subprogram = )
return (0)
.If true结束
 = 响应Subprogram
.Count times循环首 (Take the number of array members (KeyData), Count times)
.If true (KeyData [Count times].vKey [1] = Key Code and KeyData [Count times].vKey [2] = Function key code)
return (KeyData [Count times].KeyID)
.If true结束

.Count times循环尾 ()
.Judgment cycle first (Working)

winapi (, “Sleep”, 1, 1)
.Judge the end of the loop ()
Working = real
 [1] = Key Code
 [2] = Function key code
Count times = Take the number of array members (KeyData)
.if (Count times = 0)
 = 100
.otherwise
 = KeyData [Count times].KeyID + 4
.if结束
Count times = Count times + 1
Join a member (KeyData, Data)
.If true (ThreadId = 0)

winapi (, “Close Handle”, 1, winapi (, “ Create Thread”, 1, 0, 0, &HotKeyProc, 0, 0, Retrieve address (ThreadId)))

.If true结束
.Judgment cycle first (KeyData [Count times].Reg = Fake)
winapi (, “PostThread MessageA ”, 1, ThreadId, 57521, 0, 0)
winapi (, “Sleep”, 1, 1)
.Judge the end of the loop ()
Working = Fake
.If true (KeyData [Count times].Retn = Fake)
Delete members (KeyData, Count times, )
return (0)
.If true结束
return (KeyData [Count times].KeyID)

You can test the above code in Easy Language.