Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Created October 17, 2014 23:42
Show Gist options
  • Save Noitidart/8b875261d1a9dbd6b0cf to your computer and use it in GitHub Desktop.
Save Noitidart/8b875261d1a9dbd6b0cf to your computer and use it in GitHub Desktop.
_applescript-FocusMostRecentWindow -
tell application "System Events" to tell application process "Firefox"
tell application "Firefox"
activate
tell windows
set minimized to false
set visible to true
end tell
end tell
end tell
@yajd
Copy link

yajd commented Oct 18, 2014

This popen does AXRaise and it does it as System Events

Cu.import('resource://gre/modules/ctypes.jsm');


function doit() {
        _x11 = ctypes.open('libc.dylib');


    var popen = _x11.declare('popen', ctypes.default_abi, ctypes.voidptr_t, // Return int
        ctypes.char.ptr, // Param1 const char *command
        ctypes.char.ptr // Param1 const char *command
    );

    var fread = _x11.declare('fread', ctypes.default_abi, ctypes.size_t, // Return int
        ctypes.voidptr_t,
        ctypes.size_t,
        ctypes.size_t,
        ctypes.voidptr_t
    );

    var pclose = _x11.declare('pclose', ctypes.default_abi, ctypes.int, // Return int
        ctypes.voidptr_t
    );

    ////////////////////////
    ////END DECLARATIONS
    ////////////////////////

    var file = popen('osascript -e \'tell application "System Events" to tell first process whose unix id is 398 \n set frontmost to true \n \n perform action "AXRaise" \n end tell\'', 'r')
  console.log(file.toString())
    pclose(file);


}

console.time('popen');
doit();
console.timeEnd('popen')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment