Jump to content

avichou

Member
  • Posts

    7
  • Joined

  • Last visited

Posts posted by avichou

  1. 5 hours ago, vitor said:

    Welcome @avichou,

     

    First, add your Remote Trigger. Connect it to a Run Script Action with language set to /usr/bin/swift and the following Script:

     

    import Quartz
    
    let supportedKeys: [String: UInt32] = [
      "screen-brightness-up": 2,
      "screen-brightness-down": 3,
      "keyboard-brightness-up": 21,
      "keyboard-brightness-down": 22,
      "play-pause": 16,
      "fast-forward": 17,
      "rewind": 18,
      "volume-mute-toggle": 7,
      "volume-up": 0,
      "volume-down": 1,
    ]
    
    func pressKey(_ key: UInt32) {
      func keyDown(_ down: Bool) {
        let flags = NSEvent.ModifierFlags(rawValue: (down ? 0xa00 : 0xb00))
        let data1 = Int((key << 16) | (down ? 0xa00 : 0xb00))
    
        let ev = NSEvent.otherEvent(
          with: NSEvent.EventType.systemDefined,
          location: NSPoint(x: 0, y: 0),
          modifierFlags: flags,
          timestamp: 0,
          windowNumber: 0,
          context: nil,
          subtype: 8,
          data1: data1,
          data2: -1
        )
    
        let cev = ev?.cgEvent
        cev?.post(tap: CGEventTapLocation.cgSessionEventTap)
      }
    
      keyDown(true)
      keyDown(false)
    }
    
    pressKey(supportedKeys[CommandLine.arguments[1]]!)

     

    Now go back to the Remote Trigger and set “Argument” to “Text”. In the text box, write one of the options at the top of the code, like fast-forward or play-pause.

     

    Duplicate the Remote Trigger and change the Text for each action you want. They can all connect to the same Run Script.

     

    The first time you run it, macOS may ask you to install the command-line developer tools. Let it (takes two clicks), and it’ll work from then on.

    Thanks a lot but I really have no knowledge about that ...i really don't know what to do ahha

    Where is the remote trigger option so I can create a new one ?

×
×
  • Create New...