Windows上のキーストロークをシミュレートするHaskellプログラムを作成しようとしています。私はkeybd_eventとSendInputを呼び出そうとしましたが、どちらもコンパイルされませんでした。私はインタプリタでプログラムを走らせることができます。Windows上のHaskellでキーストロークをシミュレートする
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であるが、それはすべてのより多くの手がかりが含まれていないようです。私はそれがwinable.hにSendInputへの結合を含んでいたときにプログラムを構築しようとした際、私はエラーを取得します。 keybd_event
を使用しようとすると、同様のエラーが発生します。 は、私が書いたHSCファイルは、これらのヘッダが含まれています。ここでは
#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
を私は理由の#ifのWINUSER.HにSendInput
を呼び出すことができなかったと仮定:
#if (_WIN32_WINNT >= 0x0403)
WINUSERAPI UINT WINAPI SendInput(UINT,LPINPUT,int);
_WIN32_WINNT
のバインドを追加すると、値は0x400になります。
私はHaskellプラットフォームのバージョン2012.4.0.0を持っています。それは私が含まれているものを含むヘッダーのフォルダが付属しています。自分のコンピュータに同じ名前の他のヘッダーが見つかりませんでした。私はWindows 7 Professional、バージョン6.1を使用しています。
ありがとうございました!私はキーボード機能へのバインディングをコメントアウトするとき
-- 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
ビルドが成功します。ここでは
はWindowsKeys.cabalです。
ライブラリにバインドしようとしていますか?もしそうなら、どのような図書館で、どのようにGHCにその場所を教えていますか? '.cabal'には何が入っていますか? –
Windows上のuser32ライブラリにバインドしようとしています。 .cabalファイルで質問を更新しました。 – user2917747