AHK ROCKS!!! Script for AUTOMATIC plugin window positioning (at custom coord)!!!!

Discuss how to use FL Studio

Return to “FL Studio Users Forum (Looptalk)”

Forum rules
Please read them here.
[You can only see part of this thread as you are not logged in to the forums]
D3Mens
Sat Nov 17, 2018 3:04 pm

x

AHK ROCKS!!! Script for AUTOMATIC plugin window positioning (at custom coord)!!!!

I'm happy to announce that I've just found a way to automatically open on specific coordinates any (detached) plugin window!!!
I repeat: automatically!

(many thanks to MasterFocus and Lexikos from AHK forum)


The script will act any time you'll add a new generator, or effect, and also whenever you'll open that generator/effect from it's channel rack button or mixer slot button.
Basically you wil not need to move your head anymore nor search where your plugins are buried, you will always know where those will popup.

The script works also with any program, window, etc as long as it has a unique ahk_class. Basically it checks currently open windows every 200ms. You can set it as you like, but 200 is already good. Not CPU heavy at all on my machine.

Inside the script you'll find three examples:
1) Notepad
2) Generator and Effect windows (they share the same class, so no way to differenciate them)
3) Fab Filter Pro L-2 (example of a specific plugin)

+ the instructions on how to add as many programs/windows as you want to the list.

I really don't know what to say, I'm so excited!! XD



Here's the code:

Code: Select all

;========================================================================
; 
; Template:     WinTrigger (former OnOpen/OnClose)
; Description:  Act upon (de)activation/(un)existance of programs/windows
; Online Ref.:  http://www.autohotkey.com/forum/topic43826.html#267338
; * WARNING *   Online version (above) is the old OnOpen/OnClose template!
;
; Last Update:  15/Mar/2010 17:30
;
; Created by:   MasterFocus
;               https://ahknet.autohotkey.com/~MasterFocus/AHK/
;
; Thanks to:    Lexikos, for improving it significantly
;
;========================================================================
;
; This template contains two examples by default. You may remove them.
;
; * HOW TO ADD A PROGRAM to be checked upon (de)activation/(un)existance:
;
; 1. Add a variable named ProgWinTitle# (Configuration Section)
; containing the desired title/ahk_class/ahk_id/ahk_group
;
; 2. Add a variable named WinTrigger# (Configuration Section)
; containing the desired trigger ("Exist" or "Active")
;
; 3. Add labels named LabelTriggerOn# and/or LabelTriggerOff#
; (Custom Labels Section) containing the desired actions
;
; 4. You may also change CheckPeriod value if desired
;
;========================================================================

#Persistent
SetTitleMatchMode, 2
; ------ ------ CONFIGURATION SECTION ------ ------

; Program Titles
ProgWinTitle1 = ahk_class Notepad ahk_exe notepad.exe
WinTrigger1 = Exist
ProgWinTitle2 = ahk_class TPluginForm
WinTrigger2 = Active
ProgWinTitle3 = FabFilter Pro-L 2 ahk_class TPluginForm
WinTrigger3 = Active 

; SetTimer Period
CheckPeriod = 200

; ------ END OF CONFIGURATION SECTION ------ ------

SetTimer, LabelCheckTrigger, %CheckPeriod%
Return

; ------ ------ ------

LabelCheckTrigger:
  While ( ProgWinTitle%A_Index% != "" && WinTrigger := WinTrigger%A_Index% )
    if ( !ProgRunning%A_Index% != !Win%WinTrigger%( ProgWinTitle := ProgWinTitle%A_Index% ) )
      GoSubSafe( "LabelTriggerO" ( (ProgRunning%A_Index% := !ProgRunning%A_Index%) ? "n" : "ff" ) A_Index )
Return

; ------ ------ ------

GoSubSafe(mySub)
{
  if IsLabel(mySub)
    GoSub %mySub%
}

; ------ ------ CUSTOM LABEL SECTION ------ ------

LabelTriggerOn1:
WinMove, %ProgWinTitle1%, , 0, 0, ;sizeX, sizeY
return

LabelTriggerOn2:
WinMove, %ProgWinTitle2%, , 0, 400, ;sizeX, sizeY
return

LabelTriggerOn3:
WinMove, %ProgWinTitle3%, , 200, 400 ;sizeX, sizeY
return

; ------ END OF CUSTOM LABEL SECTION ------ ------


To make it work you need also this second script: save this script as "WinTrigger1.ahk" and place it in the same folder as the main one. You just need to run the main script.

Code: Select all

; Online Ref.:  http://www.autohotkey.com/forum/viewtopic.php?t=63673
;
; Last Update:  15/Mar/2010 17:30
;
; Created by:   MasterFocus
;               http://www.autohotkey.net/~MasterFocus/AHK/
;
; Thanks to:    Lexikos, for improving it significantly
;               http://www.autohotkey.com/forum/topic43826.html#267338
;
;========================================================================
;
; This template contains two examples by default. You may remove them.
;
; * HOW TO ADD A PROGRAM to be checked upon (de)activation/(un)existance:
;
; 1. Add a variable named ProgWinTitle# (Configuration Section)
; containing the desired title/ahk_class/ahk_id/ahk_group
;
; 2. Add a variable named WinTrigger# (Configuration Section)
; containing the desired trigger ("Exist" or "Active")
;
; 3. Add labels named LabelTriggerOn# and/or LabelTriggerOff#
; (Custom Labels Section) containing the desired actions
;
; 4. You may also change CheckPeriod value if desired
;
;========================================================================

#Persistent

; ------ ------ CONFIGURATION SECTION ------ ------

SetActiveWindow(window, number, trigger="Active")
{
	global ProgWinTitle1
	ProgWinTitle%number% := window
	global WinTrigger1
	WinTrigger1 := trigger
	TrayTip, CompassAHKTweaks, % "Active window is " . ProgWinTitle1 . "`nTrigger: " . WinTrigger1
}

; SetTimer Period
CheckPeriod = 200

; ------ END OF CONFIGURATION SECTION ------ ------

SetTimer, LabelCheckTrigger, %CheckPeriod%
Return

; ------ ------ ------

LabelCheckTrigger:
  While ( ProgWinTitle%A_Index% != "" && WinTrigger := WinTrigger%A_Index% )
    if ( !ProgRunning%A_Index% != !Win%WinTrigger%( ProgWinTitle := ProgWinTitle%A_Index% ) )
      GoSubSafe( "LabelTriggerO" ( (ProgRunning%A_Index% := !ProgRunning%A_Index%) ? "n" : "ff" ) A_Index )
Return

; ------ ------ ------

GoSubSafe(mySub)
{
  if IsLabel(mySub)
    GoSub %mySub%
}

; ------ ------ CUSTOM LABEL SECTION ------ ------

LabelTriggerOn1:
	
return
LabelTriggerOff1:
	TrayTip, CompassAHKTweaks, % "Focus lost. Attempting to regain"
	WinActivate, % ProgWinTitle1
return
LabelTriggerOn2:
Return
LabelTriggerOff2:
return

; ------ END OF CUSTOM LABEL SECTION ------ ------


Enjoy!!!


Madma




Return to “FL Studio Users Forum (Looptalk)”