gpt4 book ai didi

linux - PureBasic - 我如何模拟按下 F1 或 F2 键盘按钮?

转载 作者:太空宇宙 更新时间:2023-11-04 11:15:15 25 4
gpt4 key购买 nike

我正在尝试从 Linux 为 Windows 7/8 和 Mac 制作一个小的可执行文件。与 PureBasic language .我如何使用 PureBasic 按 F1 或 F2 键盘按钮?我尝试了以下操作,但出现链接器错误。

enter image description here

If OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 200, "Shortcut test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

AddKeyboardShortcut(0, #PB_Shortcut_Apps,101); (=) - somewhere near the Space key
AddKeyboardShortcut(0, #PB_Shortcut_Clear,102)
AddKeyboardShortcut(0, #PB_Shortcut_Command,103)
AddKeyboardShortcut(0, #PB_Shortcut_Execute,104)
AddKeyboardShortcut(0, #PB_Shortcut_Help,105)
AddKeyboardShortcut(0, #PB_Shortcut_Menu,106)
;AddKeyboardShortcut(0, #PB_Shortcut_Next,107)
AddKeyboardShortcut(0, #PB_Shortcut_Pause,108); Pause - should be beside F12 or so
AddKeyboardShortcut(0, #PB_Shortcut_Print,109)
;AddKeyboardShortcut(0, #PB_Shortcut_Prior,110)
AddKeyboardShortcut(0, #PB_Shortcut_Scroll,111); ScrollLock
AddKeyboardShortcut(0, #PB_Shortcut_Select,112)
AddKeyboardShortcut(0, #PB_Shortcut_Separator,113)
AddKeyboardShortcut(0, #PB_Shortcut_Snapshot,114)

Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu
z=EventMenu()
If z>99 And z<115
Debug "Found key for the event #"+Str(z)
EndIf
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver

EndIf

最佳答案

在 Windows 下,您可以发布以下消息:

    PostMessage(hWnd, WM_KEYDOWN, VK_F1, 0);
PostMessage(hWnd, WM_KEYUP, VK_F1, 0);

所以你应该用你的语言找到一种将 PostMessage 发送到你的窗口的方法。还有其他 Win API 函数,例如:keybd_event、SendInput 在这里查看更多信息:

http://www.codeproject.com/Articles/2334/Toggling-the-Num-Lock-Caps-Lock-an-Scroll-Lock-ke

我对 PureBasic 一无所知,但在快速谷歌搜索后,我找到了正在做类似事情的论坛:

http://www.purebasic.fr/english/viewtopic.php?f=13&t=47321

关于linux - PureBasic - 我如何模拟按下 F1 或 F2 键盘按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21362310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com