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
나는 때문에 # 만약의 winuser.h에
SendInput
를 호출 할 수 있다고 가정
:
#if (_WIN32_WINNT >= 0x0403)
WINUSERAPI UINT WINAPI SendInput(UINT,LPINPUT,int);
_WIN32_WINNT
에 대한 바인딩을 추가하면 값은 0x400입니다.
하스켈 플랫폼 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