HI
The original
LetMeDriveCTRL/
LazyRaider plugin has some design issues.
1st:
LetMeDriveCTRL can't handle the window on which the
CTRL key was pressed, so when you press that key on any other window, the bot will be stopped.
......The same happens for
LazyRaider when pressing left mouse button on a window, so just doing your common things on your PC it will stop the Bot everytime.
2st:
LetMeDriveCTRL and
LazyRaider can't handle multiple instances of
Diablo III because the 1st reason.
LetMeDriveCTRL is very useful, but
Lazy Raider is a feature that I really can't understand why exists,
because if the user needs to stop the bot to perform manual actions on the hero, that means the left mouse button should be free to use properlly on the D3 UI (to click on menus to select options, or to move, etc),
but since now
Lazy Raider handles mouse buttons instead keyboard keys, the Bot resumes when left mouse button is released, then this plugin, in my oppinion, has really any sense.
In resume, we can say that
LetMeDriveCTRL is very useful to pause the Bot to do any thing on the D3 client window using your mouse, and
Lazy Raider is the opposite, it's useful to move your hero from a stuck and nothing nore (at least I can't find any other reason to use it) but... hey, you already can go out from a stuck using the mouse button without any plugin (yes, it doesn't stops the bot, it will interfere with the bot movement, but it just need one click) so as I said in my oppinion is very absurd the implementation of
Lazy Raider feature, it should handle keys as did it before, no mouse buttons.
So, if someone want to get back the functionality of
LetMeDriveCTRL, with the bugs fixed, with logic improved, and with the key configurable, then you could use the plugin that I developed.
Note that the key is configurable, yes, but in a hardcoded way on the next variable:
By default (left)
CTRL key is established to stop the Bot, but you can specify any element of the WPF
System.Windows.Input.Key enumeration (don't confuse with WinForms
System.Windows.Forms.Keys enumeration, that is not compatible).
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Windows.Forms;
using System.Windows;
using System.Windows.Input;
using Key = System.Windows.Input.Key;
using Zeta.Bot;
using Zeta.Bot.Logic;
using Zeta.Bot.Profile;
using Zeta.Common;
using Zeta.Common.Plugins;
using Zeta.TreeSharp;
namespace LetMeDrive {
internal class SafeNativeMethods {
[DllImport("user32.dll", SetLastError = false)]
[SuppressUnmanagedCodeSecurity()]
internal static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", SetLastError = true)]
[SuppressUnmanagedCodeSecurity()]
internal static extern int GetWindowThreadProcessId(IntPtr hwnd, out int pid);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity()]
internal static extern short GetKeyState(int virtualKey);
internal const int KEY_PRESSED = 0x8000;
}
public class Logic : IPlugin {
private Key Mykey = Key.LeftCtrl;
public string Author { get { return "Elektro"; } }
public string Description { get { return "LetMeDrive"; } }
public string Name { get { return "LetMeDrive " + Version; } }
public Version Version { get { return new Version(1, 0); } }
public Window DisplayWindow { get { return null; } }
public bool Equals(IPlugin other) { return (other.Name == Name) && (other.Version == Version); }
private bool IsPauseRequested() {
int virtualKey = System.Windows.Input.KeyInterop.VirtualKeyFromKey(this.Mykey);
bool keyIsPressed = Convert.ToBoolean(SafeNativeMethods.GetKeyState(virtualKey) & SafeNativeMethods.KEY_PRESSED);
if (!keyIsPressed) {
return false;
} else {
Process[] d3procs = Process.GetProcessesByName(processName: "Diablo III").ToArray();
if (d3procs.Any()) {
try {
int[] d3pids = (from p in d3procs select p.Id).ToArray();
IntPtr activeWindow = SafeNativeMethods.GetForegroundWindow();
int activePid;
SafeNativeMethods.GetWindowThreadProcessId(activeWindow, out activePid);
Process actideProc = Process.GetProcessById((int)activePid);
return d3pids.Contains(actideProc.Id);
} catch {
return false;
}
} else {
return false;
}
}
}
public void OnPulse() {
if ((!BotMain.IsPaused && IsPauseRequested()) || BotMain.IsPaused && !IsPauseRequested()) {
BotMain.PauseWhile(IsPauseRequested);
}
}
public void OnInitialize() {}
public void OnEnabled() {}
public void OnDisabled() {}
public void OnShutdown() {}
}
}