Skip to content

Commit

Permalink
window finding support for xivalexander
Browse files Browse the repository at this point in the history
maybe
  • Loading branch information
Jaksuhn committed Nov 11, 2023
1 parent 2e5a656 commit 977fc76
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions SomethingNeedDoing/Misc/Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;

using Dalamud.Game.ClientState.Keys;
using ECommons.Interop;

namespace SomethingNeedDoing.Misc;

Expand Down Expand Up @@ -33,22 +34,24 @@ public static void Send(VirtualKey key, IEnumerable<VirtualKey>? mods)

if (key != 0)
{
var hWnd = handle ??= Process.GetCurrentProcess().MainWindowHandle;

if (mods != null)
{
foreach (var mod in mods)
_ = SendMessage(hWnd, WM_KEYDOWN, (IntPtr)mod, IntPtr.Zero);
}

_ = SendMessage(hWnd, WM_KEYDOWN, (IntPtr)key, IntPtr.Zero);
Thread.Sleep(100);
_ = SendMessage(hWnd, WM_KEYUP, (IntPtr)key, IntPtr.Zero);

if (mods != null)
//var hWnd = handle ??= Process.GetCurrentProcess().MainWindowHandle;
if (WindowFunctions.TryFindGameWindow(out var hWnd))
{
foreach (var mod in mods)
_ = SendMessage(hWnd, WM_KEYUP, (IntPtr)mod, IntPtr.Zero);
if (mods != null)
{
foreach (var mod in mods)
_ = SendMessage(hWnd, WM_KEYDOWN, (IntPtr)mod, IntPtr.Zero);
}

_ = SendMessage(hWnd, WM_KEYDOWN, (IntPtr)key, IntPtr.Zero);
Thread.Sleep(100);
_ = SendMessage(hWnd, WM_KEYUP, (IntPtr)key, IntPtr.Zero);

if (mods != null)
{
foreach (var mod in mods)
_ = SendMessage(hWnd, WM_KEYUP, (IntPtr)mod, IntPtr.Zero);
}
}
}
}
Expand Down

0 comments on commit 977fc76

Please sign in to comment.