send ctrl+alt+r

General discussion about Custom Buttons, including feature requests.

send ctrl+alt+r

Postby seamoon » Sat Jul 15, 2017 9:56 am

I created this button to trigger replace translator add-on's hotkey combination but it doesn't work.
Code: Select all
var args = ["sendkeypress", "ctrl+alt+0x52"];
seamoon
 
Posts: 36
Joined: Thu Oct 09, 2014 5:39 pm

Re: send ctrl+alt+r

Postby morat » Sat Jul 15, 2017 4:55 pm

Are you using the NirCmd utility?

http://www.nirsoft.net/utils/nircmd.html
http://www.nirsoft.net/utils/nircmd2.html

e.g.

Code: Select all
/*Code*/
var localFile = Components.classes["@mozilla.org/file/local;1"].
  createInstance(Components.interfaces.nsILocalFile);
var process = Components.classes["@mozilla.org/process/util;1"].
  createInstance(Components.interfaces.nsIProcess);
var args = ["sendkeypress", "ctrl+esc"];
localFile.initWithPath("C:\\nircmd.exe");
process.init(localFile);
process.run(false, args, args.length);

Try using the lowercase "r" or 0x72.

ASCII chart
http://www.bluesock.org/~willg/dev/ascii.html
morat
 
Posts: 959
Joined: Wed Dec 28, 2011 2:38 pm

Re: send ctrl+alt+r

Postby seamoon » Sat Jul 15, 2017 5:03 pm

Thank you very much.
seamoon
 
Posts: 36
Joined: Thu Oct 09, 2014 5:39 pm

NirCmd sendkey usage?

Postby seamoon » Sun Jul 16, 2017 8:28 pm

In the following script example, the system behaves like the user presses Shift+Ctrl+Esc (the task manager should appear):
sendkey shift down
sendkey ctrl down
sendkey esc down
sendkey shift up
sendkey ctrl up
sendkey esc up

How to adapt this to custom buttons, an example like ctrl+alt+t would be helpful.
seamoon
 
Posts: 36
Joined: Thu Oct 09, 2014 5:39 pm

Re: NirCmd sendkey usage?

Postby morat » Mon Jul 17, 2017 7:31 pm

Try this:

Code: Select all
/*Code*/
// open windows task manager shift+ctrl+esc
function sendKey(firstParameter, secondParameter) {
  var localFile = Components.classes["@mozilla.org/file/local;1"].
    createInstance(Components.interfaces.nsILocalFile);
  var process = Components.classes["@mozilla.org/process/util;1"].
    createInstance(Components.interfaces.nsIProcess);
  var args = ["sendkey", firstParameter, secondParameter];
  localFile.initWithPath("C:\\nircmd.exe");
  process.init(localFile);
  process.run(false, args, args.length);
}
sendKey("shift", "down");
sendKey("ctrl", "down");
sendKey("esc", "down");
sendKey("shift", "up");
sendKey("ctrl", "up");
sendKey("esc", "up");

NirCmd sendkey
http://www.nirsoft.net/utils/nircmd2.html#sendkey
morat
 
Posts: 959
Joined: Wed Dec 28, 2011 2:38 pm

Re: send ctrl+alt+r

Postby seamoon » Mon Jul 17, 2017 8:14 pm

morat wrote:Are you using the NirCmd utility?

http://www.nirsoft.net/utils/nircmd.html
http://www.nirsoft.net/utils/nircmd2.html

e.g.

Code: Select all
/*Code*/
var localFile = Components.classes["@mozilla.org/file/local;1"].
  createInstance(Components.interfaces.nsILocalFile);
var process = Components.classes["@mozilla.org/process/util;1"].
  createInstance(Components.interfaces.nsIProcess);
var args = ["sendkeypress", "ctrl+esc"];
localFile.initWithPath("C:\\nircmd.exe");
process.init(localFile);
process.run(false, args, args.length);

Try using the lowercase "r" or 0x72.

ASCII chart
http://www.bluesock.org/~willg/dev/ascii.html


Other keys work fine except alt key. I can't send ctrl+alt+r
nircmd.exe is in c:

Code: Select all
*Code*/
function sendKey(firstParameter, secondParameter) {
  var localFile = Components.classes["@mozilla.org/file/local;1"].
    createInstance(Components.interfaces.nsILocalFile);
  var process = Components.classes["@mozilla.org/process/util;1"].
    createInstance(Components.interfaces.nsIProcess);
  var args = ["sendkey", firstParameter, secondParameter];
  localFile.initWithPath("C:\\nircmd.exe");
  process.init(localFile);
  process.run(false, args, args.length);
}
sendKey("shift", "down");
sendKey("alt", "down");
sendKey("0x72", "down");
sendKey("0x72", "up");
sendKey("alt", "up");
sendKey("shift", "up");
seamoon
 
Posts: 36
Joined: Thu Oct 09, 2014 5:39 pm

Re: send ctrl+alt+r

Postby morat » Mon Jul 17, 2017 11:34 pm

Try this:

Code: Select all
/*Code*/
function sendKey(firstParameter, secondParameter) {
  var localFile = Components.classes["@mozilla.org/file/local;1"].
    createInstance(Components.interfaces.nsILocalFile);
  var process = Components.classes["@mozilla.org/process/util;1"].
    createInstance(Components.interfaces.nsIProcess);
  var args = ["sendkey", firstParameter, secondParameter];
  localFile.initWithPath("C:\\nircmd.exe");
  process.init(localFile);
  process.run(false, args, args.length);
}
sendKey("shift", "down");
sendKey("alt", "down");
sendKey("r", "press");
sendKey("alt", "up");
sendKey("shift", "up");
morat
 
Posts: 959
Joined: Wed Dec 28, 2011 2:38 pm

Re: send ctrl+alt+r

Postby seamoon » Tue Jul 18, 2017 9:23 am

Thank you very much morat.
seamoon
 
Posts: 36
Joined: Thu Oct 09, 2014 5:39 pm


Return to General Discussion

cron