小编Dom*_*nik的帖子

在Java中使用ImageSearchDll.dll(来自AutoIt)编辑:JNA

我想对我的Java程序中的屏幕事件做出反应,所以我想在实际屏幕中找到一个图像.我试着编写一个方法来从机器人类中获取一个截图,然后搜索像素 - 但它已经过了很长时间.

我知道在AutoIt中有一个外部DLL可以很好地完成这项工作,现在我试图让它在java中运行......但我被卡住了:/

.Ill在AutoIt中调用包括如下:

Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance)
   return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)
EndFunc
Run Code Online (Sandbox Code Playgroud)

和:

Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)

if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
$result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)

if $result[0]="0" then return 0

$array = StringSplit($result[0],"|")

$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
if $resultPosition=1 then
  $x=$x + Int(Number($array[4])/2)
  $y=$y + Int(Number($array[5])/2)
endif
return 1
EndFunc
Run Code Online (Sandbox Code Playgroud)

我得到了dll并尝试了像jna这样的东西,但我无法让它工作.我还尝试使用AutoItX来使用Java运行AutoIt函数,但它不能用于包含.你能帮助我吗?

编辑:好的我在JNA上做了另一次尝试,现在我得到了一个String - 但是String意味着错误.有什么问题?我有一个界面:

public interface ImageSearchDLL extends Library{
ImageSearchDLL INSTANCE = (ImageSearchDLL) Native.loadLibrary("ImageSearchDLL", ImageSearchDLL.class);
String ImageSearch(int x1, int y1, int …
Run Code Online (Sandbox Code Playgroud)

java import dll autoit jna

9
推荐指数
1
解决办法
1646
查看次数

使用来自user32.dll的SendMessage和java中的jna - 错误

我尝试使用:

LRESULT WINAPI SendMessage(_In_  HWND hWnd, _In_  UINT Msg,
                           _In_  WPARAM wParam, _In_  LPARAM lParam);
Run Code Online (Sandbox Code Playgroud)

在Java中使用jna并且我不断收到错误:

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Error looking up function 'SendMessage'
Run Code Online (Sandbox Code Playgroud)

这是我的界面:

public interface User32 extends StdCallLibrary {
Pointer GetForegroundWindow();
int SendMessage(Pointer hWnd, int msg, int num1, int num2);
Run Code Online (Sandbox Code Playgroud)

我称之为:

Pointer hW = user32.GetForegroundWindow();
user32.SendMessage(hW, 0x0201, 0, 0);
user32.SendMessage(hW, 0x0202, 0, 0);
Run Code Online (Sandbox Code Playgroud)

hWnd是对的.我的错在哪里?

java winapi user32 jna sendmessage

1
推荐指数
1
解决办法
3608
查看次数

标签 统计

java ×2

jna ×2

autoit ×1

dll ×1

import ×1

sendmessage ×1

user32 ×1

winapi ×1