- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个 Haskell 程序来模拟 Windows 上的击键。我尝试调用 keybd_event 和 SendInput,但都没有编译。不过,我可以用解释器运行该程序。当我尝试构建包含 winable.h 中 SendInput 的绑定(bind)的程序时,出现错误:
cabal install
...
[1 of 2] Compiling WindowsKeys ( dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.hs, dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.o )
[2 of 2] Compiling Main ( src\Main.hs, dist\build\WindowsKeys\WindowsKeys-tmp\Main.o )
Linking dist\build\WindowsKeys\WindowsKeys.exe ...
dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.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
时,我收到类似的错误。我编写的 hsc 文件包含以下 header :
#include "windows.h"
#include "winuser.h"
#include "winable.h"
这是 C 绑定(bind):
foreign import ccall unsafe "winable.h SendInput"
c_SendInput :: UINT
-> Ptr Input
-> CInt
-> IO UINT
我认为由于 #if 的原因,我无法在 winuser.h 上调用 SendInput
:
#if (_WIN32_WINNT >= 0x0403)
WINUSERAPI UINT WINAPI SendInput(UINT,LPINPUT,int);
当我为 _WIN32_WINNT
添加绑定(bind)时,该值为 0x400。
我的 Haskell 平台版本为 2012.4.0.0。它带有一个 header 文件夹,其中包含我包含的 header 。我在计算机上找不到任何其他同名的 header 。我使用的是 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
当我注释掉键盘功能的绑定(bind)时,构建成功。
最佳答案
我终于发现我使用了错误的调用约定。 keybd_event
和 SendInput
都需要使用 stdcall
调用,而不是 ccall
。
关于winapi - 在 Windows 上使用 Haskell 模拟击键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19578565/
menu Home Events Technical Schedule
我试图阻止触发默认 anchor 链接和 onclick 事件。 这是 HTML 代码: Google 我正在尝试使用以下 jQuery 代码阻止任何重定向的发生: $("#mylink").cli
我想在单击父 div 上的任意位置时切换我的 div,除非单击 anchor 元素。因此,例如,如果我单击示例中的第一个文本,我希望它切换,但在我的示例中的第二个文本上,我不希望它切换。 JSFidd
我在通过 jQuery 伪造 anchor 点击时遇到问题:为什么我的thickbox在我第一次点击输入按钮时出现,但第二次或第三次却没有出现? 这是我的代码: Link 当我直接点击链接时,它总是
我已经从 Mootools 切换到 jQuery,因为我认为它有更好的支持。我有这样的 HTML: Opcje Opcje Opcje Opcje Opcje Opcje Opcje JS
我是一名优秀的程序员,十分优秀!