Closed sleek22 closed 7 years ago
Thanks very much Ahmed for your feedback! Are you using v2.0? Or a v1.x?
v1.x is very old tech, I'm surprised it works.
v2.0 is using modern tech. But it hooks in very low level, at the platform level. If you have an overlapping gesture, it won't allow the overlaps to work. :(
The only way for MouseControl to co-exist is to use MouseControl for all rocker gestures, and FireGestures for the drag/draw stuff.
I can help create and customize functions via the options panel if you want to try this. Here is an example how to send Paste -
{
__exec__: function() {
var window = Services.wm.getMostRecentWindow(null);
var key = char => String.charCodeAt(char);
var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
utils.sendKeyEvent('keydown', key('V'), key('V'), Ci.nsIDOMWindowUtils.MODIFIER_CONTROL);
utils.sendKeyEvent('keyup', key('V'), key('V'), Ci.nsIDOMWindowUtils.MODIFIER_CONTROL);
utils.sendKeyEvent('keypress', key('V'), key('V'), Ci.nsIDOMWindowUtils.MODIFIER_CONTROL);
window.alert('ok pasted');
}
}
Here is a youtube video showing how I used it - https://www.youtube.com/watch?v=6hvxKOJ2mfo
Apparently we don't need the keydown and keyup so the above code can be simplified to this:
{
__exec__: function() {
var window = Services.wm.getMostRecentWindow(null);
var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
var key = char => String.charCodeAt(char);
var sendChar = (char, mods) => utils.sendKeyEvent('keypress', key(char), key(char), mods || 0);
var sendStr = str => Array.forEach.call(null, str, char=>sendChar(char))
sendChar('v', Ci.nsIDOMWindowUtils.MODIFIER_CONTROL);
}
}
I couldn't help myself, here is a "Bookmark and Close Current Tab" using send keys method :)
{
__exec__: function() {
var window = Services.wm.getMostRecentWindow(null);
var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
var key = char => String.charCodeAt(char);
var sendChar = (char, mods) => utils.sendKeyEvent('keypress', key(char), key(char), mods || 0);
var sendStr = str => Array.forEach.call(null, str, char=>sendChar(char))
sendChar('d', Ci.nsIDOMWindowUtils.MODIFIER_CONTROL);
sendChar('w', Ci.nsIDOMWindowUtils.MODIFIER_CONTROL);
}
}
Here is Toggle Bookmark in Toolbar. If the current tab is not bookmarked, it bookmarks it. If it is already bookmarked, it removes the bookmark. The target is the bookmark toolbar.
{
__exec__() {
// var FOLDER_NAME_ = 'Bollywood Movies'; // set to string, name of folder you want bookmark placed in, if it exists, it adds there, if it doesnt exist, it is created
var TOP_LEVEL_GROUP_NAME = 'TOOLBAR'; // MENU, TOOLBAR, UNSORTED
var COMMONJS_URI = 'resource://gre/modules/commonjs';
var { require } = Cu.import(COMMONJS_URI + '/toolkit/require.js', {});
var { Bookmark, Group, save, remove, search, [TOP_LEVEL_GROUP_NAME]:top_level_group } = require('sdk/places/bookmarks');
var win = Services.wm.getMostRecentWindow('navigator:browser');
var title = win.gBrowser.selectedTab.getAttribute('label');
var url = win.gBrowser.currentURI.spec;
// test is it bookmarked
search({query:url})
.on('end', function(results) {
var filtered = results.filter(el => el.url == url);
if (filtered.length) {
// IT IS BOOKMARKED
save(remove(filtered)).on('end', ()=>console.log('removed'));
} else {
// IT IS NOT BOOKMARKED so bookmark it
save(Bookmark({ title, url, group:top_level_group })).on('end', ()=>console.log('saved'));
}
});
}
}
I'll work on folder selection right now.
Here is Unbookmark if necessary, then close tab
{
__exec__() {
// var FOLDER_NAME_ = 'Bollywood Movies'; // set to string, name of folder you want bookmark placed in, if it exists, it adds there, if it doesnt exist, it is created
var TOP_LEVEL_GROUP_NAME = 'TOOLBAR'; // MENU, TOOLBAR, UNSORTED
var COMMONJS_URI = 'resource://gre/modules/commonjs';
var { require } = Cu.import(COMMONJS_URI + '/toolkit/require.js', {});
var { Bookmark, Group, save, remove, search, [TOP_LEVEL_GROUP_NAME]:top_level_group } = require('sdk/places/bookmarks');
var win = Services.wm.getMostRecentWindow('navigator:browser');
var title = win.gBrowser.selectedTab.getAttribute('label');
var url = win.gBrowser.currentURI.spec;
var closeTabOrWin = () => win.BrowserCloseTabOrWindow();
// test is it bookmarked
search({query:url})
.on('end', function(results) {
var filtered = results.filter(el => el.url == url);
if (filtered.length) {
// IT IS BOOKMARKED so remove it then close tab
save(remove(filtered)).on('end', ()=>console.log('removed', closeTabOrWin()));
} else {
// IT IS NOT BOOKMARKED so just close tab
closeTabOrWin();
}
});
}
}
Thank you Noitidart, that last code worked perfectly!
Now I can go and explore all the other options with your add-on.
Thank you again for the quick response and all the help with the coding.
I really appreciate it.
My pleasure! If you need anything let me know. MouseControl is very flexible :)
Hi @sleek22 is it ok to close this? As the conclusion is, because MouseControl hooks it at the very low level, it cannot co-exist with other addons if a gesture/mouse-combo overlaps.
Yes, you can close it.
I'm letting MouseControl handle all rocker gestures now. It's much more versatile.
Thank you again.
Very cool thank you @sleek22 ! :)
I've just been playing around with your MouseControl add-on and it has great potential. Unfortunately, it suffers from one glaring problem. It does not pass through gestures that it doesn't use.
I currently use FireGestures and I have a Rocker Gesture that sends a certain key combination.
I also use an AutoIt script that uses another Rocker Gesture that clicks on buttons, sends keystrokes, etc.
I thought I could use your add-on in combination with these other two but it is not allowing unused Rocker Gestures to pass through.
Still, a very interesting add-on. Perhaps you could have it so that if nothing is triggered, it can pass these gestures along so other add-ons/programs can use them.
Thank you.