public static GetTibiaProcess ( ) : |
||
리턴 |
public static void ShowSuspendedWindow(bool alwaysShow = false) { lock (suspendedLock) { if (window != null) { window.Close(); window = null; } Screen screen; Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { screen = Screen.FromControl(MainForm.mainForm); } else { screen = Screen.FromHandle(tibia_process.MainWindowHandle); } window = new AutoHotkeySuspendedMode(alwaysShow); int position_x = 0, position_y = 0; int suspendedX = SettingsManager.getSettingInt("SuspendedNotificationXOffset"); int suspendedY = SettingsManager.getSettingInt("SuspendedNotificationYOffset"); int xOffset = suspendedX < 0 ? 10 : suspendedX; int yOffset = suspendedY < 0 ? 10 : suspendedY; int anchor = SettingsManager.getSettingInt("SuspendedNotificationAnchor"); switch (anchor) { case 3: position_x = screen.WorkingArea.Right - xOffset - window.Width; position_y = screen.WorkingArea.Bottom - yOffset - window.Height; break; case 2: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Bottom - yOffset - window.Height; break; case 0: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Top + yOffset; break; default: position_x = screen.WorkingArea.Right - xOffset - window.Width; position_y = screen.WorkingArea.Top + yOffset; break; } window.StartPosition = FormStartPosition.Manual; window.SetDesktopLocation(position_x, position_y); window.TopMost = true; window.Show(); } }
public static void ScanTabStructures(Player player) { Process p = ProcessManager.GetTibiaProcess(); if (p == null) { return; } List <TabStructure> newStructures = TabStructureScanner.FindTabStructures(p, player); Interlocked.Exchange(ref tabStructures, newStructures); }
public static Screen GetScreen() { Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null || SettingsManager.getSettingInt("MonitorAnchor") == 1) { return(Screen.FromControl(MainForm.mainForm)); } else { return(Screen.FromHandle(tibia_process.MainWindowHandle)); } }
private static void writeToAutoHotkeyFile() { if (!SettingsManager.settingExists("AutoHotkeySettings")) { return; } using (StreamWriter writer = new StreamWriter(Constants.AutohotkeyFile)) { writer.WriteLine("#SingleInstance force"); if (ProcessManager.IsFlashClient()) { Process p = ProcessManager.GetTibiaProcess(); writer.WriteLine("SetTitleMatchMode 2"); writer.WriteLine(String.Format("#IfWinActive Tibia Flash Client", p == null ? 0 : p.Id)); } else { writer.WriteLine("#IfWinActive ahk_class TibiaClient"); } foreach (string l in SettingsManager.getSetting("AutoHotkeySettings")) { string line = l.ToLower(); if (line.Length == 0 || line[0] == ';') { continue; } if (line.Contains("suspend")) { // if the key is set to suspend the hotkey layout, we set it up so it sends a message to us writer.WriteLine(modifyKeyString(line.ToLower().Split(new string[] { "suspend" }, StringSplitOptions.None)[0], l)); writer.WriteLine("suspend"); writer.WriteLine("if (A_IsSuspended)"); // message 32 is suspend writer.WriteLine("PostMessage, 0x317,32,32,,Tibialyzer"); writer.WriteLine("else"); // message 33 is not suspended writer.WriteLine("PostMessage, 0x317,33,33,,Tibialyzer"); writer.WriteLine("return"); } else { writer.WriteLine(modifyKeyString(line, l)); } } } }
public static Bitmap takeScreenshot() { try { RECT Rect = new RECT(); if (ReadMemoryManager.FlashClient) { Screen screen = Screen.FromControl(MainForm.mainForm); Rect.left = screen.Bounds.Left; Rect.right = screen.Bounds.Right; Rect.top = screen.Bounds.Top; Rect.bottom = screen.Bounds.Bottom; } else { Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { return(null); //no tibia to take screenshot of } if (!GetWindowRect(tibia_process.MainWindowHandle, ref Rect)) { return(null); } } Point p = toPixels(new Point(Rect.left, Rect.top)); Rect.left = p.X; Rect.top = p.Y; p = toPixels(new Point(Rect.right, Rect.bottom)); Rect.right = p.X; Rect.bottom = p.Y; Bitmap bitmap = new Bitmap(Rect.right - Rect.left, Rect.bottom - Rect.top); using (Graphics gr = Graphics.FromImage(bitmap)) { gr.CopyFromScreen(new Point(Rect.left, Rect.top), Point.Empty, bitmap.Size); } return(bitmap); } catch (Exception ex) { MainForm.mainForm.DisplayWarning("Failed to take screenshot: " + ex.Message); return(null); } }
public static Bitmap takeScreenshot() { Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { return(null); //no tibia to take screenshot of } RECT Rect = new RECT(); if (!GetWindowRect(tibia_process.MainWindowHandle, ref Rect)) { return(null); } Bitmap bitmap = new Bitmap(Rect.right - Rect.left, Rect.bottom - Rect.top); using (Graphics gr = Graphics.FromImage(bitmap)) { gr.CopyFromScreen(new Point(Rect.left, Rect.top), Point.Empty, bitmap.Size); } return(bitmap); }
private void ShowTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (alwaysShow) { return; } if (ProcessManager.IsFlashClient()) { return; } try { if (showTimer == null || this.IsDisposed || this.Disposing) { return; } // only show the suspended window when tibia is active bool visible = GetActiveProcessFileName() == ProcessManager.GetTibiaProcess().ProcessName; this.BeginInvoke((MethodInvoker) delegate { this.Visible = visible; }); } catch { } }
public static Bitmap takeScreenshot() { try { Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { return(null); //no tibia to take screenshot of } RECT Rect = new RECT(); if (!GetWindowRect(tibia_process.MainWindowHandle, ref Rect)) { return(null); } Bitmap bitmap = new Bitmap(Rect.right - Rect.left, Rect.bottom - Rect.top); using (Graphics gr = Graphics.FromImage(bitmap)) { gr.CopyFromScreen(new Point(Rect.left, Rect.top), Point.Empty, bitmap.Size); } return(bitmap); } catch (Exception ex) { MainForm.mainForm.DisplayWarning("Failed to take screenshot: " + ex.Message); return(null); } }
public static void ShowPopupContainer() { if (popupContainer != null) { return; } popupContainer = new PopupContainer(); // This code is copied from ShowSimpleNotification, todo: move to method int position_x = 0, position_y = 0; Screen screen; Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { screen = Screen.FromControl(MainForm.mainForm); } else { screen = Screen.FromHandle(tibia_process.MainWindowHandle); } int simpleX = SettingsManager.getSettingInt("SimpleNotificationXOffset"); int simpleY = SettingsManager.getSettingInt("SimpleNotificationYOffset"); int xOffset = simpleX < 0 ? 30 : simpleX; int yOffset = simpleY < 0 ? 30 : simpleY; int anchor = SettingsManager.getSettingInt("SimpleNotificationAnchor"); int sign = 1; position_y = screen.WorkingArea.Bottom - yOffset - popupContainer.Height; switch (anchor) { case 0: case 1: // Top sign = -1; position_y = screen.WorkingArea.Top + yOffset; break; case 2: default: // Bottom break; } switch (anchor) { case 0: case 2: // Left position_x = screen.WorkingArea.Left + xOffset; break; case 1: default: // Right position_x = screen.WorkingArea.Right - popupContainer.Width - notificationSpacing - xOffset; break; } popupContainer.StartPosition = FormStartPosition.Manual; popupContainer.SetDesktopLocation(position_x, position_y); popupContainer.UpsideDown = sign > 0; popupContainer.Show(); }
public static void ShowSimpleNotification(SimpleNotification f) { int position_x = 0, position_y = 0; Screen screen; Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { screen = Screen.FromControl(MainForm.mainForm); } else { screen = Screen.FromHandle(tibia_process.MainWindowHandle); } int simpleX = SettingsManager.getSettingInt("SimpleNotificationXOffset"); int simpleY = SettingsManager.getSettingInt("SimpleNotificationYOffset"); int xOffset = simpleX < 0 ? 30 : simpleX; int yOffset = simpleY < 0 ? 30 : simpleY; int anchor = SettingsManager.getSettingInt("SimpleNotificationAnchor"); int sign = 1; int basePosition = screen.WorkingArea.Bottom - yOffset; int startX = 0; switch (anchor) { case 0: case 1: // Top sign = -1; basePosition = screen.WorkingArea.Top + yOffset; break; case 2: default: // Bottom break; } switch (anchor) { case 0: case 2: // Left position_x = screen.WorkingArea.Left + xOffset; startX = position_x - (f.Width + notificationSpacing); break; case 1: default: // Right position_x = screen.WorkingArea.Right - f.Width - notificationSpacing - xOffset; startX = position_x + f.Width + notificationSpacing; break; } foreach (SimpleNotification notification in notificationStack) { basePosition -= sign * (notification.Height + notificationSpacing); } position_y = basePosition - sign * f.Height; f.StartPosition = FormStartPosition.Manual; if (!SettingsManager.getSettingBool("EnableSimpleNotificationAnimation")) { startX = position_x; } f.SetDesktopLocation(startX, position_y); f.targetPositionX = position_x; f.targetPositionY = position_y; f.FormClosed += simpleNotificationClosed; notificationStack.Add(f); f.TopMost = true; f.Show(); }
public static void ShowNotification(NotificationForm f, string command, string screenshot_path = "") { if (f == null) { return; } if (screenshot_path == "") { TibialyzerCommand cmd = new TibialyzerCommand(command); command_stack.Push(cmd); f.command = cmd; } f.Visible = false; int richX = -1; int richY = -1; int anchor = 0; int duration = 5; int group = 0; for (int it = 0; it < Constants.NotificationTypeObjects.Count; it++) { if (f.GetType() == Constants.NotificationTypeObjects[it]) { string settingObject = Constants.NotificationTypes[it].Replace(" ", ""); richX = SettingsManager.getSettingInt(settingObject + "XOffset"); richY = SettingsManager.getSettingInt(settingObject + "YOffset"); anchor = SettingsManager.getSettingInt(settingObject + "Anchor"); duration = SettingsManager.getSettingInt(settingObject + "Duration"); group = Math.Min(Math.Max(SettingsManager.getSettingInt(settingObject + "Group"), 0), 9); break; } } f.notificationDuration = duration; f.LoadForm(); if (screenshot_path != "") { Bitmap bitmap = new Bitmap(f.Width, f.Height); f.DrawToBitmap(bitmap, new Rectangle(0, 0, f.Width, f.Height)); foreach (Control c in f.Controls) { c.DrawToBitmap(bitmap, new Rectangle(new Point(Math.Min(Math.Max(c.Location.X, 0), f.Width), Math.Min(Math.Max(c.Location.Y, 0), f.Height)), c.Size)); } bitmap.Save(screenshot_path); bitmap.Dispose(); f.Dispose(); return; } if (NotificationFormGroups[group] != null) { NotificationFormGroups[group].close(); } int position_x = 0, position_y = 0; Screen screen; Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { screen = Screen.FromControl(MainForm.mainForm); } else { screen = Screen.FromHandle(tibia_process.MainWindowHandle); } int xOffset = richX == -1 ? 30 : richX; int yOffset = richY == -1 ? 30 : richY; switch (anchor) { case 3: position_x = screen.WorkingArea.Right - xOffset - f.Width; position_y = screen.WorkingArea.Bottom - yOffset - f.Height; break; case 2: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Bottom - yOffset - f.Height; break; case 1: position_x = screen.WorkingArea.Right - xOffset - f.Width; position_y = screen.WorkingArea.Top + yOffset; break; default: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Top + yOffset; break; } f.StartPosition = FormStartPosition.Manual; f.SetDesktopLocation(position_x, position_y); f.TopMost = true; f.Show(); NotificationFormGroups[group] = f; }