All pastes #424882 Raw Edit

Skeletron

public text v1 · immutable
·published 2007-04-05 02:01 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Orbit_C_Sharp
{
    class Functions
    {
        public partial class DllImports
        {
            [DllImport("user32.dll")]
            public static extern int GetWindowRect(int hwnd, Rectangle lpRect);
            [DllImport("user32.dll")]
            public static extern int WindowFromPoint(int xPoint, int yPoint);
            [DllImport("winmm.dll")]
            public static extern long timeGetTime();
            [DllImport("user32.dll")]
            public static extern void mouse_event(Int32 dwFlags, Int32 dx, Int32 dy, Int32 cButtons, Int32 dwExtraInfo);
        }
        public partial class RSFunctions
        {
            public static Bitmap ScreenShot(Rectangle RectXYWH)
            {
                Bitmap Bmp = new Bitmap(RectXYWH.Width, RectXYWH.Height);
                Graphics.FromImage(Bmp).CopyFromScreen(new Point(0, 0), new Point(), new Size(RectXYWH.Width, RectXYWH.Height));
                return Bmp;
            }
            public static void Wait(long TimeOut)
            {
                long TimeNow;
                TimeNow = timeGetTime();
                do
                {
                    System.Windows.Forms.Application.DoEvents();
                } while (TimeNow + TimeOut > timeGetTime());
            }
            public static void ClickMouse(bool Value)
            {
                if (Value == true)
                {
                    int LeftDown = 0x2;
                    int LeftUp = 0x4;
                    mouse_event(LeftDown, 0, 0, 0, 0);
                    Wait(100);
                    mouse_event(LeftUp, 0, 0, 0, 0);
                }
                else
                {
                    int RightDown = 0x8;
                    int RightUp = 0x10;
                    mouse_event(RightDown, 0, 0, 0, 0);
                    Wait(100);
                    mouse_event(RightUp, 0, 0, 0, 0);
                }
            }
            public static void MoveMouse(int X, int Y, int Steps)
            {
                Point Pos = new Point();
                X = new Random().Next(X - 10, X + 10);
                Y = new Random().Next(Y - 10, Y + 10);
                Steps = new Random().Next(Steps - 20, Steps + 20);
                do
                {
                    try
                    {
                        Pos.X = System.Windows.Forms.Cursor.Position.X;
                        Pos.Y = System.Windows.Forms.Cursor.Position.Y;
                        Pos.X = Pos.X + ((X - Pos.X) / Steps);
                        Pos.Y = Pos.Y + ((Y - Pos.Y) / Steps);
                        System.Windows.Forms.Cursor.Position = new Point(Pos.X, Pos.Y);
                        Steps -= 1;
                        Wait((1));
                    }
                    catch
                    {
                        return;
                    }
                } while (Steps >= 0);
            }
        }
        public partial class MainFunction
        {
            public static bool InStr(String String1, String String2)
            {
                if (String1.IndexOf(String2, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    return true;
                }
                return false;
            }
            public static string Split(string StringToSplit, string Splitter)
            {
                int Index = StringToSplit.IndexOf(Splitter);
                string String1 = StringToSplit.Remove(0, Index + 1);
                //MessageBox.Show(String1);
                return String1;
            }
            public static string Remove(string StringToRemove, string RemoveStringIndex)
            {
                int Index = StringToRemove.IndexOf(RemoveStringIndex);
                string String1 = StringToRemove.Remove(Index);
                //MessageBox.Show(String1);
                return String1;
            }
            public static bool IsNumeric(string ValidString)
            {
                try
                {
                    Int32.Parse(ValidString);
                }
                catch
                {
                    return false;
                }
                return true;
            }
            public static string StrReverse(string UnReversed)
            {
                System.Collections.ArrayList Items = new System.Collections.ArrayList();
                String Part;
                String Compile = "";
                for (int I = 0; I < UnReversed.Length; I++)
                {
                    Part = Convert.ToString(UnReversed.Substring(I, 1));
                    Items.Add(Part);
                }
                Items.Reverse();
                for (int X = 0; X < Items.Count; X++)
                {
                    Compile = Compile + Convert.ToString(Items[X]);
                }
                return Compile;
            }
            public static bool Kill(string FileName)
            {
                try
                {
                    System.IO.File.Delete(FileName);
                }
                catch
                {
                    return false;
                }
                return true;
            }
            public static int Asc(string CharString)
            {
                if (CharString.Length > 1)
                {
                    return -1;
                }
                char Chr;
                try
                {
                    Chr = Convert.ToChar(CharString);
                }
                catch
                {
                    return -1;
                }
                int AscValue = 0;
                try
                {
                    AscValue = (int)Chr;
                }
                catch
                {
                    return -1;
                }
                return Chr;
            }
        }
    }
}