Last active
April 20, 2025 12:36
-
-
Save JoeGlines/327e9fd51157063a3b18049f14858f46 to your computer and use it in GitHub Desktop.
AutoHotkey v1 code for pausing vlc player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v1.1.33+ | |
#SingleInstance,Force | |
Menu, tray, icon, vlc.ico, 1 ;update this to your path to icon | |
Browser_Forward::Reload | |
;****************************** | |
Browser_Back:: ;Set your hotkey to play/pause here | |
ControlSend,,{space},ahk_exe vlc.exe ;Send space to VLC player control | |
Clipboard:=ACCGet("Name","4.3.3.1",0, "ahk_exe vlc.exe") "`t" ;Get the current time stamp and add tab | |
word := ComObjActive("Word.Application") ;If you're using Word, this will connect to MS word | |
word.Selection.Paste() ;And this will paste the time and tab in MS word | |
return | |
;********************Functions from ACC lib*********************************** | |
ACCGet(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") { | |
static properties := {Action:"DefaultAction", DoAction:"DoDefaultAction", Keyboard:"KeyboardShortcut"} | |
AccObj := IsObject(WinTitle)? WinTitle | |
: ACCObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 ) | |
if ComObjType(AccObj, "Name") != "IAccessible" | |
ErrorLevel := "Could not access an IAccessible Object" | |
else { | |
StringReplace, ChildPath, ChildPath, _, %A_Space%, All | |
AccError:=ACCError(), ACCError(true) | |
Loop Parse, ChildPath, ., %A_Space% | |
try { | |
if A_LoopField is digit | |
Children:=ACCChildren(AccObj), m2:=A_LoopField ; mimic "m2" output in else-statement | |
else | |
RegExMatch(A_LoopField, "(\D*)(\d*)", m), Children:=ACCChildrenByRole(AccObj, m1), m2:=(m2?m2:1) | |
if Not Children.HasKey(m2) | |
throw | |
AccObj := Children[m2] | |
} catch { | |
ErrorLevel:="Cannot access ChildPath Item #" A_Index " -> " A_LoopField, ACCError(AccError) | |
if ACCError() | |
throw Exception("Cannot access ChildPath Item", -1, "Item #" A_Index " -> " A_LoopField) | |
return | |
} | |
ACCError(AccError) | |
StringReplace, Cmd, Cmd, %A_Space%, , All | |
properties.HasKey(Cmd)? Cmd:=properties[Cmd]: | |
try { | |
if (Cmd = "Location") | |
AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId) | |
, ret_val := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int") | |
else if (Cmd = "Object") | |
ret_val := AccObj | |
else if Cmd in Role,State | |
ret_val := ACC%Cmd%(AccObj, ChildID+0) | |
else if Cmd in ChildCount,Selection,Focus | |
ret_val := AccObj["acc" Cmd] | |
else | |
ret_val := AccObj["acc" Cmd](ChildID+0) | |
} catch { | |
ErrorLevel := """" Cmd """ Cmd Not Implemented" | |
if ACCError() | |
throw Exception("Cmd Not Implemented", -1, Cmd) | |
return | |
} | |
return ret_val, ErrorLevel:=0 | |
} | |
if ACCError() | |
throw Exception(ErrorLevel,-1) | |
} | |
ACCObjectFromWindow(hWnd, idObject = 0){ | |
ACCInit() | |
If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0 | |
Return ComObjEnwrap(9,pacc,1) | |
} | |
ACCChildren(Acc) { | |
if ComObjType(Acc,"Name") != "IAccessible" | |
ErrorLevel := "Invalid IAccessible Object" | |
else { | |
ACCInit(), cChildren:=Acc.accChildCount, Children:=[] | |
if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 { | |
Loop %cChildren% | |
i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?ACCQuery(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child): | |
return Children.MaxIndex()?Children: | |
} else | |
ErrorLevel := "AccessibleChildren DllCall Failed" | |
} | |
if ACCError() | |
throw Exception(ErrorLevel,-1) | |
} | |
AccError(p="") { | |
static setting:=0 | |
return p=""?setting:setting:=p | |
} | |
AccChildrenByRole(Acc, Role){ | |
if ComObjType(Acc,"Name")!="IAccessible" | |
ErrorLevel := "Invalid IAccessible Object" | |
else { | |
ACCInit(), cChildren:=Acc.accChildCount, Children:=[] | |
if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 { | |
Loop %cChildren% { | |
i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i) | |
if NumGet(varChildren,i-8)=9 | |
AccChild:=AccQuery(child), ObjRelease(child), ACCRole(AccChild)=Role?Children.Insert(AccChild): | |
else | |
AccRole(Acc, child)=Role?Children.Insert(child): | |
} | |
return Children.MaxIndex()?Children:, ErrorLevel:=0 | |
} else | |
ErrorLevel := "AccessibleChildren DllCall Failed" | |
} | |
if ACCError() | |
throw Exception(ErrorLevel,-1) | |
} | |
AccInit(){ | |
Static h | |
If Not h | |
h:=DllCall("LoadLibrary","Str","oleacc","Ptr") | |
} | |
AccQuery(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530 | |
try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1) | |
} | |
AccRole(Acc, ChildId=0) { | |
try return ComObjType(Acc,"Name")="IAccessible"?AccGetRoleText(Acc.accRole(ChildId)):"invalid object" | |
} | |
AccGetRoleText(nRole){ | |
nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0) | |
VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize) | |
DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1) | |
Return sRole | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment