Skip to content

Instantly share code, notes, and snippets.

@mniak
Last active July 11, 2018 14:13
Show Gist options
  • Save mniak/854dbe107d3064bb0306c4aeab721066 to your computer and use it in GitHub Desktop.
Save mniak/854dbe107d3064bb0306c4aeab721066 to your computer and use it in GitHub Desktop.
SendKey scripts
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
public void TypeKeys(string text, bool trimNums=true) {
if (trimNums) {
text = Regex.Replace(text, "[^0-9]", "");
}
for (int i = 0; i < text.Length; i++) {
SendKeys.SendWait(text[i].ToString());
Thread.Sleep(50);
}
}
import SendKeys
import re
import time
def type(text, trimNums=True):
time.sleep(2)
if trimNums:
text = re.sub('[^0-9]', '', text)
for k in text:
SendKeys.SendKeys(k)
time.sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment