von_Elsewhere

Browser Search & Load for Bitwig

Jan 25th, 2025 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 2.74 KB | Software | 0 0
  1. ; Browser Search & Load for Bitwig
  2. ;
  3. ; How to use:
  4. ; Write the trigger character (default: backitck) and
  5. ; then two letters abbreviation in the search field.
  6. ; The script will write a replacement search term,
  7. ; press tab for Everything, down arrow and then enter
  8. ; to load the search match.
  9. ; Make sure you don't trigger these elsewhere than in
  10. ; the browser search as you will get wonky behavior.
  11. ;
  12. ; For example, with this configuration, writing "`vi"
  13. ; without quotes to either browser's search should
  14. ; load Vital withhout further user interaction.
  15.  
  16. #Requires AutoHotkey v2.0
  17. #SingleInstance Force
  18.  
  19. SetKeyDelay(2)
  20.  
  21. SEARCH_DLY := 200 ; Delay time in ms that Bitwig needs to get the search done. Increase if 200ms isn't enough on your system.
  22. TAB_DLY := 30 ; Delay time that Bitwig needs to switch to Everything in the popup browser
  23. INPUT_TIMEOUT := 500 ; After writing the trigger character you need to write the rest within this ms value.
  24.  
  25. make_autoloader()
  26.  
  27. make_autoloader() {
  28.     trigger := "``" ; Trigger character for autoload hotstrings that need to be written before the abbreviation. Note that the backtick is escaped with another backtick here.
  29.  
  30.     ; sarchTerms map contains the abbreviations you need to write after the trigger and the search terms that gets passed to Bitwig
  31.     ; The abbreviation can contain any number of characters but be aware that f.ex. "eq" would trigger before "eq5".
  32.     ; Follow the syntax of the example below.
  33.     searchTerms := Map(
  34.         "vi", "vital vst3",
  35.         "sr", "serum vst3",
  36.         "pp", "phase plant vst3",
  37.         "e5", "eq-5 bwd", ; Writing "bwd" to the search term searches only .bwdevices (unless some other device name includes "bwd")
  38.         "chr", "chorus -{+} bwd", ; Using only "ch" here would make it impossible to trigger "chp"
  39.         "chp", "chorus{+} bwd" ; Note that plus sign needs to be written in curly brackets as "{+}" for search terms in this script.
  40.     )
  41.  
  42.     ; Everything below this just does what needs to be done
  43.     HotIfWinActive("ahk_class bitwig")
  44.     for abbrv, searchString in searchTerms {
  45.         Hotstring(":*B0:" trigger abbrv, autoLoad.Bind(,searchString))
  46.     }
  47.     Hotkey("~" trigger, autoLoad.Bind(,""))
  48.     HotIfWinActive()
  49.  
  50.     autoLoad(hs, searchString := "") {
  51.         static startT
  52.         if (SubStr(hs, 2, 1) == trigger) {
  53.             startT := A_TickCount
  54.             return
  55.         }
  56.         if (A_TickCount - startT > INPUT_TIMEOUT) {
  57.             return
  58.         }
  59.         if searchString {
  60.             Send("+{Home}{Del}")
  61.             SendEvent(searchString)
  62.             Sleep SEARCH_DLY
  63.             Send("{Tab}")
  64.             Sleep TAB_DLY
  65.             Send("{Down}{Enter}")
  66.         }
  67.     }
  68. }
  69.  
  70. #HotIf WinActive("ahk_class bitwig")
  71. #HotIf
Advertisement
Add Comment
Please, Sign In to add comment