|
| 1 | +; AutoHotKey - Buttonpusher Post-Production Keyboard Environment - After Effects HotKeys |
| 2 | +; by Ben Howard - [email protected] |
| 3 | + |
| 4 | +;===== START OF AUTO-EXECUTION SECTION ========================================================= |
| 5 | +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. |
| 6 | +; #Warn ; Enable warnings to assist with detecting common errors. |
| 7 | +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. |
| 8 | +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. |
| 9 | +#Persistent ; Keeps script permanently running. |
| 10 | +#SingleInstance force ; Ensures that there is only a single instance of this script running. |
| 11 | +; SetTitleMatchMode, 2 ; sets title matching to search for "containing" instead of "exact" |
| 12 | +#MaxHotkeysPerInterval 2000 |
| 13 | +#WinActivateForce ;https://autohotkey.com/docs/commands/_WinActivateForce.htm |
| 14 | + |
| 15 | +; The 2 lines below pertain to the 'reload on save' function below (CheckScriptUpdate). |
| 16 | +; They are required for it to work. |
| 17 | +;FileGetTime ScriptStartModTime, %A_ScriptFullPath% |
| 18 | +;SetTimer CheckScriptUpdate, 100, 0x7FFFFFFF ; 100 ms, highest priority |
| 19 | + |
| 20 | +Menu, Tray, Icon, imageres.dll, 251 ; this changes the tray icon to a filmstrip! |
| 21 | +;===== INITIALIZATION - VARIABLES ============================================================== |
| 22 | +; Sleep shortcuts - use these to standardize sleep times. Change here to change everywhere. |
| 23 | +sleepMicro := 15 |
| 24 | +sleepShort := 333 |
| 25 | +sleepMedium := 666 |
| 26 | +sleepLong := 1500 |
| 27 | +sleepDeep := 3500 |
| 28 | + |
| 29 | +splashScreenX = %1% |
| 30 | +splashScreenY = %2% |
| 31 | +splashScreenTimeout = %3% |
| 32 | + |
| 33 | +#include %A_ScriptDir%\..\LIB\gdip.ahk |
| 34 | +;Thanks to tic (Tariq Porter) for his GDI+ Library |
| 35 | +;ahkscript.org/boards/viewtopic.php?t=6517 |
| 36 | + |
| 37 | +If !pToken := Gdip_Startup() ; this is here just to test that the GDI+ library is available at the path in the above #include |
| 38 | +{ |
| 39 | + MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system |
| 40 | + ExitApp |
| 41 | +} |
| 42 | +OnExit, GdiplusExit |
| 43 | + |
| 44 | +;===== SPLASH SCREEN TO ANNOUNCE WHAT SCRIPT DOES ============================================== |
| 45 | +SplashTextOn, 600, 100, Launching %A_ScriptFullPath%, Loading AFTER EFFECTS HOTKEYS Script. |
| 46 | +WinMove, Launching %A_ScriptFullPath%, , %splashScreenX%, %splashScreenY% |
| 47 | +SetTimer, RemoveSplashScreen, %splashScreenTimeout% |
| 48 | +;===== END OF AUTO-EXECUTE ===================================================================== |
| 49 | + |
| 50 | +;===== MODIFIER MEMORY HELPER ================================================================== |
| 51 | +; combine below with key and '::' to define hotkey |
| 52 | +; e.g.- ^f1::Msgbox You pressed Control and F1 |
| 53 | +; #=Win | !=Alt | ^=Ctrl | +=Shift | &=combine keys | *=ignore other mods |
| 54 | +; <=use left mod key| >=use right mod key | UP=fires on release |
| 55 | + |
| 56 | +;===== MAIN HOTKEY DEFINITIONS HERE ============================================================ |
| 57 | + |
| 58 | +;===== AFTER EFFECTS HOTKEY DEFINITIONS HERE ============================================ |
| 59 | + |
| 60 | +#IfWinActive, ahk_exe AfterFX.exe |
| 61 | + |
| 62 | +F13:: ; <- In Timeline, Select All then collapse/open effects/animated on all tracks |
| 63 | + MouseGetPos, xpos, ypos |
| 64 | + halfScreenHeight := (A_ScreenHeight / 2) |
| 65 | + ;MSGBOX, , DEBUG, X: %xpos%`nY:%ypos%`nScreen Height:%A_ScreenHeight%`nhalfScreenHeight:%halfScreenHeight% |
| 66 | + If (ypos < halfScreenHeight) { |
| 67 | + ToolTip, Make sure to fire this hotkey when Timeline has focus. |
| 68 | + RemoveToolTip(3000) |
| 69 | + } |
| 70 | + |
| 71 | + Send, {Control Down}a{Control Up} |
| 72 | + Sleep, sleepShort |
| 73 | + Send, u |
| 74 | + Return |
| 75 | + |
| 76 | + |
| 77 | +#IfWinActive |
| 78 | + |
| 79 | + |
| 80 | +;===== ILLUSTRATOR HOTKEY DEFINITIONS HERE ============================================ |
| 81 | + |
| 82 | +/* |
| 83 | +
|
| 84 | +THIS BLOCK IS JUST HERE FOR REFERENCE ON USING 'clickradar()' FUNCTION |
| 85 | +
|
| 86 | +#IfWinActive, ahk_exe Illustrator.exe |
| 87 | +
|
| 88 | ++^!F6:: ; <-- Clicking on 'Vertical Distribute Center' FOR MIXED OBJECTS |
| 89 | + ;- why can't this be assigned a key board shortcut in Illustrator?!? |
| 90 | + ; 'clickRadar' is a function below. You give it the coordinates you want to click & it does the rest. |
| 91 | + clickRadar(1056,66) |
| 92 | + Return |
| 93 | +
|
| 94 | +#IfWinActive |
| 95 | +*/ |
| 96 | +;===== END SCAF DEFINITIONS =============================================================== |
| 97 | + |
| 98 | +;===== FUNCTIONS =============================================================================== |
| 99 | + |
| 100 | +RemoveSplashScreen: |
| 101 | + SplashTextOff |
| 102 | + SetTimer RemoveSplashScreen, Off |
| 103 | + return |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +; use this function to Remove ToolTips - pretty self-explanatory - 'duration' should be given in milliseconds (4000 = 4 seconds) |
| 108 | +RemoveToolTip(duration) { |
| 109 | + SetTimer, ToolTipOff, %duration% |
| 110 | + Return |
| 111 | + |
| 112 | +ToolTipOff: |
| 113 | + ToolTip |
| 114 | + return |
| 115 | +} |
| 116 | + |
| 117 | +; This function will auto-reload the script on save. |
| 118 | +CheckScriptUpdate() { |
| 119 | + global ScriptStartModTime |
| 120 | + FileGetTime curModTime, %A_ScriptFullPath% |
| 121 | + If (curModTime <> ScriptStartModTime) { |
| 122 | + Loop |
| 123 | + { |
| 124 | + reload |
| 125 | + Sleep 300 ; ms |
| 126 | + MsgBox 0x2, %A_ScriptName%, Reload failed. ; 0x2 = Abort/Retry/Ignore |
| 127 | + IfMsgBox Abort |
| 128 | + ExitApp |
| 129 | + IfMsgBox Ignore |
| 130 | + break |
| 131 | + } ; loops reload on "Retry" |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +; clickRadar is used to show a yellow-circle.png centered on the coords you send the function. The idea is that they should be centered on the coords you will be clicking on. |
| 136 | +; to get the transparency working, we need to use the GDI+ library |
| 137 | +; Based on the tutorial here: https://github.com/tariqporter/Gdip/blob/master/Gdip.Tutorial.3-Create.Gui.From.Image.ahk |
| 138 | +clickRadar(sx,sy){ |
| 139 | + global sleepShort |
| 140 | + ; we are going to store the position of your cursor when you show this so that we can put the cursor back where it was |
| 141 | + ;coordmode, mouse, Screen |
| 142 | + MouseGetPos, xposP, yposP |
| 143 | + offsetSX := (sx - 25) |
| 144 | + offsetSY := (sy - 25) |
| 145 | + ;MSgBox, Sent: %sx%, %sy%`nOffset: %offsetSX%, %offsetSY%`nGrabbed: %xposP%, %yposP% |
| 146 | + ; this is all blackmagic provided by GDI+ |
| 147 | + Gui, ShowPicture: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +hwndhwnd +alwaysontop |
| 148 | + Gui, ShowPicture: Show, NA ,dialog |
| 149 | + |
| 150 | + pBitmap:=Gdip_CreateBitmapFromFile("yellow-circle.png") |
| 151 | + Gdip_GetImageDimensions(pBitmap,w,h) |
| 152 | + |
| 153 | + hbm := CreateDIBSection(w,h) |
| 154 | + hdc := CreateCompatibleDC() |
| 155 | + obm := SelectObject(hdc, hbm) |
| 156 | + pGraphics:=Gdip_GraphicsFromHDC(hdc) |
| 157 | + |
| 158 | + Gdip_DrawImage(pGraphics, pBitmap, 0,0,w,h) |
| 159 | + UpdateLayeredWindow(hwnd, hdc,offsetSX,offsetSY,w,h) |
| 160 | + Gdip_DisposeImage(pBitmap) |
| 161 | + sleep, sleepShort |
| 162 | + destroyGDIplusGUI() |
| 163 | + Click, %sx%, %sy% |
| 164 | + MouseMove, xposP, yposP, 0 ; returning cursor where it was |
| 165 | +return |
| 166 | +} |
| 167 | + |
| 168 | +destroyGDIplusGUI(){ ; this should not only kill the ShowPicture but free up everything it used and reset things for the next time a CheatSheet is shown (we want showPicture to be set to 0) |
| 169 | + ; Now the bitmap may be deleted |
| 170 | + DeleteObject(hbm) |
| 171 | + |
| 172 | + ; Also the device context related to the bitmap may be deleted |
| 173 | + DeleteDC(hdc) |
| 174 | + |
| 175 | + ; The graphics may now be deleted |
| 176 | + Gdip_DeleteGraphics(G) |
| 177 | + |
| 178 | + ; The bitmap we made from the image may be deleted |
| 179 | + Gdip_DisposeImage(pBitmap) |
| 180 | + showPicture = 0 |
| 181 | +Gui, ShowPicture:Destroy |
| 182 | + Return |
| 183 | +} |
| 184 | + |
| 185 | +GdiplusExit: |
| 186 | +; gdi+ may now be shutdown on exiting the program |
| 187 | +Gdip_Shutdown(pToken) |
| 188 | +ExitApp |
0 commit comments