winapi – 在Windows上模拟Haskell的击键
发布时间:2020-12-14 02:46:23 所属栏目:Windows 来源:网络整理
导读:我正在尝试编写一个模拟 Windows上击键的Haskell程序.我试图调用keybd_event和SendInput,但都没有编译.不过,我可以用解释器来运行程序.当我在winable.h中包含对SendInput的绑定时尝试构建程序时,我收到错误: cabal install...[1 of 2] Compiling WindowsKey
我正在尝试编写一个模拟
Windows上击键的Haskell程序.我试图调用keybd_event和SendInput,但都没有编译.不过,我可以用解释器来运行程序.当我在winable.h中包含对SendInput的绑定时尝试构建程序时,我收到错误:
cabal install ... [1 of 2] Compiling WindowsKeys ( distbuildWindowsKeysWindowsKeys-tmpWindowsKeys.hs,distbuildWindowsKeysWindowsKeys-tmpWindowsKeys.o ) [2 of 2] Compiling Main ( srcMain.hs,distbuildWindowsKeysWindowsKeys-tmpMain.o ) Linking distbuildWindowsKeysWindowsKeys.exe ... distbuildWindowsKeysWindowsKeys-tmpWindowsKeys.o:fake:(.text+0x35d): undefined reference to `SendInput' collect2: ld returned 1 exit status cabal: Error: some packages failed to install: WindowsKeys-0.1.0.0 failed during the building phase. The exception was: ExitFailure 1 详细错误发生在http://pastebin.com/trg21N0x,但它似乎不再包含任何线索.我尝试使用keybd_event时遇到类似的错误. #include "windows.h" #include "winuser.h" #include "winable.h" 这是C绑定: foreign import ccall unsafe "winable.h SendInput" c_SendInput :: UINT -> Ptr Input -> CInt -> IO UINT 我假设我无法在winuser.h上调用SendInput,因为#if: #if (_WIN32_WINNT >= 0x0403) WINUSERAPI UINT WINAPI SendInput(UINT,LPINPUT,int); 当我为_WIN32_WINNT添加绑定时,值为0x400. 我有Haskell平台的2012.4.0.0版.它附带了一个包含我所包含的标题的文件夹.我在计算机上找不到任何其他具有相同名称的标题.我使用的是Windows 7 Professional 6.1版. 谢谢! 这是WindowsKeys.cabal: -- Initial WindowsKeys.cabal generated by cabal init. For further -- documentation,see http://haskell.org/cabal/users-guide/ name: WindowsKeys version: 0.1.0.0 build-type: Simple cabal-version: >=1.8 extra-source-files: windows.h,winuser.h,winable.h executable WindowsKeys main-is: Main.hs other-modules: WindowsKeys build-depends: base ==4.5.*,Win32 ==2.2.* hs-source-dirs: src build-tools: hsc2hs extra-libraries: user32 include-dirs: src 当我注释掉键盘功能的绑定时,构建成功. 解决方法
我终于发现我使用了错误的调用约定. keybd_event和SendInput都需要使用stdcall而不是ccall来调用.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows – 将Microsoft软件作为独立开发者许可的最佳方式
- windows-7 – 如何创建客户端证书以通过SSL本地测试双向身份
- windows-server-2012 – 从Windows Server 2012 R2中删除Hy
- unit-testing – 以编程方式将.reg文件合并到win32注册表中
- 如何在Windows 8上启用公开功能?
- windows-phone-8 – 如何在Windows Phone 8应用程序中启动新
- 如何构建程序,以便它不需要DLL
- Windows上的PuTTY替代方案:更好的保存会话组织
- Windows安装Linux子系统--安装GUI界面
- windows-server-2008 – Windows 2008 RAID失败的Redudancy
推荐文章
站长推荐
热点阅读