public void DoSendKey(byte keyCode) { string sendThis = string.Empty; switch (keyCode) { case 40: //KeyArrowDown sendThis = "{DOWN}"; break; case 37: //KeyArrowLeft sendThis = "{LEFT}"; break; case 39: //KeyArrowRight: sendThis = "{RIGHT}"; break; case 38: //KeyArrowUp: sendThis = "{UP}"; break; case 46: //KeyDelete: sendThis = "{DELETE}"; break; case 17: //KeyEscape: sendThis = "{ESC}"; break; case 112: //KeyF1: sendThis = "{F1}"; break; case 113: //KeyF2: sendThis = "{F2}"; break; case 114: //KeyF3: sendThis = "{F3}"; break; case 115: //KeyF4: sendThis = "{F4}"; break; case 116: //KeyF5: sendThis = "{F5}"; break; case 117: //KeyF6: sendThis = "{F6}"; break; case 118: //KeyF7: sendThis = "{F7}"; break; case 119: //KeyF8: sendThis = "{F8}"; break; case 120: //KeyF9: sendThis = "{F9}"; break; case 121: //KeyF10: sendThis = "{F10}"; break; case 122: //KeyF11: sendThis = "{F11}"; break; case 123: //KeyF12: sendThis = "{F12}"; break; default: sendThis = Convert.ToChar(keyCode).ToString(); break; } SendKeys.SendWait(sendThis); }
public void execute() { //Console.WriteLine("spool,{0}", _spoolStr.Length); if (_spoolStr.Length == 0) { return; } int startIndex = _spoolStr.IndexOf(startStr); //"{" int endIndex = _spoolStr.IndexOf(endStr); //"}" if (startIndex == -1 || endIndex == -1) { return; } string result = _spoolStr.Substring(startIndex + 1, endIndex - 1); if (_spoolStr.Length > endIndex + 1) { _spoolStr = _spoolStr.Substring(endIndex + 1); } else { _spoolStr = ""; } string[] keys = result.Split(separatorStr.ToCharArray()); if (keys[0] == "key") { //Console.WriteLine(keys[1]); SendKeys.SendWait(escapeSendableChar(keys[1])); } else if (keys[0] == "xy") { if (keys.Length == 3) { // http://dobon.net/vb/dotnet/system/cursorposition.html // クライアント座標を画面座標に変換する System.Drawing.Point mp = new System.Drawing.Point(); mp.X = (int)(float.Parse(keys[1]) * screenWidth); mp.Y = (int)(float.Parse(keys[2]) * screenHeight); //マウスポインタの位置を設定する System.Windows.Forms.Cursor.Position = mp; //Console.WriteLine(mp.ToString()); } } else if (keys[0] == "ml" || keys[0] == "mr") { // マウス操作実行用のデータ const int num = 2; INPUT[] inp = new INPUT[num]; inp[0].type = INPUT_MOUSE; inp[1].type = INPUT_MOUSE; if (keys[0] == "ml") { inp[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN; inp[1].mi.dwFlags = MOUSEEVENTF_LEFTUP; } else { inp[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; inp[1].mi.dwFlags = MOUSEEVENTF_RIGHTUP; } inp[0].mi.dx = 0; inp[0].mi.dy = 0; inp[0].mi.mouseData = 0; inp[0].mi.dwExtraInfo = 0; inp[0].mi.time = 0; inp[1].mi.dx = 0; inp[1].mi.dy = 0; inp[1].mi.mouseData = 0; inp[1].mi.dwExtraInfo = 0; inp[1].mi.time = 0; // マウス操作実行 SendInput(1, ref inp[0], Marshal.SizeOf(inp[0])); SendInput(1, ref inp[1], Marshal.SizeOf(inp[1])); } }
/// <summary> /// Handles keypresses, determines what element is being highlighted /// and send the selected element to the game window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hoverTimer_Tick(object sender, EventArgs e) { if (!Keyboard.GetKeyStates((Key)_settings.HotKey).HasFlag(KeyStates.Down)) { if (Visibility != Visibility.Hidden) { //Selection has ended. Now acting Visibility = Visibility.Hidden; if (_lastChosenPie == null) { return; } _lastChosenPie.ReactToMouseLeave(); SendKeys.SendWait("{ENTER}"); Clipboard.SetText(_lastChosenPie.FullText); SendKeys.SendWait("^v"); SendKeys.SendWait("{ENTER}"); } return; } if (Visibility == Visibility.Hidden) { Visibility = Visibility.Visible; User32.SetCursorPosition(Left + _chatWheelCenterLocation.X, Top + _chatWheelCenterLocation.Y); } //TODO: Clean up this area var mousePos = User32.GetMousePosition(); var mouseOffseted = mousePos; mouseOffseted.Offset(Left * -1, Top * -1); Console.WriteLine(mouseOffseted); if (_previousValidPos.X == 0) { _previousValidPos = _chatWheelCenterLocation; } //Recenter if too far away var distance = Utils.Distance2D(_chatWheelCenterLocation, mouseOffseted); if (distance > 90) { User32.SetCursorPosition((int)_previousValidPos.X, (int)_previousValidPos.Y); } else { _previousValidPos = mousePos; } //Ignore nodes if mouse is in the center of the circle if (distance < 30) { if (_lastChosenPie != null) { _lastChosenPie.ReactToMouseLeave(); } _lastChosenPie = null; return; } //Todo: optimize by generating a list of piepieces foreach (var obj in chatWheelCanvas.Children) { if ((obj.GetType() != typeof(PiePiece))) { continue; } var pie = obj as PiePiece; if (pie.IsAngleOnControl( Utils.FindAngleBetweenPoints (new Point(_chatWheelCenterLocation.X, 0), _chatWheelCenterLocation, mouseOffseted))) { pie.ReactToMouseEnter(); _lastChosenPie = pie; } else { pie.ReactToMouseLeave(); } } }
private void btnGenerate_Click(object sender, EventArgs e) { int inttype = 0, introw = 0;; string strBranchID; //DateTime dteStartDate; if (radItemWise.Checked == true) { inttype = 0; } else { inttype = 1; } DG.Rows.Clear(); for (int intcol = 0; intcol < DG.ColumnCount; intcol++) { DG.Columns.RemoveAt(intcol); intcol--; } strBranchID = Utility.gstrGetBranchID(strComID, uctxtbranchName.Text); DG.RowTemplate.Height = 40; if (radItemWise.Checked == true) { DG.Columns.Add(Utility.Create_Grid_Column("Ledger Name", "Ledger Name", 100, false, DataGridViewContentAlignment.TopLeft, true)); DG.Columns.Add(Utility.Create_Grid_Column("MPO Name", "MPO Name", 300, true, DataGridViewContentAlignment.TopLeft, true)); } else { DG.Columns.Add(Utility.Create_Grid_Column("Ledger Name", "Ledger Name", 100, false, DataGridViewContentAlignment.TopLeft, true)); DG.Columns.Add(Utility.Create_Grid_Column("MPO Name", "MPO Name", 300, true, DataGridViewContentAlignment.TopLeft, true)); } List <StockItem> oogrp; if (m_action == 1) { oogrp = invms.mFillStockItemListNew(strComID, inttype, 1).ToList(); } else { oogrp = invms.mFillStockItemListNewEdit(strComID, inttype, txtOldKey.Text.ToString()).ToList(); } if (oogrp.Count > 0) { foreach (StockItem osockItem in oogrp) { if (inttype == 0) { DG.Columns.Add(Utility.Create_Grid_Column(osockItem.strItemName, osockItem.strItemName, 100, true, DataGridViewContentAlignment.TopLeft, false)); } else { DG.Columns.Add(Utility.Create_Grid_Column(osockItem.strItemCategory, osockItem.strItemCategory, 100, true, DataGridViewContentAlignment.TopLeft, false)); } } } List <Invoice> objinv = invms.mfillPartyNameNew(strComID, strBranchID, false, Utility.gstrUserName, 0, "", "").ToList(); if (objinv.Count > 0) { foreach (Invoice inv in objinv) { DG.Rows.Add(); DG[0, introw].Value = inv.strLedgerName; DG[1, introw].Value = inv.strMereString; introw += 1; } DG.AllowUserToAddRows = false; } DG.DefaultCellStyle.WrapMode = DataGridViewTriState.True; DG.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; DG.Columns[1].DefaultCellStyle.WrapMode = DataGridViewTriState.True; DG.Columns[0].DefaultCellStyle.BackColor = Color.Bisque; DG.Columns[1].DefaultCellStyle.BackColor = Color.Bisque; SendKeys.Send("{tab}"); }
private void startButton_Click(object sender, EventArgs e) { int coolDown = (int)coolDownRaw.Value; eStop = 0; progressPart = 0; GetProgressWhole(); startButton.Enabled = false; stopButton.Enabled = true; saveButton.Enabled = false; filePathTextBox.ReadOnly = true; progressBar.Maximum = progressWhole; richTextBox3.Text = "Progress"; if (string.IsNullOrWhiteSpace(filePathTextBox.Text)) { consoleDisplay.Items.Add("Error: No set file location"); _swLog.WriteLine("Error: No set file location"); _swLog.Flush(); return; } Thread.Sleep(1500); consoleDisplay.Items.Add("Info: Running..."); _swLog.WriteLine("Info: Running..."); _swLog.Flush(); var list = new List <string>(); string filePath = filePathTextBox.Text.ToString(); using (var sr = new StreamReader(filePath)) { string line; while ((line = sr.ReadLine()) != null) { if (eStop != 1) { list.Add(line); SendKeys.SendWait("{ENTER}"); consoleDisplay.Items.Add("Sending: " + line); _swLog.WriteLine("Sending: " + line); _swLog.Flush(); SendKeys.SendWait(line + "{ENTER}"); Thread.Sleep(Convert.ToInt32(coolDown)); progressPart++; progressBar.Value = progressPart; consoleDisplay.EnsureVisible(consoleDisplay.Items.Count - 1); } else { StopProgram(); return; } } StopProgram(); richTextBox3.Text = "Done"; } }
private void btnCheck_Click(object sender, EventArgs e) { //Store Delay Times int pageDelay, refreshDelay; //Convert Text Boxes Delay to Numbers int.TryParse(txtPageDelay.Text, out pageDelay); int.TryParse(txtRefreshDelay.Text, out refreshDelay); //Convert from normal seconds to milliseconds pageDelay *= 1000; refreshDelay *= 1000; //Check Button States if (check == false) { check = true; lblStatus.ForeColor = Color.Green; lblStatus.Text = "Status: Started"; } else { check = false; lblStatus.ForeColor = Color.Red; lblStatus.Text = "Status: Stopped"; } //Loop Until User Wants to Stop while (check) { Application.DoEvents(); Process.Start("chrome.exe", txtURL.Text); string url = ""; System.Threading.Thread.Sleep(pageDelay); foreach (Process process in Process.GetProcessesByName("chrome")) { url = GetChromeUrl(process); if (url == null) { continue; } else { url = "http://" + url; break; } } if (url == txtURL.Text) { System.Media.SystemSounds.Beep.Play(); lblStatus.ForeColor = Color.Red; lblStatus.Text = "Status: Stopped"; check = false; } else { //check url bar string urlc = url.Substring(7); if (urlc == "https://app.spare5.com/fives/tasks") { SendKeys.Send("^w"); } System.Threading.Thread.Sleep(refreshDelay); } } }
private void MontaGrid() { string TipoDados = ""; int[] ColunasValores; int[] ColunasDatas; ColunasValores = new int[50]; ColunasDatas = new int[50]; int x = 0; int xTamanho = 0; // Monta Cabeçario da Listview if (Controle) { for (x = 0; x < Campos.Length; x++) { if (Titulos == null) { listView1.Columns.Add(Campos[x].ToString(), 100, HorizontalAlignment.Left); } else { listView1.Columns.Add(Titulos[x].ToString(), 100, HorizontalAlignment.Left); } cmbPesquisa.Items.Add(Campos[x].ToString().ToUpper()); // adicionar os campos na combobox de pesquisa } if (x > 0 && x < 2) { cmbPesquisa.SelectedIndex = x - 1; } else { cmbPesquisa.SelectedIndex = 1; } } int cols = listView1.Columns.Count; x = Campos.Length; int y = 0; TipoDados = ""; string Mascara; xTamanho = 0; Mascara = ""; while (dr.Read()) { TipoDados = dr.GetDataTypeName(0).ToString(); //MessageBox.Show(TipoDados.ToString()); if (TipoDados.ToString().ToUpper() == "INT") { xTamanho = dr[Campos[0]].ToString().Length; item = new ListViewItem(dr[Campos[0]].ToString().PadLeft(6 - xTamanho, '0')); } else { item = new ListViewItem(dr[Campos[0]].ToString()); } string xConteudo = ""; for (y = 1; y < x; y++) { Mascara = ""; TipoDados = dr.GetDataTypeName(y).ToString(); // MessageBox.Show(TipoDados.ToString()); if (TipoDados.ToString() == "Date" || TipoDados == "DateTime") { Mascara = "dd/MM/yyyy"; ColunasDatas[y] = y; } xTamanho = dr[Campos[0]].ToString().Length; xConteudo = dr[Campos[y]].ToString(); if (y == 1) { item.SubItems.Add(dr[Campos[y]].ToString().PadRight(50 - xTamanho, ' ')); } else { if (TipoDados.ToString().ToUpper() == "DECIMAL") { item.SubItems.Add(dr[Campos[y]].ToString().PadLeft(02, 'x')); ColunasValores[y] = y; } else if (TipoDados.ToString().ToUpper() == "DATE") { item.SubItems.Add(DateTime.Parse(dr[Campos[y]].ToString()).ToString("dd/MM/yyyy")); } else { // outros campos sendo preenchidos item.SubItems.Add(dr[Campos[y]].ToString()); } } } listView1.Items.Add(item); } int tamColunas = 0; if (tamColunas < 150) { tamColunas = 150; } if (Controle) { for (y = 1; y < cols; y++) { listView1.AutoResizeColumn(y, ColumnHeaderAutoResizeStyle.HeaderSize); listView1.AutoResizeColumn(y, ColumnHeaderAutoResizeStyle.ColumnContent); if (listView1.Columns[y].Width > 600) { tamColunas = tamColunas + 600; } else { if (y == ColunasValores[y]) // colunas de valores { listView1.Columns[y].TextAlign = HorizontalAlignment.Right; listView1.Columns[y].Width = 100; tamColunas = tamColunas + listView1.Columns[y].Width; } else { // outras colunas // colunas com tamanho menor que 100, ficam com tamanho de 100 if (listView1.Columns[y].Width < 100) { listView1.Columns[y].Width = 100; } tamColunas = tamColunas + listView1.Columns[y].Width; } } } for (y = 1; y < cols; y++) { Larguras.Add(listView1.Columns[y].Width); } Controle = false; listView1.Width = tamColunas - 45; } else { tamColunas = 150; for (y = 1; y < cols; y++) { listView1.Columns[y].Width = int.Parse(Larguras[y - 1].ToString()); tamColunas += listView1.Columns[y].Width; } } // int z1 = listView1.Columns[cols - 1].Width; listView1.Refresh(); listView1.Focus(); SendKeys.Send("{HOME}"); //this.Width = 800; // centraliza a tela depois de ter a chamado this.Width = tamColunas; this.WindowState = FormWindowState.Normal; this.StartPosition = FormStartPosition.Manual; this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2); this.Refresh(); //this.StartPosition = FormStartPosition.CenterScreen; dr.Close(); conn.Close(); }
private void Spacekey_Click(object sender, EventArgs e) { SendKeys.Send("{ }"); LeftShiftkey.Checked = false; RightShiftkey.Checked = false; }
private void Enter2key_Click(object sender, EventArgs e) { SendKeys.Send("{ENTER}"); }
private void mabn4_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode==Keys.Enter) SendKeys.Send("{Tab}"); }
protected override void WndProc(ref Message m) { //F1 int FirstHotkeyId = 1; int FirstHotKeyKey = (int)Keys.F1; if (checkBox2.Checked) { RegisterHotKey(this.Handle, FirstHotkeyId, 0x0000, FirstHotKeyKey); } else { UnregisterHotKey(this.Handle, FirstHotkeyId); } //F2 int SecondHotkeyId = 2; int SecondHotKeyKey = (int)Keys.F2; if (checkBox3.Checked) { RegisterHotKey(this.Handle, SecondHotkeyId, 0x0000, SecondHotKeyKey); } else { UnregisterHotKey(this.Handle, SecondHotkeyId); } //F3 int TerceiraHotkeyId = 3; int TerceiraHotKeyKey = (int)Keys.F3; if (checkBox4.Checked) { RegisterHotKey(this.Handle, TerceiraHotkeyId, 0x0000, TerceiraHotKeyKey); } else { UnregisterHotKey(this.Handle, TerceiraHotkeyId); } //F4 int QuartoHotkeyId = 4; int QuartoHotKeyKey = (int)Keys.F4; if (checkBox5.Checked) { RegisterHotKey(this.Handle, QuartoHotkeyId, 0x0000, QuartoHotKeyKey); } else { UnregisterHotKey(this.Handle, QuartoHotkeyId); } //F5 int QuintoHotkeyId = 5; int QuintoHotKeyKey = (int)Keys.F5; if (checkBox6.Checked) { RegisterHotKey(this.Handle, QuintoHotkeyId, 0x0000, QuintoHotKeyKey); } else { UnregisterHotKey(this.Handle, QuintoHotkeyId); } //F6 int SextoHotkeyId = 6; int SextoHotKeyKey = (int)Keys.F6; if (checkBox7.Checked) { RegisterHotKey(this.Handle, SextoHotkeyId, 0x0000, SextoHotKeyKey); } else { UnregisterHotKey(this.Handle, SextoHotkeyId); } //F7 int SetimoHotkeyId = 7; int SetimoHotKeyKey = (int)Keys.F7; if (checkBox8.Checked) { RegisterHotKey(this.Handle, SetimoHotkeyId, 0x0000, SetimoHotKeyKey); } else { UnregisterHotKey(this.Handle, SetimoHotkeyId); } //F8 int OitavoHotkeyId = 8; int OitavoHotKeyKey = (int)Keys.F8; if (checkBox9.Checked) { RegisterHotKey(this.Handle, OitavoHotkeyId, 0x0000, OitavoHotKeyKey); } else { UnregisterHotKey(this.Handle, OitavoHotkeyId); } //F9 int NonoHotkeyId = 9; int NovoHotKeyKey = (int)Keys.F9; if (checkBox10.Checked) { RegisterHotKey(this.Handle, NonoHotkeyId, 0x0000, NovoHotKeyKey); } else { UnregisterHotKey(this.Handle, NonoHotkeyId); } //F10 int DecimoHotkeyId = 10; int DecimHotKeyKey = (int)Keys.F10; if (checkBox11.Checked) { RegisterHotKey(this.Handle, DecimoHotkeyId, 0x0000, DecimHotKeyKey); } else { UnregisterHotKey(this.Handle, DecimoHotkeyId); } //F11 int DecimoprimHotkeyId = 11; int DecimpriHotKeyKey = (int)Keys.F11; if (checkBox12.Checked) { RegisterHotKey(this.Handle, DecimoprimHotkeyId, 0x0000, DecimpriHotKeyKey); } else { UnregisterHotKey(this.Handle, DecimoprimHotkeyId); } //HOME int DecimosegHotkeyId = 13; int DecimsegHotKeyKey = (int)Keys.Home; if (checkBox13.Checked) { RegisterHotKey(this.Handle, DecimosegHotkeyId, 0x0000, DecimsegHotKeyKey); } else { UnregisterHotKey(this.Handle, DecimosegHotkeyId); } //INSERT int DecimotercHotkeyId = 12; int DecimtercHotKeyKey = (int)Keys.Insert; if (checkBox14.Checked) { RegisterHotKey(this.Handle, DecimotercHotkeyId, 0x0000, DecimtercHotKeyKey); } else { UnregisterHotKey(this.Handle, DecimotercHotkeyId); } //END int DecimoQUacHotkeyId = 14; int DecimQUAHotKeyKey = (int)Keys.End; if (checkBox15.Checked) { RegisterHotKey(this.Handle, DecimoQUacHotkeyId, 0x0000, DecimQUAHotKeyKey); } else { UnregisterHotKey(this.Handle, DecimoQUacHotkeyId); } // 5. Catch when a HotKey is pressed ! if (m.Msg == 0x0312) { int id = m.WParam.ToInt32(); // MessageBox.Show(string.Format("Hotkey #{0} pressed", id)); // 6. Handle what will happen once a respective hotkey is pressed switch (id) { //F1 case 1: SendKeys.Send(textBox1.Text); break; //F2 case 2: Clipboard.SetText(textBox2.Text); SendKeys.Send("^v"); break; //F3 case 3: Clipboard.SetText(textBox3.Text); SendKeys.Send("^v"); break; //F4 case 4: Clipboard.SetText(textBox4.Text); SendKeys.Send("^v"); break; //F5 case 5: Clipboard.SetText(textBox5.Text); SendKeys.Send("^v"); break; //F6 case 6: Clipboard.SetText(textBox6.Text); SendKeys.Send("^v"); break; //F7 case 7: Clipboard.SetText(textBox7.Text); SendKeys.Send("^v"); break; //F8 case 8: Clipboard.SetText(textBox8.Text); SendKeys.Send("^v"); break; //F9 case 9: Clipboard.SetText(textBox9.Text); SendKeys.Send("^v"); break; //F10 case 10: Clipboard.SetText(textBox10.Text); SendKeys.Send("^v"); break; //F11 case 11: Clipboard.SetText(textBox11.Text); SendKeys.Send("^v"); break; //12 case 12: Clipboard.SetText(textBox12.Text); SendKeys.Send("^v"); break; case 13: Clipboard.SetText(textBox13.Text); SendKeys.Send("^v"); break; case 14: Clipboard.SetText(textBox14.Text); SendKeys.Send("^v"); break; } } base.WndProc(ref m); }
private void portRead(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { //Initialize a buffer to hold the received data byte[] buffer = new byte[serialPort.ReadBufferSize]; //There is no accurate method for checking how many bytes are read //unless you check the return from the Read method int bytesRead = serialPort.Read(buffer, 0, buffer.Length); //For the example assume the data we are received is ASCII data. tString += Encoding.ASCII.GetString(buffer, 0, bytesRead) + "\r\n"; //Check if string contains the terminator //if (tString.IndexOf((char)_terminator) > -1) // { //If tString does contain terminator we cannot assume that it is the last character received // string workingString = tString.Substring(0, tString.IndexOf((char)_terminator)); //Remove the data up to the terminator from tString //tString = tString.Substring(tString.IndexOf((char)_terminator)); //Do something with workingString int read; List <string> msg = tString.ToString().Split("\r\n".ToCharArray()).ToList(); msg.RemoveAll(isBlank); bool succeed = Int32.TryParse(msg[msg.Count - 1], out read); if (succeed) { switch (read) { case 0: SendKeys.SendWait(textBox1.Text); Console.WriteLine("0 Pressed, Sending \"" + textBox1.Text + "\" To the current application"); break; case 1: SendKeys.SendWait(textBox2.Text); Console.WriteLine("1 Pressed, Sending \"" + textBox2.Text + "\" To the current application"); break; case 2: SendKeys.SendWait(textBox3.Text); Console.WriteLine("2 Pressed, Sending \"" + textBox3.Text + "\" To the current application"); break; case 3: SendKeys.SendWait(textBox4.Text); Console.WriteLine("3 Pressed, Sending \"" + textBox4.Text + "\" To the current application"); break; case 4: SendKeys.SendWait(textBox5.Text); Console.WriteLine("4 Pressed, Sending \"" + textBox5.Text + "\" To the current application"); break; case 5: SendKeys.SendWait(textBox6.Text); Console.WriteLine("5 Pressed, Sending \"" + textBox6.Text + "\" To the current application"); break; case 6: SendKeys.SendWait(textBox7.Text); Console.WriteLine("6 Pressed, Sending \"" + textBox7.Text + "\" To the current application"); break; case 7: SendKeys.SendWait(textBox8.Text); Console.WriteLine("7 Pressed, Sending \"" + textBox8.Text + "\" To the current application"); break; case 8: SendKeys.SendWait(textBox9.Text); Console.WriteLine("8 Pressed, Sending \"" + textBox9.Text + "\" To the current application"); break; case 9: SendKeys.SendWait(textBox10.Text); Console.WriteLine("9 Pressed, Sending \"" + textBox10.Text + "\" To the current application"); break; default: Console.WriteLine("No match"); break; } } else { Console.WriteLine("Error, Data not read"); } // } }
public void KeyShortcut(string parameter) { /* * Added by : Joshua Miller * How to use it : * - To seperate keys please us '+' (to use '+' do {ADD}) * - Things like ctrl will be converted to control key */ // Split up commands char splitChar = '+'; String[] keyCombinationInput = parameter.Split(splitChar); // Will be added onto to make what to type String keyCombinationPress = ""; // Put commands into correct form for (int index = 0; index < keyCombinationInput.Length; index++) { // Get current command String command = keyCombinationInput[index]; // If not empty if (command != "") { // If one character (not command) if (command.Length == 1) { // Add to the out keyCombinationPress = keyCombinationPress + command.ToLower(); } else { // If it is a command (probably) // Check if it is a possible command and needs to be changed bool foundYet = false; for (int countInCharacterArray = 0; countInCharacterArray < charactersType.GetLength(0) && foundYet == false; countInCharacterArray++) { String characterTestNow = charactersType[countInCharacterArray, 0]; if (Equals(command.ToUpper(), characterTestNow)) { keyCombinationPress += charactersType[countInCharacterArray, 1]; foundYet = true; } else if (Equals(command.ToUpper(), charactersType[countInCharacterArray, 1])) { keyCombinationPress += charactersType[countInCharacterArray, 1]; foundYet = true; } } if (foundYet == false) { MainProgram.DoDebug("KeyShortcut Action - Warning: A command " + command.ToUpper() + " was not identified, please be weary as this may not work"); MainProgram.DoDebug("KeyShortcut Action - Warning: Adding Anyway"); keyCombinationPress += command; } } } else { MainProgram.DoDebug("KeyShortcut Action - Warning: A character inside the paramater was blank"); } } // Is it testing? if (MainProgram.testingAction) { successMessage = ("Simulated sending the combination: " + keyCombinationPress); } else { // Try pressing keys bool keysPressedSuccess = true; try { SendKeys.SendWait(keyCombinationPress); } catch (ArgumentException) { Error("Key combination is not valid"); keysPressedSuccess = false; } if (keysPressedSuccess) { successMessage = ("Sending the combination: " + keyCombinationPress); } } }
public async Task <int> AddCardToDeck(Card card, List <HearthMirror.Objects.Card> collection) { var inCollection = collection.Where(x => x.Id == card.Id).ToList(); if (!inCollection.Any()) { return(card.Count); } var golden = inCollection.FirstOrDefault(x => x.Premium)?.Count ?? 0; var normal = inCollection.FirstOrDefault(x => !x.Premium)?.Count ?? 0; if (Config.Instance.ExportForceClear) { await ClearSearchBox(); } await _mouse.ClickOnPoint(_info.SearchBoxPos); await Task.Delay(Config.Instance.DeckExportDelay); if (Config.Instance.ExportPasteClipboard || !Helper.LatinLanguages.Contains(Config.Instance.SelectedLanguage)) { Clipboard.SetText(GetSearchString(card)); SendKeys.SendWait("^{v}"); } else { SendKeys.SendWait(GetSearchString(card)); } SendKeys.SendWait("{ENTER}"); Log.Info($"Adding {card}, in collection: {normal} normal, {golden} golden"); await Task.Delay(Config.Instance.DeckExportDelay * 2); if (Config.Instance.PrioritizeGolden && golden > 0) { if (normal > 0) { await ClickOnCard(Right); } else { await ClickOnCard(Left); } if (card.Count == 2) { if (golden > 1 && normal > 1) { await ClickOnCard(Right); } else { await ClickOnCard(Left); } } } else { await ClickOnCard(Left); if (card.Count == 2) { if (normal + golden < 2) { return(1); } if (normal == 1) { await ClickOnCard(Right); } else { await ClickOnCard(Left); } } } return(0); }
public static void HandleGameStart(string playerHero) { //avoid new game being started when jaraxxus is played if (!Game.IsInMenu) { return; } Game.PlayingAs = playerHero; Logger.WriteLine("Game start"); if (Config.Instance.FlashHsOnTurnStart) { User32.FlashHs(); } if (Config.Instance.BringHsToForeground) { User32.BringHsToForeground(); } if (Config.Instance.KeyPressOnGameStart != "None" && Helper.MainWindow.EventKeys.Contains(Config.Instance.KeyPressOnGameStart)) { SendKeys.SendWait("{" + Config.Instance.KeyPressOnGameStart + "}"); Logger.WriteLine("Sent keypress: " + Config.Instance.KeyPressOnGameStart); } var selectedDeck = Helper.MainWindow.DeckPickerList.SelectedDeck; if (selectedDeck != null) { Game.SetPremadeDeck((Deck)selectedDeck.Clone()); } Game.IsInMenu = false; Game.Reset(); //select deck based on hero if (!string.IsNullOrEmpty(playerHero)) { if (!Game.IsUsingPremade || !Config.Instance.AutoDeckDetection) { return; } if (selectedDeck == null || selectedDeck.Class != Game.PlayingAs) { var classDecks = Helper.MainWindow.DeckList.DecksList.Where(d => d.Class == Game.PlayingAs).ToList(); if (classDecks.Count == 0) { Logger.WriteLine("Found no deck to switch to", "HandleGameStart"); } else if (classDecks.Count == 1) { Helper.MainWindow.DeckPickerList.SelectDeck(classDecks[0]); Logger.WriteLine("Found deck to switch to: " + classDecks[0].Name, "HandleGameStart"); } else if (Helper.MainWindow.DeckList.LastDeckClass.Any(ldc => ldc.Class == Game.PlayingAs)) { var lastDeckName = Helper.MainWindow.DeckList.LastDeckClass.First(ldc => ldc.Class == Game.PlayingAs).Name; Logger.WriteLine("Found more than 1 deck to switch to - last played: " + lastDeckName, "HandleGameStart"); var deck = Helper.MainWindow.DeckList.DecksList.FirstOrDefault(d => d.Name == lastDeckName); if (deck != null) { Helper.MainWindow.DeckPickerList.SelectDeck(deck); Helper.MainWindow.UpdateDeckList(deck); Helper.MainWindow.UseDeck(deck); } } } } }
private void button1_Click(object sender, EventArgs e) { SendKeys.Send("{BACKSPACE}"); }
//TODO: Currently we are iterating and clicking over a tab width to locate a tab. This adds unnecessary click events. Fix it to avoid additional click public void SendKeysByLibrary(AutomationElement element, string value) { element.SetFocus(); SendKeys.SendWait(value); }
private void ESCkey_Click(object sender, EventArgs e) { SendKeys.Send("{ESC}"); }
private void timer1_Tick(object sender, EventArgs e) { SendKeys.Send(textBox1.Text); SendKeys.Send("{Enter}"); }
private void Win2key_Click(object sender, EventArgs e) { SendKeys.Send("{HOME}"); }
public void FocusContent() { btnForward.Focus(); SendKeys.Send("\t"); }
private void dtpDOB_Enter(object sender, EventArgs e) { SendKeys.Send("%{DOWN}"); }
private void button_Click(object sender, EventArgs e) { SendKeys.Send((sender as Button).Tag.ToString()); }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtID.Text.Trim())) { re1 = MessageBox.Show("Please input ID...", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtID.Focus(); return; //stop running } if (string.IsNullOrEmpty(txtName.Text.Trim())) { re1 = MessageBox.Show("Please input name...", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Focus(); return; //stop running } if (rdoF.Checked == false && rdoM.Checked == false) { re1 = MessageBox.Show("Please select gender..."); rdoF.Focus(); return; } if (dtpDOB.CustomFormat == " ") { re1 = MessageBox.Show("Please select birthdate..."); dtpDOB.Focus(); SendKeys.Send("%{DOWN}"); return; } if (string.IsNullOrEmpty(txtPos.Text.Trim())) { re1 = MessageBox.Show("Please input position...", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPos.Focus(); return; //stop running } if (string.IsNullOrEmpty(txtSal.Text.Trim())) { re1 = MessageBox.Show("Please input salary...", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSal.Focus(); return; //stop running } if (string.IsNullOrEmpty(txtAdd.Text.Trim())) { re1 = MessageBox.Show("Please input address...", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAdd.Focus(); return; //stop running } if (dtpHire.CustomFormat == " ") { re1 = MessageBox.Show("Please select birthdate...", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); dtpHire.Focus(); SendKeys.Send("%{DOWN}"); return; } if (string.IsNullOrEmpty(txtContact.Text.Trim())) { re1 = MessageBox.Show("Please input contact number...", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtContact.Focus(); return; //stop running } if (picEmp.Image == null) { re1 = MessageBox.Show("Please select an image..."); btnBrowse_Click(sender, e); } if (b == true) { Modify("InsertEmployee"); MessageBox.Show("Your data was saved...", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Modify("UpdateEmployee"); MessageBox.Show("Your data was updated...", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } //frmEmployee_Load(sender, e); myOper.OnOff(this, false); LoadData(); btnNew.Text = "New"; btnNew.Image = SaleInv.Properties.Resources.Plus_25; }
/// <summary> /// judShiListTxtKeyDown /// キー入力判定(テキストボックス) /// </summary> private void judShiListTxtKeyDown(object sender, KeyEventArgs e) { //キー入力情報によって動作を変える switch (e.KeyCode) { case Keys.Tab: break; case Keys.Left: break; case Keys.Right: break; case Keys.Up: break; case Keys.Down: break; case Keys.Delete: break; case Keys.Back: break; case Keys.Enter: //TABボタンと同じ効果 SendKeys.Send("{TAB}"); break; case Keys.F1: break; case Keys.F2: break; case Keys.F3: break; case Keys.F4: break; case Keys.F5: break; case Keys.F6: break; case Keys.F7: break; case Keys.F8: break; case Keys.F9: break; case Keys.F10: break; case Keys.F11: break; case Keys.F12: break; default: break; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e">Gesture event arguments.</param> private void OnGestureRecognized(object sender, GestureEventArgs e) { if (isPaused && e.GestureName == "WaveRight") { isPaused = false; gestureRecognized(this, e); return; } if (!isPaused && e.GestureName == "JoinedHands") { isPaused = true; gestureRecognized(this, e); return; } if (isPaused) { return; } switch (e.GestureName) { case "Menu": break; case "WaveRight": SendKeys.SendWait("{ESC}"); gestureRecognized(this, e); break; case "WaveLeft": break; case "JoinedHands": break; case "ZoomIn": break; case "ZoomOut": break; case "SwipeLeft": break; case "SwipeRight": SendKeys.SendWait("{ADD}"); remoScheduler.enterVolumeMode(); gestureRecognized(this, e); break; case "SwipeUp": if (!remoScheduler.canDoSwipeUp || interactionManager.isRightHandGripped) { return; } remoScheduler.swipeUpOccured(); gestureRecognized(this, e); break; case "SwipeDown": if (!remoScheduler.canDoSwipeDown || interactionManager.isRightHandGripped) { return; } remoScheduler.swipeDownOccured(); gestureRecognized(this, e); break; case "Click": if (interactionManager.isRightHandGripped) { return; } SendKeys.SendWait("{ENTER}"); gestureRecognized(this, e); break; default: break; } }
private void timer1_Tick(object sender, EventArgs e) { SendKeys.Send(richTextBox1.Text); SendKeys.Send("{ENTER}"); }
/// <summary> /// This property allows the user the ability to set the SelectAll property /// of the textbox directly without having to use the "tb" property. /// </summary> public void SelectAll() { //this.tb.SelectAll(); // Focus is at the end //SendKeys.Send("^{END}"); SendKeys.Send("^+{HOME}"); // Sound will be played if textbox is empty SendKeys.Send("^a"); }
private void pageDown() { dgvBill.Select(); SendKeys.Send("{PGDN}"); //SendKeys.Send("{PGUP}"); }
private void button1_Click(object sender, EventArgs e) { // Next Button // check if cursor already reached the end. if (richTextBox1.SelectionStart == richTextBox1.TextLength) { MessageBox.Show("Done! End of text reached!!!"); return; } // Use SetForegroundWindow & SendKeys instead of FindWindowEx & SendMessage if (processname == null) { MessageBox.Show("No Target Window Selected"); return; } Process p = Process.GetProcessesByName(processname).FirstOrDefault(); if (p != null) { // get selected text startread = richTextBox1.SelectionStart; endread = startread; while (endread < richTextBox1.TextLength && !stopset.Contains(richTextBox1.Text[endread].ToString())) { endread++; } while (endread + 1 < richTextBox1.TextLength && stopset.Contains(richTextBox1.Text[endread + 1].ToString())) { endread++; } // remove previous highlight richTextBox1.Select(prevstartread, prevendread - prevstartread + 1); richTextBox1.SelectionBackColor = Color.White; richTextBox1.SelectionColor = Color.Black; // highlight selected text richTextBox1.Select(startread, endread - startread + 1); richTextBox1.SelectionBackColor = Color.Blue; richTextBox1.SelectionColor = Color.White; prevstartread = startread; prevendread = endread; // copy text to clipboard Clipboard.SetText(richTextBox1.SelectedText); // send keys IntPtr h = p.MainWindowHandle; SetForegroundWindow(h); SendKeys.SendWait(richTextBox1.SelectedText); if (checkBox1.Checked) // Send ENTER { SendKeys.SendWait("{Enter}"); } richTextBox1.ScrollToCaret(); endread++; richTextBox1.SelectionStart = endread; while (endread < richTextBox1.TextLength && richTextBox1.Text[richTextBox1.SelectionStart].ToString() == "\n") { richTextBox1.SelectionStart = richTextBox1.SelectionStart + 1; } startread = richTextBox1.SelectionStart; progressBar1.Value = (int)Math.Round(Convert.ToDecimal(100 * richTextBox1.SelectionStart / richTextBox1.TextLength), MidpointRounding.AwayFromZero); label2.Text = richTextBox1.SelectionStart.ToString() + "/" + richTextBox1.TextLength.ToString(); } }