VLC and Blender Script

Post your working scripts, libraries and tools for AHK v1.1 and older
SteveR359
Posts: 2
Joined: 23 Sep 2018, 05:55

VLC and Blender Script

23 Sep 2018, 08:05

I do a lot of 3D modelling and stuff in Blender - and use a lot of video tutorials. A real pain is having to switch between VLC and Blender to pause, skip back 5 seconds and so on during the videos. So I have had a go at using AHK to remedy this. My script allows me to uses the keys Ctrl=Windows+left/right/space to skip forwards, backwards or pause/start in VLC whilst ensuring the Blender window remains in focus after th VLC action. This is my first AHK script so it may not be elegant in any shape of form but seems to work. Posting in case useful top others - easily adapted to other apps. Also if there are better ways of achieving the same results I'd be interested to hear if you have the time to post the info.
Best
Steve

#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.

#SingleInstance force

; VLC Short Skip Backwards - ctrl+windows+left trigger
^#left::
if WinExist("ahk_exe vlc.exe")
WinActivate, ahk_exe vlc.exe
Send, +{left}
WinActivate, ahk_exe blender.exe
return


; VLC Short Skip Forwards - ctrl+windows+right trigger
^#right::
if WinExist("ahk_exe vlc.exe")
WinActivate, ahk_exe vlc.exe
Send, +{right}
WinActivate, ahk_exe blender.exe
return

; VLC Pause - ctrl+windows+space trigger
^#space::
if WinExist("ahk_exe vlc.exe")
WinActivate, ahk_exe vlc.exe
Send, {space}
WinActivate, ahk_exe blender.exe
return
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: VLC and Blender Script

23 Sep 2018, 09:21

different way, not necessarily better per se, but different:

Code: Select all

#NoEnv 
#SingleInstance force
SendMode Input 
SetWorkingDir %A_ScriptDir% 

fn := Func("mySendFunc")
for key, modifier in {"left": "+", "right": "+", "space": ""}
{
	bf := fn.Bind(modifier "{" key "}")
	Hotkey % "^#" key, % bf
}

mySendFunc(arg) {
	static VLC_EXE := "ahk_exe vlc.exe"
		, BLENDER_EXE := "ahk_exe blender.exe"

	if WinExist(VLC_EXE) ; is this check even necessary 
		WinActivate % VLC_EXE

	Send % arg

	WinActivate % BLENDER_EXE
}
SteveR359
Posts: 2
Joined: 23 Sep 2018, 05:55

Re: VLC and Blender Script

24 Sep 2018, 13:27

Hi Swag, thank you for this - this is useful and helps me to understand AHK. I can reverse engineer this with the help file. The advantage of your approach is that it is easier to add more controls to it whilst keeping the code short - thank you for taking the time to post :) Appreciate it :)
radi0n
Posts: 6
Joined: 13 Jul 2019, 16:41

Re: VLC and Blender Script

21 Jan 2020, 09:19

Hello,

it is possible to make this script working with Media Player Classic instead of VLC?
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: VLC and Blender Script

21 Jan 2020, 15:48

Sure, if you know the window properties and the keyboard shortcuts for MPC
ciao
toralf

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 113 guests