alias sendkeys { var %a = mIRCsendkeys $+ $ticks .comopen %a WScript.Shell if !$comerr { var %b = $com(%a,SendKeys,3,bstr,$1-) if (!%b) var %b = 2 .comclose %a return %b } return 0 } ; While learning to use /sendkeys, you may find it helpful to put a debug message at the beginning of the alias, similar to: ; echo 4 -s sendkeys cmd seen: $1- /* Simulating keystrokes with COM By qwerty (nousername@gmx.net) (documentation edited/enlarged by maroon minor alteration to alias by maroon) The following alias allows you to simulate keystrokes in mIRC, i.e. makes mIRC execute whatever commands would be executed by pressing the specified key(s). It does that by using the SendKeys method of the WshShell object. I know this is already possible with a dll (a lot of scripters know and use sendkeys.dll) but a few people were interested in this, so here it is. Usage: /sendkeys or $sendkeys(key combination) If used as an identifier, it returns: 0 if it fails to open the COM 1 if successful 2 if string contains invalid {symbol}, causes only string prior to that symbol to not be sent. Official Documentation: https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys(v=vs.110).aspx To open mirc-options from editbox: /sendkeys %o from script needs: sendkeys % $+ o or sendkeys $eval(%o,0) or sendkeys $chr(37) $+ o Most Alt+letter and Ctrl+letter requires lower-case letter. (Using %o is valid, %O is not). An exception is that ^v and ^V both generate Ctrl+V, which pastes the clipboard, and ^c and ^C copy into the clipboard. Note: You are sending KEYSTROKES not ASCII characters. For example, Ctrl+A through Ctrl+Z are aliases for $chr(1) through $chr(26). However, when you use /sendkeys to send Ctrl+V, you are sending the keystroke for pasting the clipboard, not $chr(22) which is the value created by pressing Ctrl+R for reverse colors. A lot depends on the active APP when the key is sent. In mIRC, using Ctrl+M and Ctrl+Enter behave the same way in the channel editbox, but this may not be true in other Apps. In mIRC, sending $chr(127) is the same as Ctrl+Backspace, which deletes word-left. Sendkeys does not support Unicode, so sending $chr(233) returns $null for that character, then continues sending the contents of the remainder of the sendkey string. A workaround is to stuff the unicode character into the clipboard, then use /sendkeys to send ^V to paste the clipboard's contents. To send 1 literal character/symbol, enclose it within {brackets} optionally followed by space and a repeats-number. {tab} simulates pressing tab, {tab 3} is pressing TAB 3 times {a 3} is literal aaa {special_words} are case-insensitive, so {DOWN} and {down} are equivalent, but {a} and {A} are not because 'a' is not a special word. You can send 3 {'s and 3 }'s like: /sendkeys {{ 3} {} 3} To send 3 consecutive spaces: /sendkeys foo{ }{ }{ }bar or use $sendkeys(string-with-3-spaces) or using the clipboard before sending ^V. Because of the way mIRC alters parameters for /commands, this puts 1 space between a and b: //sendkeys a $chr(32) b ... but this follows mIRC's rules for $identifiers, and puts 3 spaces between a and b: //noop $sendkeys(a $chr(32) b) When using Sendkeys to interface with a menu, instead of using several {TAB} or {TAB 3} to switch focus to the control you need, then using {enter} to toggle that setting, then using {TAB} again to return to the OK button... often menus have one of the letters underlined in each choice's text, which allows selecting that option using alt+UnderlinedLetter instead of the mouse. Tabbing to that item changes focus to that item, but alt+letter often does not. To save changes in alt+o options, you need to send {enter} while focus is on the OK button. If checking mirc.ini or one of mIRC's other .ini's for a settings's value before deciding whether you need to use /sendkeys to change it, be sure to /saveini first, in case the actual setting hasn't been flushed. Keys are sent to the active App at the cursor's focus location, even if a different program than mIRC. If you use alt+TAB to activate the Excel spreadsheet before the 5 seconds finishes, this pastes the clipboard into Excel: /timer 1 5 sendkeys +v Even if $appactive is true, $active does not warn if the focus is in Remotes Editor, Options, top menu, etc. i.e. simulating Alt+O to get into mirc-options doesn't work if the cursor focus is in the Remotes Editor. Instead, it would do what Alt+O does in the Editor, opening the editor's Options-Dropdown. The only thing allowed inside {} brackets is: 1 character 1 word-symbol either of the above that's followed by a space, then by the number of times it's repeated Valid: /sendkeys {a 3} simulates aaa /sendkeys {ESC 3} simulates the ESCAPE key 3 times Not Valid: /sendkeys {abc 3} not a codeword or single character /sendkeys { a} space not separating code/symbol and N repeats /sendkeys {a } ditto Sendkeys stops sending when it encounters an invalid symbol. The invalid {abc} symbol causes the following to send "/echo -a foo" to the editbox, but does not send 'bar' nor does it send the ENTER key: //echo 4 -a return code: $sendkeys(/echo -a foo{abc}bar{enter}) You can also use sendkeys as an identifier. This sends "/echo -a fooabar" to the editbox, along with the ENTER key, causing the ECHO command to execute: //echo 4 -a return code: $sendkeys(/echo -a foo{a}bar{enter}) Note the different return codes above, due to encountering an invalid symbol. (parenthesis) indicates 2+ keys to be pressed simultaneously. Usually used with ctrl/alt/shift Ctrl+Shift+TAB: /sendkeys (^+{tab}) All 3 keys pressed at the same time: Hold down shift while typing both 'e' and 'c'. Returns "EC": /sendkeys +(ec) Press SHIFT and 'e' at the same time, but not pressing SHIFT while pressing 'c' returns Ec: /sendkeys +ec The +^%~(){} symbols have special meaning to SendKeys, so if you wish to 'send' them as literal characters, you must enclose them inside {} braces. i.e. {{} and {}} are literal { and } while {(} and {)} are literal ( and ) ( The +^% symbols are shift/ctrl/alt, while ~ is the same thing as {enter} ) For example, paste into editbox: /sendkeys /echo 4 -a 2 {+} 2 = 4{enter} To send a literal space between other sent characters, either place the space character literally in the send string, or enclose inside { } especially if the space needs to be sent as the first/last character. The ~ and {enter} symbols are equivalent, but the latter is probably easier code to read. These are equivalent ways to send a space character between 'foo bar' followed by simulating the ENTER key: /sendkeys /echo -a foo{ }bar{enter} /sendkeys /echo -a foo bar~ The [] symbols can be sent literally, but Microsoft advises also enclosing them inside braces due to the possibility of some applications receiving them via DDE and handling them with special meaning. Note that, in the following, the two { } between 'test' and {enter} send 2 spaces to the input box for a length of 10. If you replace the pair of { } with more than 1 consecutive literal spaces, mirc removes duplicate consecutive spaces when giving strings to a /command so the length is only 9: //timersendkeytest 1 1 sendkeys test{ }{ }{enter} | timersendkeytest | var %a $input(label,e) $+ test | echo -a input %a has length $len(%a) vs //timersendkeytest 1 1 sendkeys test {enter} | timersendkeytest | var %a $input(label,e) $+ test | echo -a input %a has length $len(%a) The above doesn't work without /sendkeys delayed by a timer, because mIRC clears the input buffer before prompting for input. Assuming all menu sections inside Alt+O options have NOT been collapsed into "-", these are 2 ways to toggle your timestamp setting on/off, as long as mIRC is the $appactive and the focus is somewhere that pressing alt+o opens the options dialog. Paste either command in the editbox: //saveini | if (!$gettok($readini($mircini,options,n4),12,44)) sendkeys % $+ o{home}{down 8} $+ % $+ t{enter} //saveini | if (!$gettok($readini($mircini,options,n4),12,44)) sendkeys % $+ o{home}m $+ % $+ t{enter} Note that this causes a quick screen flash due to opening/closing the Alt+O dialog quickly. But the above also take no action if the timestamping is already enabled. If you did not check the current setting in mirc.ini, this would be blindly toggling the existing setting. //sendkeys echo -a tést~ ... returns tst but not the accented e, because sendkeys does not support Unicode. The fact that using "/sendkeys echo -a t{é}st~" also generates the remainder of the string shows that {é} is not an invalid symbol, it just returns NULL. To send strings containing unicode characters, you must use the clipboard. Note that this destroys the existing content of the clipboard: //clipboard $chr(233) | sendkeys /echo -a t^Vst~ This shows that codepoint 127 behaves as if pressing Ctrl+Backspace at the focus, which in the Remotes editor or the editbox deletes-word-left. In the editbox, both are equivalent: //sendkeys /echo -a word1,word2 $chr(123) $+ $chr(127) $+ $chr(125) word3 //sendkeys /echo -a word1,word2^{backspace}word3 This simulates pressing alt+TAB to toggle to a different application: //sendkeys % $+ {tab} This simulates holding down the ALT key while pressing TAB twice to toggle to a different application: //sendkeys % $+ {tab 2} The example above for using Alt+TAB is not reliable, because the script cannot guarantee which program it lands on. Courtesy of Raccon, another way to switch to another APP that is already open: //var %a = $ticks | .comopen %a WScript.Shell | if (!$comerr) .comclose %a $com(%a,AppActivate,3,bstr,Notepad) If Notepad is already open, that causes the focus to switch to Notepad, and $appactive will become false. There are at least a couple known problems: 1. If Notepad is minimized, focus shifts to the taskbar icon for Notepad, without maximizing or window'izing it. 2. If there are more than 1 copy of a program open, you can't always guarantee which of them becomes active. For example, this seems to activate whichever notepad is nearest in the alt+TAB list. But on the other hand, when using it to activate mIRC while 2 copies are running, it seems to always run the same mIRC, regardless which one the command is run from, or which mIRC is nearest in the alt+TAB list. Below are the defined symbols recognized by /sendkeys, though not all are valid keys on your PC i.e. {HELP} {F16} and other keys not on your keyboard do nothing. SHIFT + CTRL ^ ALT % Reminder: The following symbols can be repeated N times by also including a number. i.e. {DOWN 3} (The columns may not line up correctly in your font size without adding or deleting TAB characters) BACKSPACE {BACKSPACE}, {BS}, or {BKSP} BREAK {BREAK} CAPS LOCK {CAPSLOCK} DEL or DELETE {DELETE} or {DEL} DOWN ARROW {DOWN} END {END} ENTER {ENTER} or ~ ESC {ESC} HELP {HELP} HOME {HOME} INS or INSERT {INSERT} or {INS} LEFT ARROW {LEFT} NUM LOCK {NUMLOCK} PAGE DOWN {PGDN} PAGE UP {PGUP} PRINT SCREEN {PRTSC} (reserved for future use) RIGHT ARROW {RIGHT} SCROLL LOCK {SCROLLLOCK} TAB {TAB} UP ARROW {UP} F1 {F1} F2 {F2} F3 {F3} F4 {F4} F5 {F5} F6 {F6} F7 {F7} F8 {F8} F9 {F9} F10 {F10} F11 {F11} F12 {F12} F13 {F13} F14 {F14} F15 {F15} F16 {F16} Keypad add {ADD} Keypad subtract {SUBTRACT} Keypad multiply {MULTIPLY} Keypad divide {DIVIDE} Add'l maroon notes: {PRTSC} doesn't work for me +a and +A both return capital A, regardless whether CAPSLOCK is on or off. {CAPSLOCK} and {NUMLOCK} and {SCROLLLOCK} are supposed to work the same way. (3 L's in scrolllock) These 3 toggle that key on/off, and including an odd number of repeats also toggles, but an even number changes nothing. However, {CAPSLOCK} does NOT toggle the capslock OFF if your Windows settings has the capslock disabled by pressing the shift-key. However, when that setting is enabled, sending + or +a doesn't toggle capslock off either. The place to change that setting is in: Control Panel / Region and Language / Keyboards and Languages / Change Keyboards / Advanced Key Settings / Press-the-shift-key. This setting makes the capslock behave similarly to that on a typewriter and avoids the problem of typing hELLO eVERYONE! */