Sunday, September 13, 2015

windows 7 - Disable ALT Functionality after an Application starts using AutoHotKey


I was looking for a way to disable the alt functionality that prepares a mnemonic-capable menu to be used with the keyboard, waiting for a letter to be pressed but, apparently, this isn't possible by Windows itself, at least not Windows 7 (I don't know others).


The issue is just with Adobe Premiere in which the alt is used, among other things, to zoom in and out the timeline/sequence and I do this a lot because I do frame-by-frame lip-sync.


Thing is that when I release the alt key, sometimes, its menu-related functionality remains and an immediate use of the arrow keys to move the... cursor? in the timeline/sequence instead of navigating through the video frames, I navigate through the menus.


Although frustrating, by pressing alt again immediately after stop scrolling up/down the mouse wheel, I can keep a continuous working flow. It's just for a millisecond, but just extrapolate this to a very time-consuming task in which 2-3 minutes may take 2-3 hours to finish.


Anyway... While searching for an alternative approach I've found someone with the same problem but with Adobe Photoshop and someone else suggested both an app called apssistant that sadly it is only for Photoshop, but also a solution with AutoHotKey.


I always tried to avoid AHK because I never liked programs running in the background and, in this particular case, every bit of memory and/or processing power is vital, considering I don't have top hardware configuration. Last time my PC stopped worked several times because of the complexity of the project with Premiere consuming more than 7GB of RAM.


But I gave it a shot combining the original suggestion:


#NoEnv
; #Warn ;
~LAlt::
KeyWait, LAlt
return
~LAlt Up::
Send, {LAlt Up}
return


I'm positive that this works because I tested in a Windows Explorer window and, although the menu blinks, it doesn't fire.



with a way to trigger Premiere -AND- run the script altogether:


#NoEnv
; #Warn ;#Persistent ;Script will not Exit when no hotkeys exist.
Run, "C:\Program Files\Adobe\Adobe Premiere Pro CC 2017\Adobe Premiere Pro.exe"
SetTitleMatchMode, 2 ;Program Title can be portions of the title instead of the full title
SetTimer, CheckPrograms, 1000 ;Run CheckPrograms subroutine every 1 second
return
CheckPrograms:
IfWinExist, Premiere
{
Run, DisableALTFunctionality.ahk
;PremiereTrack = 1
}
IfWinNotExist, Premiere
;PremiereTrack = 0
Exitapp
return

But as far as I could tell, this didn't work because when Premiere finally loaded (no SSD here yet) I opened my last project and the ALT functionality was still in place.


I'm running the second script through a shortcut in my Desktop, both scripts are in the same directory and AHK files are correctly configured to run with AutoHotScript x64 manually (portable version) — the tray icon shows that the script running is indeed DisableALTFunctionality.ahk.


But even increasing the timeout to something like 5 minutes, I didn't have any success.


Answer



You can use the #If- or the #IfWinActive- directive to disable the ALT Functionality in this program:


#NoEnv
; #Warn ;#Persistent ; Script will not Exit when no hotkeys exist.
SetTitleMatchMode, 2 ; Program Title can be portions of the title instead of the full
#IfWinActive, Premiere
LAlt::
RAlt:: return ; do nothing
!WheelDown:: Send, {Alt Down}{WheelDown}{Alt Up} ; ! means Alt
!WheelUp:: Send, {Alt Down}{WheelUp}{Alt Up}
#IfWinActive ; turn off context sensitivity

Try also:


#NoEnv
; #Warn ;#Persistent ; Script will not Exit when no hotkeys exist.
SetTitleMatchMode, 2 ; Program Title can be portions of the title instead of the full
#IfWinActive, Premiere
LAlt up::
If (A_PriorKey = "LAlt") ; If LAlt was pressed alone
return ; do nothing
return
; In this case its necessary to define a custom combination by using "LAlt &" or " ; to avoid that LAlt loses its original function as a modifier key:
#IfWinActive ; turn off context sensitivity

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...