Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualBasic.CompilerServices;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Drawing;
- using System.Reflection;
- using System.Reflection.Emit;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Windows.Forms;
- namespace %ConsoleApp%
- {
- class %Program%
- {
- public delegate bool %MOUSE_DELG%(uint %dwFlags%, int %dx%, int %dy%, uint %dwData%, UIntPtr %dwExtraInfo%);
- public static %MOUSE_DELG% %MOUSE%;
- public delegate ushort %ASYNC_KEY_DELG%(int %vKey%);
- public static %ASYNC_KEY_DELG% %ASYNC_KEY%;
- static void Main(string[] args)
- {
- %MOUSE% = %CreateAPI%<%MOUSE_DELG%>("user32.dll", "mouse_event"); //Cast the Delegate
- %ASYNC_KEY% =
- %CreateAPI%<%ASYNC_KEY_DELG%>("user32.dll", "GetAsyncKeyState"); //Cast the Delegate
- bool %cycleDone% = false;
- Point %p1% = new Point();
- if (%MOUSE% != null
- && %ASYNC_KEY% != null )
- {
- int %fireRate% = 1000 / (450 / 60);
- int[] %xRecoil% = { 40, 48, 48, 48, 33, 33, 28, 24, 16, 13, 18, 22, 24, 29, 33, 33, 33, 29, 22, 20, 17, 17, 17, 17, 20, 27, 27, 27, 26 };
- int[] %yRecoil% = { -36, 5, -59, -49, 3, 20, 25, 45, 43, 32, 82, 8, 43, -32, -25, -40, -35, -32, -43, -42, -42, -55, -25, 15, 20, 35, 50, 62, 40 };
- int %mouseXNext% = 0;
- int %mouseYNext% = 0;
- while (true)
- {
- if (%IsDown%() && %cycleDone% != true)
- {
- for (int %i% = 0; %i% < %xRecoil%.Length -1; %i%++)
- {
- %mouseXNext% = Cursor.Position.X - %xRecoil%[%i%];
- %mouseYNext% = Cursor.Position.Y - %yRecoil%[%i%];
- %MOUSE%(0x0001, %mouseXNext%, %mouseYNext%, 0, UIntPtr.Zero);
- Thread.Sleep(%fireRate%);
- }
- %cycleDone% = true;
- }
- else
- {
- if (%p1%.X != -1 || %p1%.Y != -1)
- {
- %p1%.X = -1;
- %p1%.Y = -1;
- }
- if (!%cycleDone%) %cycleDone% = false;
- Thread.Sleep(1);
- }
- }
- }
- else
- {
- Debug.WriteLine("[ERR] Could not create delegate(s)");
- }
- }
- public static bool %IsDown%()
- {
- return 0 != (%ASYNC_KEY%((int) Keys.LButton) & 0x8000);
- }
- public static T %CreateAPI%<T>(string %wLib%, string %mName%)
- {
- AssemblyBuilder ASMB =
- AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(Assembly.GetExecutingAssembly().FullName),
- AssemblyBuilderAccess.RunAndSave);
- ModuleBuilder MODB = ASMB.DefineDynamicModule(MethodBase.GetCurrentMethod().Name);
- TypeBuilder TB = MODB.DefineType(MethodBase.GetCurrentMethod().DeclaringType.Name, TypeAttributes.Public);
- MethodInfo MI = typeof(T).GetMethods()[0];
- List<Type> LP = new List<Type>();
- foreach (ParameterInfo pI in MI.GetParameters())
- LP.Add(pI.ParameterType);
- MethodBuilder MB = TB.DefinePInvokeMethod(%mName%,
- %wLib%,
- MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.PinvokeImpl,
- CallingConventions.Standard,
- MI.ReturnType, LP.ToArray(),
- CallingConvention.Winapi,
- CharSet.Ansi);
- MB.SetImplementationFlags(MB.GetMethodImplementationFlags() | MethodImplAttributes.PreserveSig);
- return Conversions.ToGenericParameter<T>(Delegate.CreateDelegate(typeof(T), TB.CreateType().GetMethod(%mName%)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement