error check

This commit is contained in:
Akito123321 2024-05-24 08:16:59 +02:00
parent 511de720d3
commit a28718408b
5 changed files with 10 additions and 7 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target/

View File

@ -12,6 +12,7 @@ import com.sun.jna.platform.WindowUtils;
import com.sun.jna.platform.win32.WinDef.LPARAM; import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.platform.win32.WinUser; import com.sun.jna.platform.win32.WinUser;
import static com.sun.jna.Native.getLastError;;
public class Input { public class Input {
@ -44,7 +45,8 @@ public class Input {
public static void press(char c, int timeInMs, String windowName) { public static void press(char c, int timeInMs, String windowName) {
DesktopWindow window = WindowUtils.getAllWindows(true).stream() DesktopWindow window = WindowUtils.getAllWindows(true).stream()
.filter(w -> w.getTitle().toLowerCase().contains(windowName.toLowerCase())).findFirst().get(); .filter(w -> w.getTitle().toLowerCase().contains(windowName.toLowerCase())).findFirst().get();
System.out.println(SendMessageA(window.getHWND(), WinUser.WM_KEYDOWN, new WPARAM(c), new LPARAM(0))); SendMessageA(window.getHWND(), WinUser.WM_KEYDOWN, new WPARAM(c), new LPARAM(0));
System.out.println(getLastError());
try { try {
Thread.sleep(timeInMs); Thread.sleep(timeInMs);
} catch (InterruptedException e) { } catch (InterruptedException e) {

View File

@ -1,4 +1,4 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Build-Jdk-Spec: 21 Build-Jdk-Spec: 21
Created-By: Maven Integration for Eclipse Created-By: Maven Integration for Eclipse

View File

@ -1,7 +1,7 @@
#Generated by Maven Integration for Eclipse #Generated by Maven Integration for Eclipse
#Thu May 23 23:10:46 CEST 2024 #Fri May 24 08:04:04 CEST 2024
artifactId=macro artifactId=macro
groupId=me.akito123321.macro groupId=me.akito123321.macro
m2e.projectLocation=C\:\\Users\\ronny\\eclipse-workspace\\macro m2e.projectLocation=/home/ronny/Desktop/Private Projects/PROBot
m2e.projectName=macro m2e.projectName=macro
version=0.0.1-SNAPSHOT version=0.0.1-SNAPSHOT

Binary file not shown.