diff --git a/.gitignore b/.gitignore index de5711f..2973a59 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,30 @@ Network Trash Folder Temporary Items .apdisk *.pdb +System.Buffers.xml +System.Buffers.dll +SharpDX.xml +SharpDX.dll +SharpDX.Desktop.dll +PoeHUD.exe.config +PoeFilterParser.dll +Newtonsoft.Json.xml +ImGui.NET.xml +ImGui.NET.dll +Gma.System.MouseKeyHook.dll +System.Runtime.CompilerServices.Unsafe.dll +System.Numerics.Vectors.xml +System.Numerics.Vectors.dll +SharpDX.Direct3D9.xml +SharpDX.Direct3D9.dll +Newtonsoft.Json.dll +Trinet.Core.IO.Ntfs.xml +Trinet.Core.IO.Ntfs.dll +System.Runtime.CompilerServices.Unsafe.xml +SharpDX.Mathematics.xml +SharpDX.Mathematics.dll +PoeHUD.exe +Antlr4.Runtime.xml +Antlr4.Runtime.dll +SharpDX.Desktop.xml +netstandard.dll diff --git a/AutoGolem.dll b/AutoGolem.dll index 7228cd1..143d60a 100644 Binary files a/AutoGolem.dll and b/AutoGolem.dll differ diff --git a/src/AutoGolem.cs b/src/AutoGolem.cs index ba936e2..07a4ef1 100644 --- a/src/AutoGolem.cs +++ b/src/AutoGolem.cs @@ -156,7 +156,7 @@ private void GolemMain() if (!GameController.Game.IngameState.Data.LocalPlayer.IsValid) return; - var playerLife = GameController.Game.IngameState.Data.LocalPlayer.GetComponent(); + var playerLife = GameController.Game?.IngameState?.Data?.LocalPlayer?.GetComponent(); if (playerLife == null || isTown) return; diff --git a/src/AutoGolem.csproj b/src/AutoGolem.csproj index ee74b1a..b454add 100644 --- a/src/AutoGolem.csproj +++ b/src/AutoGolem.csproj @@ -16,8 +16,8 @@ true full - true ..\ + false DEBUG;TRACE prompt 0 @@ -34,9 +34,11 @@ x64 - - ..\..\..\..\..\packages\SharpDX.Mathematics.4.0.1\lib\net40\SharpDX.Mathematics.dll - False + + ..\..\..\..\..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\..\..\PoEHUD\src\packages\SharpDX.Mathematics.4.0.1\lib\net45\SharpDX.Mathematics.dll @@ -51,6 +53,7 @@ + @@ -58,10 +61,9 @@ - + {e86368b2-ae1e-4489-a749-e29a0ab48f83} PoeHUD - False diff --git a/src/Keyboard.cs b/src/Keyboard.cs new file mode 100644 index 0000000..061dcf5 --- /dev/null +++ b/src/Keyboard.cs @@ -0,0 +1,56 @@ +using System; +using System.Runtime.InteropServices; +using System.Threading; +using System.Windows.Forms; + +namespace Stashie.Utils +{ + public static class Keyboard + { + [DllImport("user32.dll")] + private static extern uint keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); + + private const int KEYEVENTF_EXTENDEDKEY = 0x0001; + private const int KEYEVENTF_KEYUP = 0x0002; + private const int KEY_TOGGLED = 0x0001; + private const int KEY_PRESSED = 0x8000; + private const int ACTION_DELAY = 1; + + + public static void KeyDown(Keys key) + { + keybd_event((byte) key, 0, KEYEVENTF_EXTENDEDKEY | 0, 0); + } + + public static void KeyUp(Keys key) + { + keybd_event((byte) key, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); //0x7F + } + + public static void KeyPress(Keys key) + { + KeyDown(key); + Thread.Sleep(ACTION_DELAY); + KeyUp(key); + } + + [DllImport("USER32.dll")] + private static extern short GetKeyState(int nVirtKey); + + public static bool IsKeyDown(int nVirtKey) + { + return GetKeyState(nVirtKey) < 0; + } + + public static bool IsKeyPressed(Keys key) + { + return Convert.ToBoolean(GetKeyState((int) key) & KEY_PRESSED); + } + + + public static bool IsKeyToggled(Keys key) + { + return Convert.ToBoolean(GetKeyState((int) key) & KEY_TOGGLED); + } + } +} \ No newline at end of file diff --git a/src/KeyboardHelper.cs b/src/KeyboardHelper.cs index dca8c22..ad81c22 100644 --- a/src/KeyboardHelper.cs +++ b/src/KeyboardHelper.cs @@ -3,6 +3,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; +using Stashie.Utils; namespace AutoGolem { @@ -34,18 +35,9 @@ public void SetLatency(float latency) private static extern short GetKeyState(int nVirtKey); public void KeyDown(Keys key) { - SendMessage(_gameHandle.Window.Process.MainWindowHandle, 0x100, (int)key, 0); - } - - public static bool IsKeyDown(int nVirtKey) - { - return GetKeyState(nVirtKey) < 0; - } - - public void KeyUp(Keys key) - { - SendMessage(_gameHandle.Window.Process.MainWindowHandle, 0x101, (int)key, 0); + Keyboard.KeyPress(key); } + public bool KeyPressRelease(Keys key) { KeyDown(key); diff --git a/src/packages.config b/src/packages.config index 1298951..a091a63 100644 --- a/src/packages.config +++ b/src/packages.config @@ -1,6 +1,6 @@  - +