Skip to content

Commit

Permalink
version 1.3
Browse files Browse the repository at this point in the history
See release for details
  • Loading branch information
IBM5100o committed Oct 22, 2023
1 parent cacd611 commit c7b4f88
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 67 deletions.
42 changes: 16 additions & 26 deletions HDT-BGhelper/BGhelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace HDT_BGhelper
{
internal class BGhelper
{
internal class BGhelper
{
private bool hookExist;
private IKeyboardMouseEvents m_GlobalHook;
private const int WM_LBUTTONDOWN = 0x201;
Expand All @@ -21,34 +21,35 @@ public BGhelper()
}

[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll", EntryPoint = "WindowFromPoint", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr WindowFromPoint(Point point);
private static extern void SetCursorPos(int x, int y);

[DllImport("user32.dll")]
static extern void SetCursorPos(int x, int y);
private static extern IntPtr WindowFromPoint(Point point);

[DllImport("user32.dll")]
static extern bool GetCursorPos(out Point point);
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

private static IntPtr CreateLParam(int LoWord, int HiWord)
{
return (IntPtr)((HiWord << 16) | (LoWord & 0xffff));
}

internal void GameStart()
{
internal void Activate()
{
if (!hookExist)
{
m_GlobalHook.MouseDownExt += GlobalHookMouseDownExt;
hookExist = true;
}
}

internal void GameEnd()
internal void Deactivate()
{
Disable();
if (hookExist)
{
m_GlobalHook.MouseDownExt -= GlobalHookMouseDownExt;
hookExist = false;
}
}

private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
Expand All @@ -64,11 +65,10 @@ private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
var handle = WindowFromPoint(new Point(x, y));
var lparam = CreateLParam(dx, dy);

GetCursorPos(out Point oripos);
SetCursorPos(x + dx, y + dy);
SendMessage(handle, WM_LBUTTONDOWN, IntPtr.Zero, lparam);
SendMessage(handle, WM_LBUTTONUP, IntPtr.Zero, lparam);
SetCursorPos(oripos.X, oripos.Y);
SetCursorPos(e.X, e.Y);
}
else if (e.Button == MouseButtons.Middle)
{
Expand All @@ -79,22 +79,12 @@ private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
var handle = WindowFromPoint(new Point(x, y));
var lparam = CreateLParam(dx, dy);

GetCursorPos(out Point oripos);
SetCursorPos(x + dx, y + dy);
SendMessage(handle, WM_LBUTTONDOWN, IntPtr.Zero, lparam);
SendMessage(handle, WM_LBUTTONUP, IntPtr.Zero, lparam);
SetCursorPos(oripos.X, oripos.Y);
SetCursorPos(e.X, e.Y);
}
}
}

public void Disable()
{
if (hookExist)
{
m_GlobalHook.MouseDownExt -= GlobalHookMouseDownExt;
hookExist = false;
}
}
}
}
}
76 changes: 38 additions & 38 deletions HDT-BGhelper/BGhelperPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,59 @@

namespace HDT_BGhelper
{
public class BGhelperPlugin : IPlugin
{
private BGhelper helper;
public class BGhelperPlugin : IPlugin
{
private BGhelper helper;

public string Author
{
get { return "IBM5100"; }
}
{
get { return "IBM5100"; }
}

public string ButtonText
{
get { return "No Settings"; }
}
public string ButtonText
{
get { return "No Settings"; }
}

public string Description
{
get { return "A battleground plugin makes shortcuts for refresh and freeze.\n" +
"Right click = refresh, middle click = freeze"; }
}
public string Description
{
get { return "A battleground plugin makes shortcuts for refresh and freeze.\n" +
"Right click = refresh, middle click = freeze"; }
}

public System.Windows.Controls.MenuItem MenuItem
{
get { return null; }
}
public System.Windows.Controls.MenuItem MenuItem
{
get { return null; }
}

public string Name
{
get { return "HDT-BGhelper"; }
}
public string Name
{
get { return "HDT-BGhelper"; }
}

public void OnButtonPress()
{
public void OnButtonPress()
{
}

public void OnLoad()
{
helper = new BGhelper();
GameEvents.OnGameStart.Add(helper.GameStart);
GameEvents.OnGameEnd.Add(helper.GameEnd);
{
helper = new BGhelper();
GameEvents.OnGameStart.Add(helper.Activate);
GameEvents.OnInMenu.Add(helper.Deactivate);
}

public void OnUnload()
{
helper.Disable();
{
helper.Deactivate();
}

public void OnUpdate()
{
public void OnUpdate()
{
}

public Version Version
{
get { return new Version(1, 2); }
}
}
public Version Version
{
get { return new Version(1, 3); }
}
}
}
5 changes: 2 additions & 3 deletions HDT-BGhelper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down Expand Up @@ -32,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2")]
[assembly: AssemblyFileVersion("1.2")]
[assembly: AssemblyVersion("1.3")]
[assembly: AssemblyFileVersion("1.3")]

0 comments on commit c7b4f88

Please sign in to comment.