Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MouseControl does not pass through unused gestures (underlapping/overlapping gestures with other addons/software) #7

Closed
sleek22 opened this issue Oct 29, 2016 · 11 comments
Labels

Comments

@sleek22
Copy link

sleek22 commented Oct 29, 2016

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.

@Noitidart
Copy link
Owner

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

@Noitidart
Copy link
Owner

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);

    }
}

@Noitidart
Copy link
Owner

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);

    }
}

@Noitidart
Copy link
Owner

Noitidart commented Oct 29, 2016

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'));
                }
            });
    }
}

@Noitidart
Copy link
Owner

I'll work on folder selection right now.

@Noitidart
Copy link
Owner

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();
                }
            });
    }
}

@sleek22
Copy link
Author

sleek22 commented Oct 29, 2016

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.

@Noitidart
Copy link
Owner

My pleasure! If you need anything let me know. MouseControl is very flexible :)

@Noitidart
Copy link
Owner

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.

@sleek22
Copy link
Author

sleek22 commented Oct 31, 2016

Yes, you can close it.

I'm letting MouseControl handle all rocker gestures now. It's much more versatile.

Thank you again.

@Noitidart
Copy link
Owner

Very cool thank you @sleek22 ! :)

@Noitidart Noitidart changed the title MouseControl does not pass through unused gestures MouseControl does not pass through unused gestures (underlapping/overlapping gestures with other addons/software) Oct 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants