Tuesday, December 3, 2019

Autohotkey Script


Twitch_emotes.ahk




Purpose:


Type emojis easily.

What it does:


When you type "?" followed by a keyword, your text is automatically replaced by the corresponding emoji. Set it to run only in specific apps.

Requires:


  • Automatically runs programs, clicks buttons, types keys.

Script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; tray icon
; Menu, Tray, Icon, %A_ScriptDir%\icons\icons8-twitch-64.png

; Hotstring parameters
hotstring_hotkey = ?
    ; prefix to type before the emoji name
ahk_hotstring_option = :*X:
    ; * immediately replace hotstring
    ; X use function to paste string
prefix = %ahk_hotstring_option%%hotstring_hotkey%

emoji_dictionary := {}
twitch_dictionary := {}
;--------------------------------------------------
;---- add new emoji hotstrings here ---------------
;--------------------------------------------------
Push(emoji_dictionary, "sparkuling", "・゜・:・゚✧*:・゚✧。*゚+..。 ✧・゚: ✧・゚:*・゜・:・゚✧*::*・・*:・゚・゚*・゜・*:・゚✧*:・゚✧。*゚+..。 ✧・゚: ✧・゚:*・゜・:・゚✧*::*・・*:・゚・゚・゚✧*:・*゚+..。✧・゚:*・..。 ✧・゚ :・゚* ゜・*:・ ✧・゚:・゚:.。 ✧・゚ SPARKULING ・゜・:・゚✧*:・゚✧。*゚+..。 ✧・゚: ✧・゚:*・゜・:・゚✧*::*・・*:・゚・゚*・゜・*:・゚✧*:・゚✧。*゚+..。 ✧・゚: ✧・゚:*・゜・:・゚✧*::*・・*:・゚・゚*・゜・*:・゚✧*:・゚✧。*゚+..。 ✧・゚: ✧・゚:*・゜・:・゚✧*::*・・*:・゚・゚")
Push(emoji_dictionary, "shrug", "¯\_(ツ)_/¯")
Push(emoji_dictionary, "tableflip", "(╯°□°)╯︵ ┻━┻")
Push(emoji_dictionary, "tablerestore", "(ノ^_^)ノ┻━┻ ┬─┬ ノ( ^_^ノ)")
Push(emoji_dictionary, "bear", "ʕ·͡ᴥ·ʔ")
Push(emoji_dictionary, "lovely", "(°◡°♡).:。")
Push(emoji_dictionary, "yuno", "ლ(ಠ益ಠლ)")
Push(emoji_dictionary, "morty", "╭(◔ ◡ ◔)/")
Push(emoji_dictionary, "disapprove", "ಠ_ಠ")
Push(emoji_dictionary, "facepalm", "(-‸ლ)")
Push(emoji_dictionary, "shades", "(•_•) ( •_•)>⌐■-■ (⌐■_■)")
Push(emoji_dictionary, "zoop", "(☞゚ヮ゚)☞")
Push(emoji_dictionary, "lenny", "( ͡° ͜ʖ ͡°)")
Push(emoji_dictionary, "kiss", "( ˘ ³˘)♥")
; Push(emoji_dictionary, "foo", "bar")

; Twitch emotes
Push(twitch_dictionary, "cat", "DxCat CoolCat DxCat CoolCat DxCat CoolCat ")
Push(twitch_dictionary, "wings", "MercyWing1 CurseLit MercyWing2    MercyWing1 TwitchLit MercyWing2    MercyWing1 CurseLit MercyWing2 ")
Push(twitch_dictionary, "angel", "TBAngel VoHiYo TBAngel VoHiYo TBAngel VoHiYo TBAngel VoHiYo TBAngel ")
Push(twitch_dictionary, "heart", "bleedPurple bleedPurple PurpleStar bleedPurple bleedPurple <3 PurpleStar bleedPurple bleedPurple PurpleStar <3 bleedPurple bleedPurple ")
Push(twitch_dictionary, "lol", "EleGiggle MaxLOL MaxLOL LUL SuperVinlin MaxLOL MaxLOL EleGiggle ")
Push(twitch_dictionary, "pow", "CurseLit    twitchRaid    MorphinTime    twitchRaid    twitchRaid    MorphinTime    twitchRaid    CurseLit")
Push(twitch_dictionary, "snacks", "DoritosChip PopCorn NomNom DoritosChip PopCorn NomNom DoritosChip PopCorn NomNom ")
Push(twitch_dictionary, "cute", "TPFufun ")
Push(twitch_dictionary, "pet", "RitzMitz KonCha RitzMitz KonCha RitzMitz KonCha ")
Push(twitch_dictionary, "fire", "CurseLit CurseLit CurseLit CurseLit CurseLit CurseLit CurseLit CurseLit ")
; Push(twitch_dictionary, "foo", "bar")
;--------------------------------------------------
;--------------------------------------------------
;--------------------------------------------------
; nonessential function just to make it slightly easier to copy paste the parameters
Push(dictionary, key, value)   
{
    dictionary[key] := value
}
;---- add a description list to the tray menu ---------------
Menu, tray, nostandard
Menu, Tray, Add, Emoji List, show_description ; add a new tray menu entry
Menu, tray, add ; divider
Menu, tray, Standard ; put the standard buttons back
Menu, tray, default, emoji list ; set the default double click menu entry

;---- run hotstrings only in these apps ---------------
GroupAdd, TwitchApps, ahk_exe TwitchUI.exe
GroupAdd, TwitchApps, ahk_exe Twitch Sings.exe
GroupAdd, TwitchApps, ahk_exe Firefox.exe
GroupAdd, TwitchApps, ahk_exe notepad.exe ; for testing purposes
#IfWinActive ahk_group TwitchApps
;---- create the replacement hotstrings ---------------
For emoji_name, emoji_string in emoji_dictionary
    Hotstring(prefix emoji_name, (Func("paste_string").Bind(emoji_string)))
For emoji_name, emoji_string in twitch_dictionary
    Hotstring(prefix emoji_name, (Func("paste_string").Bind(emoji_string)))
#IfWinActive

; unicode strings don't always type properly in app, but work when copy pasted from clipboard
; old clipboard contents are restored
paste_string(string){
    clipSave := ClipboardAll
    Clipboard := string
    Send, ^v
    Sleep 500
    Clipboard := clipSave
    clipSave := ""
}


; creates a GUI window to display emoji list
show_description()
   {
   global
   static Description_textbox, OKbutton ; local variabes are not allowed. use caution if creating multiple gui windows!
   gui, new
   gui, Default
   description_string := ""
   description_string = %description_string%ASCII emojis`n`n
   for key, value in emoji_dictionary
    description_string = %description_string%%hotstring_hotkey%%key%         %value%`n
   description_string = %description_string%`nTwitch emotes`n`n
   for key, value in twitch_dictionary
    description_string = %description_string%%hotstring_hotkey%%key%         %value%`n
   gui, add, edit, readonly vDescription_textbox , %description_string%
   gui, add, button, gmyguiclose vOKbutton, OK
   gui, show, , Emoji descriptions
   GuiControl, focus, OKbutton
   return winexist()
  
   myguiclose:
      {
      gui,destroy
      return
      }
   }

No comments:

Post a Comment

You can add Images, Colored Text and more to your comment.
See instructions at http://macrolayer.blogspot.com..