public void Exit(object sender, EventArgs e) { MagicKeys.KeySwitch = 1; MagicKeys.UnregisterHotKey(MagicKeys.HM.Handle, 0); MagicKeys.UnregisterHotKey(MagicKeys.HM.Handle, 1); Ni.Visible = false; if (MagicKeys.Exit == true) { DialogResult result; result = MessageBox.Show(T._("Do you really want to exit MagicKeys?"), T._("Exit MagicKeys"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); if (result == DialogResult.OK) { MagicKeys.Speak(T._("Goodbye")); Application.Exit(); return; } Ni.Visible = true; MagicKeys.RegisterHotKey(MagicKeys.HM.Handle, 0, MKC.CTRL | MKC.SHIFT | MKC.MOD_NOREPEAT, (int)Keys.F1); MagicKeys.RegisterHotKey(MagicKeys.HM.Handle, 1, MKC.CTRL | MKC.SHIFT | MKC.MOD_NOREPEAT, (int)Keys.F2); MagicKeys.KeySwitch = 0; } else { MagicKeys.Speak(T._("Goodbye")); Application.Exit(); } }
public static void ImgSave() { KeyUnReg(); OptionKeyUnReg(); int[] MP = MagicKeys.GetMousePosition(); string ITB = MagicKeys.InputTextBox("Image name", "Enter image name"); if (ITB == "0") { KeyReg(); OptionKeyReg(); return; } int Width = Convert.ToInt32(MagicKeys.InputBox("Image width", "Enter image width", 1, P[3] - MP[0])); if (Width == 0) { KeyReg(); OptionKeyReg(); return; } int Height = Convert.ToInt32(MagicKeys.InputBox("Image height", "Enter image height", 1, P[4] - MP[1])); if (Height == 0) { KeyReg(); OptionKeyReg(); return; } Bitmap Screen = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(Screen); g.CopyFromScreen(MP[0] - (Width / 2), MP[1] - (Height / 2), 00, 0, Screen.Size); Screen.Save(@"DevSave\" + Module + @"\" + ITB + ".bmp"); }
public void DebugForm_Shown(object sender, EventArgs e) { this.Activate(); MagicKeys.SoundPlay("Error", 0); string[] DI = DebugInfo.Split("|"); switch (DI[0]) { case "IniRead": IniReadError(DI); break; case "IniReadKeys": IniReadKeysError(DI); break; case "KeyReg": KeyRegError(DI); break; case "FileNotFound": FileNotFoundError(DI); break; case "ExceptionHook": ExceptionHookError(DI); break; } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case MKC.WM_HOTKEY: int modifier = (int)m.LParam & 0xFFFF; Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF); if (modifier == (MKC.CTRL | MKC.SHIFT) & key == Keys.F3) { MagicKeys.HelpForm(); } else if (modifier == (MKC.CTRL | MKC.SHIFT) & key == Keys.F5) { VUILoader(API.GetVUI()); } else if ((modifier == MKC.SHIFT & key == Keys.Tab) || key == Keys.Left) { MagicKeys.VUIObjectNavigator("Back"); } else if (key == Keys.Tab || key == Keys.Right) { MagicKeys.VUIObjectNavigator("Next"); } else if (key == Keys.F1) { MagicKeys.VUIObjectHelp(); } else if (key == Keys.Enter) { MagicKeys.VUIObjectEnter(); } break; } base.WndProc(ref m); }
public static void SpeakWindowRect() { int[] Rect = MagicKeys.GetWinRect(MagicKeys.GetForegroundWindow()); string R = T._("Width") + " " + (Rect[2] - P[1]).ToString() + ", " + T._("Height") + " " + (Rect[3] - P[2]).ToString(); MagicKeys.Speak(R); }
public static void KeyUnReg() { for (int I = 4; I <= 24; I++) { MagicKeys.UnregisterHotKey(DeveloperTool.HM.Handle, I); } }
public static void ControlSearch() { KeyUnReg(); OptionKeyUnReg(); string ModuleName = MagicKeys.InputTextBox("Enter sub string for calling module", "ControlSearch"); if (ModuleName == "0") { OptionKeyReg(); return; } Module = ModuleName; MagicKeys.SetWindowPos(MagicKeys.GetForegroundWindow(), 0, 10, 10, 0, 0, MKC.SWP_NOSIZE | MKC.SWP_NOACTIVATE | MKC.SWP_NOZORDER); P = GetPluginCoord(); if (P[0] == 1) { MagicKeys.Speak("Module found"); MagicKeys.MouseMove(P[1], P[2], 0); KeyReg(); OptionKeyReg(); MagicKeys.SoundPlay("WindowOpened", 0); Directory.CreateDirectory(@".\DevSave\" + Module); ModuleFound(); KeyUnReg(); MagicKeys.SoundPlay("WindowClosed", 0); } else { MagicKeys.Speak("Not found"); OptionKeyReg(); } }
public static void SpeakMousePosition() { int[] MP = MagicKeys.GetMousePosition(); string S = "X " + (MP[0] - P[1]).ToString() + ", Y" + (MP[1] - P[2]).ToString(); MagicKeys.Speak(S); }
public static void Save() { KeyUnReg(); OptionKeyUnReg(); string Name = MagicKeys.InputTextBox(T._("Save"), T._("Enter name for save.")); if (Name == null) { return; } int[] MP = MagicKeys.GetMousePosition(); Bitmap Screen = new Bitmap(1, 1); Graphics g = Graphics.FromImage(Screen); g.CopyFromScreen(MP[0], MP[1], 00, 0, Screen.Size); Color GetColor = Screen.GetPixel(0, 0); string StrColor = String.Format("#{0:X6}", GetColor.ToArgb() & 0x00FFFFFF); string WR = "Name: " + Name + "\r\nX: " + (MP[0] - P[1]).ToString() + "\r\nY: " + (MP[1] - P[2]).ToString() + "\r\nColor: " + StrColor + "\r\n"; if (OCRR != string.Empty) { WR += "OCR:\r\n" + OCRR + "\r\n"; } WR += "\r\n"; using (StreamWriter sw = new StreamWriter(@".\DevSave\" + Module + @"\" + Module + ".txt", true, System.Text.Encoding.Default)) { sw.Write(WR); } KeyReg(); OptionKeyReg(); }
public static int[] GetPluginCoord() { int[] ControlCoord; IntPtr Handle = MagicKeys.GetForegroundWindow(); int[] RC = MagicKeys.GetWinRect(Handle); for (int X = RC[0]; X < RC[2]; X += 100) { for (int Y = RC[1]; Y < RC[3]; Y += 150) { IntPtr HModule = MagicKeys.GetWinPointHandle(X, Y); string ModuleName = MagicKeys.GetDllName(HModule); if (ModuleName.Contains(Module, StringComparison.OrdinalIgnoreCase) == true) { Module = ModuleName; int[] RectCTRL = MagicKeys.GetWinRect(MagicKeys.GetWinPointHandle(X, Y)); ControlCoord = new int[5] { 1, RectCTRL[0], RectCTRL[1], RectCTRL[2] - 1, RectCTRL[3] - 1 }; return(ControlCoord); } } } ControlCoord = new int[5] { 0, 0, 0, 0, 0 }; return(ControlCoord); }
public static async void VisionBotResult(string ID) { HttpClient HTTPC = new HttpClient(); var Values = new Dictionary <string, string> { { "id", ID } }; var form = new FormUrlEncodedContent(Values); while (true) { HttpResponseMessage response = await HTTPC.PostAsync("https://visionbot.ru/apiv2/res.php", form); response.EnsureSuccessStatusCode(); string sd = response.Content.ReadAsStringAsync().Result; Dictionary <string, string> J = JsonSerializer.Deserialize <Dictionary <string, string> >(sd); if (J["status"] == "notready") { Thread.Sleep(1000); MagicKeys.SoundPlay("PluginDetect", 0); continue; } HTTPC.Dispose(); OCRR = J["text"]; MagicKeys.Speak(J["text"]); break; } }
public static async void VisionBot() { if (DP[0] == 0) { MagicKeys.Speak("No rect for OCR"); return; } int[] MP = MagicKeys.GetMousePosition(); Bitmap Screen = new Bitmap(DP[0], DP[1]); Graphics g = Graphics.FromImage(Screen); g.CopyFromScreen(MP[0] - (DP[0] / 2), MP[1] - (DP[1] / 2), 00, 0, Screen.Size); Bitmap S = new Bitmap(Screen, new Size(DP[0] * OCRZoom, DP[1] * OCRZoom)); ImageConverter converter = new ImageConverter(); byte[] BT = (byte[])converter.ConvertTo(S, typeof(byte[])); HttpClient HTTPC = new HttpClient(); var form = new MultipartFormDataContent(); form.Add(new ByteArrayContent(BT, 0, BT.Length), "file", "OCR.bmp"); form.Add(new StringContent("text"), "target"); HttpResponseMessage response = await HTTPC.PostAsync("https://visionbot.ru/apiv2/in.php", form); response.EnsureSuccessStatusCode(); HTTPC.Dispose(); string sd = response.Content.ReadAsStringAsync().Result; Dictionary <string, string> J = JsonSerializer.Deserialize <Dictionary <string, string> >(sd); VisionBotResult(J["id"]); }
public static void MouseMover(string To) { OCRR = string.Empty; Thread.Sleep(20); KeyUnReg(); int[] MP = MagicKeys.GetMousePosition(); if (To == "Left") { if (MP[0] - MouseStep <= P[1]) { MagicKeys.SoundPlay("End", 0); MagicKeys.MouseMove(P[1], MP[1], 0); KeyReg(); return; } MagicKeys.MouseMove(MP[0] - MouseStep, MP[1], 0); } if (To == "Right") { if (MP[0] + MouseStep >= P[3]) { MagicKeys.SoundPlay("End", 0); MagicKeys.MouseMove(P[3], MP[1], 0); KeyReg(); return; } MagicKeys.MouseMove(MP[0] + MouseStep, MP[1], 0); } if (To == "Up") { if (MP[1] - MouseStep <= P[2]) { MagicKeys.SoundPlay("End", 0); MagicKeys.MouseMove(MP[0], P[2], 0); KeyReg(); return; } MagicKeys.MouseMove(MP[0], MP[1] - MouseStep, 0); } if (To == "Down") { if (MP[1] + MouseStep >= P[4]) { MagicKeys.SoundPlay("End", 0); MagicKeys.MouseMove(MP[0], P[4], 0); KeyReg(); return; } MagicKeys.MouseMove(MP[0], MP[1] + MouseStep, 0); } if (AutoOCR == 1) { VisionBot(); } KeyReg(); }
public static void SpeakModule() { int[] MP = MagicKeys.GetMousePosition(); IntPtr HModule = MagicKeys.GetWinPointHandle(MP[0], MP[1]); string ModuleName = MagicKeys.GetDllName(HModule); MagicKeys.Speak(ModuleName); }
public void Save_Click(object sender, EventArgs e) { Ini.IniWrite(@".\Settings.ini", "Settings", "NavigationType", Convert.ToInt32(NavigationType.Checked).ToString()); Ini.IniWrite(@".\Settings.ini", "Settings", "SoundTheme", Convert.ToBoolean(SoundTheme.Checked).ToString()); Ini.IniWrite(@".\Settings.ini", "Settings", "TimeOut", (Time.Value).ToString()); Ini.IniWrite(@".\Settings.ini", "Settings", "SpeakType", Convert.ToBoolean(SpeakType.Checked).ToString()); Ini.IniWrite(@".\Settings.ini", "Settings", "Exit", Convert.ToBoolean(Exit.Checked).ToString()); MagicKeys.LoadSettings(); this.Close(); }
public static void MKDebugForm(string DebugInfo) { MagicKeys.UnregisterHotKey(MagicKeys.HM.Handle, 1); MagicKeys.UnregisterHotKey(MagicKeys.HM.Handle, 2); KeyUnReg(); KeySwitch = 1; using DebugForm DF = new DebugForm(); DF.DebugInfo = DebugInfo; DF.ShowDialog(); }
public static List<string> IniReadKeys(string GetFile, string GetSection) { List<string> temp = new List<string>(); int L = 0; int End = 0; string Error = string.Empty; try { if (IniFileExists(GetFile) == false) { MagicKeys.MKDebugForm("FileNotFound|"+GetFile); return null; } string[] FileStr = File.ReadAllLines(GetFile); for (int S = 0; S <= FileStr.Length-1; S++) { if (FileStr[S].StartsWith(":") == true || FileStr[S].StartsWith("#") == true) continue; if (FileStr[S].Trim() == "["+GetSection+"]") { L = S; break; } else if (FileStr[S].Trim() != "["+GetSection+"]" && S == FileStr.Length-1) { L = S+1; Error = T._("Section not found"); throw new Exception(); } } for (int R = L+1; R <= FileStr.Length-1; R++) { if (FileStr[R].StartsWith(":") == true || FileStr[R].StartsWith("#") == true) continue; if (FileStr[R].Contains("[") || R == FileStr.Length-1) { End = R; break; } } for (int Start = L+1; Start <= End; Start++) { if (FileStr[Start].StartsWith(":") == true || FileStr[Start].StartsWith("#") == true) continue; if (FileStr[Start].Contains("[") == true) continue; string[] KeyValue = FileStr[Start].Split("=", 2); temp.Add(KeyValue[0].Trim()); } return temp; } catch(Exception) { MagicKeys.MKDebugForm("IniReadKeys|"+L.ToString()+"|"+GetFile+"|"+GetSection+"|"+Error); return null; } }
public static void OptionKeyReg() { MagicKeys.RegisterHotKey(HM.Handle, 0, MKC.CTRL | MKC.SHIFT | MKC.MOD_NOREPEAT, (int)Keys.F1); MagicKeys.RegisterHotKey(HM.Handle, 1, MKC.CTRL | MKC.SHIFT | MKC.MOD_NOREPEAT, (int)Keys.F2); if (KeySwitch == 1) { return; } MagicKeys.RegisterHotKey(HM.Handle, 2, MKC.CTRL | MKC.SHIFT | MKC.MOD_NOREPEAT, (int)Keys.F3); MagicKeys.RegisterHotKey(HM.Handle, 3, MKC.CTRL | MKC.SHIFT | MKC.MOD_NOREPEAT, (int)Keys.F4); }
public static void OCRClick(string BTN) { if (DP[0] == 0) { MagicKeys.Speak(T._("No rectangle for OCR")); return; } int[] MP = MagicKeys.GetMousePosition(); MagicKeys.MouseClick(BTN, MP[0] + (DP[0] / 2), MP[1] + (DP[1] / 2), 1, 0, 0, 10); MagicKeys.MouseMove(MP[0], MP[1], 1); }
public void NexusSearchForm_Shown(object sender, EventArgs e) { this.Activate(); string ScanDir = MagicKeys.RegReader(Microsoft.Win32.Registry.CurrentUser, "SOFTWARE/reFX/Nexus", "ContentPath"); string[] Dirs = Directory.GetDirectories(ScanDir + "/Presets"); foreach (string S in Dirs) { ListBank.Items.Add(Path.GetFileName(S)); } ListBank.Items[0].Selected = true; }
public static void SpeakColor() { int[] MP = MagicKeys.GetMousePosition(); Bitmap Screen = new Bitmap(1, 1); Graphics g = Graphics.FromImage(Screen); g.CopyFromScreen(MP[0], MP[1], 00, 0, Screen.Size); Color GetColor = Screen.GetPixel(0, 0); string StrColor = String.Format("#{0:X6}", GetColor.ToArgb() & 0x00FFFFFF); MagicKeys.Speak(StrColor); }
static void Main() { var RunProc = from proc in Process.GetProcesses(".") orderby proc.Id select proc; if (RunProc.Count(p => p.ProcessName.Contains("MagicKeys")) > 0) { MessageBox.Show("You must close MagicKeys to run DeveloperTool.", "Error"); return; } HM = new Menu(); MagicKeys.Speak("DeveloperTool is ready"); OptionKeyReg(); Application.Run(); }
public static void WindowsOCR() { if (DP[0] == 0) { MagicKeys.Speak("No rect for OCR"); return; } int[] MP = MagicKeys.GetMousePosition(); string Text = MagicKeys.ImgToText(DP[0], DP[1], MP[0] - (DP[0] / 2), MP[1] - (DP[1] / 2), OCRZoom); Thread.Sleep(500); OCRR = Text; MagicKeys.Speak(Text); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case MKC.WM_HOTKEY: int modifier = (int)m.LParam & 0xFFFF; Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF); if (modifier == (MKC.CTRL | MKC.SHIFT) & key == Keys.F1) { if (MagicKeys.KeySwitch == 0) { Ni.Text = T._("MagicKeys {0} is disabled", MagicKeys.Version); MagicKeys.Speak(T._("MagicKeys is disabled")); MagicKeys.KeySwitch = 1; } else if (MagicKeys.KeySwitch == 1) { Ni.Text = T._("MagicKeys {0} is enabled", MagicKeys.Version); MagicKeys.Speak(T._("MagicKeys is enabled")); MagicKeys.KeySwitch = 0; } } else if (modifier == (MKC.CTRL | MKC.SHIFT) & key == Keys.F2) { Exit(null, null); } else if (modifier == (MKC.CTRL | MKC.SHIFT) & key == Keys.F4) { if (MagicKeys.SoundTheme == true) { MagicKeys.SoundTheme = false; MagicKeys.Speak(T._("Sounds off")); } else { MagicKeys.SoundTheme = true; MagicKeys.Speak(T._("Sounds on")); } } else if (modifier == (MKC.CTRL | MKC.SHIFT) & key == Keys.F6) { Settings(null, null); } break; } base.WndProc(ref m); }
public static void MouseGoTo() { KeyUnReg(); OptionKeyUnReg(); int[] MP = MagicKeys.GetMousePosition(); InputBox X = new InputBox(); X.Text = "Mouse X"; X.InputBoxLabel.Text = "Enter new mouse position X"; X.Value.Minimum = 0; X.Value.Maximum = P[3] - P[1]; X.ShowDialog(); int NewX; if (X.DialogResult == DialogResult.OK) { NewX = Convert.ToInt32(X.GetString()); } else { KeyReg(); OptionKeyReg(); return; } InputBox Y = new InputBox(); Y.Text = "Mouse Y"; Y.InputBoxLabel.Text = "Enter new mouse position Y"; Y.Value.Minimum = 0; Y.Value.Maximum = P[4] - P[2]; Y.ShowDialog(); int NewY; if (Y.DialogResult == DialogResult.OK) { NewY = Convert.ToInt32(Y.GetString()); } else { KeyReg(); OptionKeyReg(); return; } MagicKeys.MouseMove(P[1] + NewX, P[2] + NewY, 0); KeyReg(); OptionKeyReg(); }
public static async void OCRWordPosition() { KeyUnReg(); OptionKeyUnReg(); Bitmap Screen = new Bitmap(P[3] - P[1], P[4] - P[2]); Graphics g = Graphics.FromImage(Screen); g.CopyFromScreen(P[1], P[2], 00, 0, Screen.Size); var engine = Windows.Media.Ocr.OcrEngine.TryCreateFromLanguage(new Windows.Globalization.Language("en")); var memoryStream = new MemoryStream(); Screen.Save(memoryStream, ImageFormat.Bmp); var WMS = WindowsRuntimeStreamExtensions.AsRandomAccessStream(memoryStream); var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(WMS); var softwareBitmap = await decoder.GetSoftwareBitmapAsync(); var OCRR = await engine.RecognizeAsync(softwareBitmap); OCRResultForm ORF = new OCRResultForm(); foreach (var Line in OCRR.Lines) { for (int I = 0; I <= Line.Words.Count - 1; I++) { LW.Add(Line.Words[I].Text); LX.Add(Convert.ToInt32(Line.Words[I].BoundingRect.X)); LY.Add(Convert.ToInt32(Line.Words[I].BoundingRect.Y)); } } foreach (var W in LW) { ORF.WList.Items.Add(W); } ORF.ShowDialog(); if (ORF.DialogResult == DialogResult.OK) { int SI = ORF.WList.SelectedIndex; MagicKeys.MouseMove(P[1] + LX[SI], P[2] + LY[SI], 0); LW.Clear(); LX.Clear(); LY.Clear(); } OptionKeyReg(); KeyReg(); }
public void ListBank_SelectedIndexChanged(object sender, EventArgs e) { try { ListPatch.Items.Clear(); string ScanDir = MagicKeys.RegReader(Microsoft.Win32.Registry.CurrentUser, "SOFTWARE/reFX/Nexus", "ContentPath"); string[] Files = Directory.GetFiles(ScanDir + "/Presets/" + (ListBank.FocusedItem.Text)); foreach (string S in Files) { ListPatch.Items.Add(Path.GetFileNameWithoutExtension(Path.GetFileName(S))); } ListPatch.Items[0].Selected = true; } catch (Exception) { } }
public async void Exit(object sender, EventArgs e) { DeveloperTool.KeySwitch = 1; DeveloperTool.OptionKeyUnReg(); Ni.Visible = false; DialogResult result = await Task.Run(() => MessageBox.Show("Do you really want to exit DeveloperTool?", "Exit DeveloperTool", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification)); if (result == DialogResult.OK) { MagicKeys.Speak("Goodbye"); Application.Exit(); return; } DeveloperTool.KeySwitch = 0; Ni.Visible = true; DeveloperTool.OptionKeyReg(); }
public static void HelpForm() { string HelpFile = API.GetVUIPath() + API.GetVUI() + ".help"; if (File.Exists(HelpFile) == false) { MagicKeys.Speak(T._("Help file not found")); } else { KeyUnReg(); using HelpForm HF = new HelpForm(); HF.HelpFile = HelpFile; HF.ShowDialog(); KeyReg(); } }
public static void MouseStepChange() { KeyUnReg(); OptionKeyUnReg(); InputBox IB = new InputBox(); IB.Text = "Mouse step"; IB.InputBoxLabel.Text = "Enter mouse step"; IB.Value.Minimum = 1; IB.Value.Maximum = 100; IB.ShowDialog(); if (IB.DialogResult == DialogResult.OK) { MouseStep = Convert.ToInt32(IB.GetString()); } KeyReg(); OptionKeyReg(); MagicKeys.Speak(MouseStep.ToString()); }