working on it ...

Filters

Explore Public Snippets

Sort by

Found 209 snippets matching: hotkey

    public by p.kontalis  3520  1  5  0

    Hotkey for Application

    Hotkey or Combination that can effect everywhere inside the application
    Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Add the following line in order to enable the capability to capture the keyboard events before any other element in the form.
        Me.KeyPreview = True
    End Sub
    
    Private Sub Hotkeys_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        ' The Alt + P Hotkey raise the event Button1.Click
        If (e.Alt AndAlso (e.KeyCode = Keys.P)) Then RaiseEvent Button1.Click
    End If

    public by msdn  153500  0  5  0

    GetHotkeyAndLabel: Parse a string containing a hotkey character. Take a string of the form Yes to &all and returns a two-dimensional array split out as "A", "Yes to all".

    Parse a string containing a hotkey character. Take a string of the form Yes to &all and returns a two-dimensional array split out as "A", "Yes to all". The string to process A two dimensional array containing the parsed components.
    /// <summary>
    /// Parse a string containing a hotkey character.
    /// Take a string of the form
    ///    Yes to &amp;all
    /// and returns a two-dimensional array split out as
    ///    "A", "Yes to all".
    /// </summary>
    /// <param name="input">The string to process</param>
    /// <returns>
    /// A two dimensional array containing the parsed components.
    /// </returns>
    private static string[] GetHotkeyAndLabel(string input)
    {
        string[] result = new string[] { String.Empty, String.Empty };
        string[] fragments = input.Split('&');
        if (fragments.Length == 2)
        {
            if (fragments[1].Length > 0)
            {
                result[0] = fragments[1][0].ToString().
                ToUpper(CultureInfo.CurrentCulture);
            }
    
            result[1] = (fragments[0] + fragments[1]).Trim();
        }
        else
        {
            result[1] = input;
        }
    
        return result;
    }

    external by Asa Jay  139884  0  4  0

    OpenVim.ahk - Windows Explorer hotkey integration of gVim

    OpenVim.ahk - Windows Explorer hotkey integration of gVim: OpenVim.ahk
    ; OpenVim.ahk
    ;
    ; Author: Arthur Jaron
    ; EMail: hifreeo@gmail.com
    
    ; Overview:
    ; Explorer_GetSelection(): Helper function (found in the AHK-forums)
    ; OpenVim(): Core function
    ; Hotkeys:
    ;   Win+Enter: Open current file in gVim session "GVIM"
    ;   Win+Ctrl+Enter: Open current selected file in gVim session "ADMIN MODE" with
    ;       elevated rights. This wil let you write to protected files, e.g. inside
    ;       the Windows/ folder and top-level files (c:\example.txt).
    
    Explorer_GetSelection(hwnd="") {
        ; Get the full filepath + name of the currently selected file inside
        ; the explorer window.
        hwnd := hwnd ? hwnd : WinExist("A")
        WinGetClass class, ahk_id %hwnd%
        if (class="CabinetWClass" or class="ExploreWClass" or class="Progman")
                for window in ComObjCreate("Shell.Application").Windows
                        if (window.hwnd==hwnd)
        sel := window.Document.SelectedItems
        for item in sel
            ToReturn .= item.path "`n"
            return Trim(ToReturn,"`n")
    }
    
    OpenVim(Admin="") {
        ; Open the currently selected file within explorer in gVim.
        ; Passing a non-empty string as a parameter will bring up the UAC-prompt 
        ; to elevate the next gVim session. It doesn't elevate the current existing
        ; "GVIM" session, but opens a new one named "ADMIN MODE".
        path_name := % Explorer_GetSelection()
        if (Admin) {
            Run *RunAs C:\Program Files\Vim\vim74\gvim.exe --servername "ADMIN MODE" --remote-silent "%path_name%",,,OutputVarPID
        }
        else {
            Run, C:\Program Files\Vim\vim74\gvim.exe --servername "GVIM" --remote-silent "%path_name%",,,OutputVarPID
        }
        return
    }
    
    ; ### Hotkeys ###
    
    ; Win+Enter
    #Enter::
    OpenVim()
    return
    
    ; Win+Ctrl+Enter: 
    ^#Enter::
    OpenVim("Admin")
    return
    
    

    external by Github  378  0  4  0

    Global Hotkey: HotKey _hotKey = new HotKey(Key.Space, KeyModifier.Alt, OnHotKeyHandler); private void OnHotKeyHandler(HotKey hotKey) { //do shit }

    Global Hotkey: HotKey _hotKey = new HotKey(Key.Space, KeyModifier.Alt, OnHotKeyHandler); private void OnHotKeyHandler(HotKey hotKey) { //do shit }: HotKey.cs
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Windows.Input;
    using System.Windows.Interop;
    
    namespace fuzzy_kellotin
    {
      public class HotKey : IDisposable
      {
        private static Dictionary<int, HotKey> _dictHotKeyToCalBackProc;
    
        [DllImport("user32.dll")]
        private static extern bool RegisterHotKey(IntPtr hWnd, int id, UInt32 fsModifiers, UInt32 vlc);
    
        [DllImport("user32.dll")]
        private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
    
        public const int WmHotKey = 0x0312;
    
        private bool _disposed = false;
    
        public Key Key { get; private set; }
        public KeyModifier KeyModifiers { get; private set; }
        public Action<HotKey> Action { get; private set; }
        public int Id { get; set; }
    
        // ******************************************************************
        public HotKey(Key k, KeyModifier keyModifiers, Action<HotKey> action, bool register = true)
        {
          Key = k;
          KeyModifiers = keyModifiers;
          Action = action;
          if (register)
          {
            Register();
          }
        }
    
        // ******************************************************************
        public bool Register()
        {
          int virtualKeyCode = KeyInterop.VirtualKeyFromKey(Key);
          Id = virtualKeyCode + ((int)KeyModifiers * 0x10000);
          bool result = RegisterHotKey(IntPtr.Zero, Id, (UInt32)KeyModifiers, (UInt32)virtualKeyCode);
    
          if (_dictHotKeyToCalBackProc == null)
          {
            _dictHotKeyToCalBackProc = new Dictionary<int, HotKey>();
            ComponentDispatcher.ThreadFilterMessage += new ThreadMessageEventHandler(ComponentDispatcherThreadFilterMessage);
          }
    
          _dictHotKeyToCalBackProc.Add(Id, this);
    
          Debug.Print(result.ToString() + ", " + Id + ", " + virtualKeyCode);
          return result;
        }
    
        // ******************************************************************
        public void Unregister()
        {
          HotKey hotKey;
          if (_dictHotKeyToCalBackProc.TryGetValue(Id, out hotKey))
          {
            UnregisterHotKey(IntPtr.Zero, Id);
          }
        }
    
        // ******************************************************************
        private static void ComponentDispatcherThreadFilterMessage(ref MSG msg, ref bool handled)
        {
          if (!handled)
          {
            if (msg.message == WmHotKey)
            {
              HotKey hotKey;
    
              if (_dictHotKeyToCalBackProc.TryGetValue((int)msg.wParam, out hotKey))
              {
                if (hotKey.Action != null)
                {
                  hotKey.Action.Invoke(hotKey);
                }
                handled = true;
              }
            }
          }
        }
    
        // ******************************************************************
        // Implement IDisposable.
        // Do not make this method virtual.
        // A derived class should not be able to override this method.
        public void Dispose()
        {
          Dispose(true);
          // This object will be cleaned up by the Dispose method.
          // Therefore, you should call GC.SupressFinalize to
          // take this object off the finalization queue
          // and prevent finalization code for this object
          // from executing a second time.
          GC.SuppressFinalize(this);
        }
    
        // ******************************************************************
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be _disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be _disposed.
        protected virtual void Dispose(bool disposing)
        {
          // Check to see if Dispose has already been called.
          if (!this._disposed)
          {
            // If disposing equals true, dispose all managed
            // and unmanaged resources.
            if (disposing)
            {
              // Dispose managed resources.
              Unregister();
            }
    
            // Note disposing has been done.
            _disposed = true;
          }
        }
      }
    
      // ******************************************************************
      [Flags]
      public enum KeyModifier
      {
        None = 0x0000,
        Alt = 0x0001,
        Ctrl = 0x0002,
        NoRepeat = 0x4000,
        Shift = 0x0004,
        Win = 0x0008
      }
    
      // ******************************************************************
    }
    
    

    external by Renato  63  0  1  0

    Auto Hotkey (AHK) script to paste clipboard content removing non alphanumeric caracters (Hotkey - Ctrl + Alt + Shift + T)

    Auto Hotkey (AHK) script to paste clipboard content removing non alphanumeric caracters (Hotkey - Ctrl + Alt + Shift + T): paste_alpha_only.ahk
    ; To be used to paste CPF / CNPJ / bar code copied to clipboard
    
    $^+!t::
      Sleep, 100
      ClipSaved := ClipboardAll  ;save original clipboard contents
      Clipboard := RegExReplace(Clipboard, "[^a-zA-Z0-9]", "")
      Sleep, 100
      Send   ^v  ;send the Ctrl+V command
      Sleep, 100
      Clipboard := ClipSaved  ;restore the original clipboard contents
      ClipSaved =  ;clear the variable
    
    Return
    
    

    external by CheapDevotion  114  0  2  0

    A UnityEditor script that provides a hotkey for quickly grouping GameObjects.

    A UnityEditor script that provides a hotkey for quickly grouping GameObjects.: GroupSelection.cs
    using UnityEngine;
    using System.Collections;
    using UnityEditor;
    
    public class ParentSelection : ScriptableObject {
    
        [MenuItem("OffTheGrid/Group Objects #g")]
        static void GroupObjects()
        {
            GameObject[] objects = Selection.gameObjects;
            GameObject parentObject = new GameObject("Grouped Objects");
            Undo.RegisterCreatedObjectUndo(parentObject, "Grouped Objects");
            foreach (GameObject ob in objects)
            {
                Undo.SetTransformParent(ob.transform, parentObject.transform, ob.name + " Parent");
            }
            Selection.activeGameObject = parentObject;
        }
    }
    
    

    external by arianraptor  2971  71  3  1

    Auto Hotkey skill spam macro for Ragnarok Online

    Auto Hotkey skill spam macro for Ragnarok Online: spam.ahk
    $F1::
    loop, 5
    {
        send, {F1}
        sleep, 0
        MouseClick, Left
    }
    return
    
    $F3::
    loop, 5
    {
        send, {F3}
        sleep, 0
        MouseClick, Left
    }
    return
    
    
    

    external by airstrike  3814  50  3  0

    AutoHotkey | Toggle microphone hotkey script (Windows+U)

    AutoHotkey | Toggle microphone hotkey script (Windows+U): mute-mic.ahk
    ;
    ; AutoHotkey Version: v1.1.22.06
    ; Language:       English
    ; Platform:       Windows 10
    ; Author:         Andre Terra <github.com/airstrike>
    ;
    ; Script Function:
    ;	Toggle Microphone Mute -- assumes it is located at WAVE:1, device #2
    ;	Use the SoundCardAnalysis to figure out where your mic is
    ;
    
    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    #SingleInstance force
    
    MuteMic() {
    	local MM
    	SoundSet, +1, WAVE:1, MUTE, 2
    	SoundGet, MM, WAVE:1, MUTE, 2
    	#Persistent
    	ToolTip, % (MM == "On" ? "Microphone muted" : "Microphone online")
    	SetTimer, RemoveMuteMicTooltip, 700
    	return
    }
    
    RemoveMuteMicTooltip:
    	SetTimer, RemoveMuteMicTooltip, Off
    	ToolTip
    	return
    
    #u::MuteMic()
    
    

    external by jasonwhite  80  0  1  0

    Download video URL (youtube-dl supported), and automatically open with VLC as soon as possible. Assign to global hotkey for easy use: (1. Copy URL. 2. Hit hotkey shortcut. 3. Wait a few seconds. 4. Enjoy in VLC). (This is an updated version of swarming...

    Download video URL (youtube-dl supported), and automatically open with VLC as soon as possible. Assign to global hotkey for easy use: (1. Copy URL. 2. Hit hotkey shortcut. 3. Wait a few seconds. 4. Enjoy in VLC). (This is an updated version of swarminglogic's.): vlcopen.sh
    #!/bin/bash
    
    # Opens the video on your clipboard and plays it in VLC. I recommend binding
    # this to a keyboard shortcut.
    #
    # Usage: vlcopen.sh
    #
    # Authors: Roald Fernandez, Jason White
    #
    # Dependencies:
    #   * youtube-dl (for downloading the video)
    #   * vlc (for playing the video of course)
    #   * inotify-tools (for inotifywait)
    
    # Timeout (in seconds) after which to give up on downloading the video.
    timeout=10
    
    # Time to wait for the video to buffer before playing. Increase/decrease this
    # depending on the quality of your connection. VLC will fail to auto-play the
    # video if there isn't enough data downloaded yet.
    buffertime=2
    
    # Video player to play the video with.
    player=vlc
    
    # Video quality control (see Video Format Options in youtube-dl man page for
    # more info).
    quality="--max-quality 18" # Selects 360p as max quality
    #quality="--max-quality best" # Selects the best possible quality
    
    if [ $# -eq 1 ] ; then
        path=$1
    else
        clipboard=$(xclip -selection clipboard -o)
        if [ $(<<<$clipboard grep -P "^http") ] ; then
            path=$clipboard
        else
            if [ -t 1 ] ; then
                echo "Bad clipboard path: $clipboard" >&2
            else
                notify-send "Invalid Video URL" "$clipboard"
            fi
            exit 1
        fi
    fi
    
    # Let the user know something is happening
    ! [[ -t 1 ]] && notify-send "Opening video..." "Just wait a sec, okay?"
    
    # Parameters: $1 processid, $2 video, $3 log
    function cleanup {
        kill -9 $1 &> /dev/null
        rm -f -- "$2" "$3"
    }
    
    # Video path
    video=$(mktemp --tmpdir=/tmp)
    
    # Download log path
    log=$(mktemp --tmpdir=/tmp)
    
    echo "Getting video: $path"
    
    (youtube-dl --no-part $quality --output $video -- "$path" &> $log)&
    processId=$!
    #echo "ProcessID: $processId"
    
    echo -n "Waiting for download to start..."
    
    # Wait for the video to be written to. Time out after 10 seconds.
    inotifywait -e modify -t $timeout $video &> /dev/null
    
    if [ $? -ne 0 ]; then
        echo
    
        case $? in
            2)
                notify-send "Video Download Timed Out" "Download did not start after $timeout seconds.\n$path"
                ;;
            *)
                notify-send "Video Download Failed" "The video failed to download:\n$path"
                [[ -t 1 ]] && cat $log >&2
                ;;
        esac
    
        cleanup $processId $video $log
        exit 1
    fi
    
    echo " Done."
    
    # Wait a couple of seconds for it to buffer. Otherwise VLC may not auto-play the
    # video.
    sleep $buffertime
    
    # Open in VLC
    $player -- "$video" &> /dev/null
    
    # Clean up our mess after the video player is closed.
    cleanup $processId "$video" "$log"
    
    

    external by mrichar1  80  0  1  0

    reveal.js - hotkey to jump to/from a named slide

    reveal.js - hotkey to jump to/from a named slide: reveal-jump.js
    Reveal.initialize({
          keyboard: {
          // '0' key will jump between current slide and slide-X
          48: function() {jumpSlide()},
          }
    });
    
    function jumpSlide() {
    
      // The id of the slide you wish to jump to/from
      target = "slide-X";     
    
      slide = Reveal.getCurrentSlide();
      // If we're on the target slide, jump to original slide, if there was one
      if (slide.id == target) {
        Reveal.slide(orig['h'], orig['v']);
      }
      else {
        // 'Save' the current slide's index to jump back to later
        orig = Reveal.getIndices();
        // Jump to the target slide
        jump = Reveal.getIndices(document.getElementById(target));
        Reveal.slide(jump['h'], jump['v']);
      }
    }
    
    
    • Public Snippets
    • Channels Snippets