I was reading this today and I discovered the ApplyTemplate command, I've refactored my Window swaping script to use it
Code:
<Command LaunchAndRename>
<SendPC local>
<Run "C:\Users\Public\Games\World of Warcraft\WoW.exe">
<RenameTargetWin %1%>
<Template SetWin>
<Command SetWin%1%>
<SetVar Win%1% %2%>
<TargetWin %2%>
<SetWinPos %3% %4%>
<SetWinSize %5% %6%>
<UpdateWin>
<EndTemplate>
<ApplyTemplate SetWin 1 "%1%" "0" "0" "965" "795">
<ApplyTemplate SetWin 2 "%1%" "0" "795" "965" "795">
<ApplyTemplate SetWin 3 "%1%" "965" "0" "795" "660">
<ApplyTemplate SetWin 4 "%1%" "1760" "0" "795" "660">
<ApplyTemplate SetWin 5 "%1%" "965" "660" "1135" "930">
<Command DefaultWindowLayout>
<SetWin1 WoW5>
<SetWin2 WoW4>
<SetWin3 WoW3>
<SetWin4 WoW2>
<SetWin5 WoW1>
<Template Swap>
<Command Swap%1%And%2%>
<SetWin%1% %3%>
<SetWin%2% %4%>
<EndTemplate>
<ApplyTemplate Swap 1 5 "%2%" "%1%">
<ApplyTemplate Swap 2 5 "%2%" "%1%">
<ApplyTemplate Swap 3 5 "%2%" "%1%">
<ApplyTemplate Swap 4 5 "%2%" "%1%">
<Command AutoExec>
// Initialise the HKN indicator
<DoHotKey Hotkey NumLockOn Alt Ctrl Shift H>
// Initialise the AWT indicator
<DoHotKey Hotkey NumLockOn Alt Ctrl Shift A>
// turn hotkeys off
<DoHotKey Hotkey NumLockOn Alt Ctrl Shift T>
<SetActiveWindowTracking Off>
<SetVar ActOff true>
<DefaultWindowLayout>
<Hotkey NumLockOn Alt Ctrl Shift H>
<If WinDoesNotExist HKN>
<CreatePanel HKN 2500 1535 30 30>
<TargetWin HKN>
<CreateColoredButton ON 0 0 30 30 0x00FF00 0x0F0F0F ???>
<AddButtonToPanel ON HKN>
<SetButtonText ON HKN>
<TargetWin HKN>
<AlwaysOnTop on>
<RemoveWinFrame>
<UpdateWin>
<EndIf>
<SetButtonColors ON 0xfF0000 0xffFFff >
<SetButtonText ON off>
<Hotkey NumLockOn Alt Ctrl Shift A>
<If WinDoesNotExist AWT>
<CreatePanel AWT 2400 1535 30 30>
<TargetWin AWT>
<CreateColoredButton ACT 0 0 30 30 0x0000FF 0xFFFFFF ???>
<AddButtonToPanel ACT AWT>
<SetButtonText ACT AWT>
<TargetWin AWT>
<AlwaysOnTop on>
<RemoveWinFrame>
<UpdateWin>
<endif>
<SetButtonColors ACT 0xfF0000 0xffFFff >
<SetButtonText ACT off>
<Hotkey NumLockOn Alt Ctrl Shift T>
<If HotkeysAreOn>
<TurnHotkeysOff>
<EndIf>
<Template Conditional1>
<Hotkey Alt Ctrl Shift %1%>
<If Win5 Is WoW%2%>
<Swap%3%And5 WoW%4% WoW%2%>
<Else If Win5 Is WoW%5%>
<Swap%3%And5 WoW%4% WoW%5%>
<EndIf>
<EndTemplate>
<Template Conditional2>
<Hotkey Alt Ctrl Shift %1%>
<If Win5 Is WoW%2%>
<Swap%3%And5 WoW%4% WoW%2%>
<Else If Win5 Is WoW%5%>
<Swap%3%And5 WoW%4% WoW%5%>
<Else>
<DoHotkey Hotkey Alt Ctrl Shift %6%>
<EndIf>
<EndTemplate>
<Template Conditional3>
<Hotkey Alt Ctrl Shift %1%>
<If Win3 Is WoW%2%>
<DoHotkey Hotkey Alt Ctrl Shift %3%>
<Else If Win4 Is WoW%2%>
<DoHotkey Hotkey Alt Ctrl Shift %4%>
<EndIf>
<EndTemplate>
<Template Conditional4>
<Hotkey Alt Ctrl Shift %1%>
<If Win%2% Is WoW%3%>
<DoHotkey Hotkey Alt Ctrl Shift %4%>
<Else>
<DoHotkey Hotkey Alt Ctrl Shift %5%>
<EndIf>
<EndTemplate>
<ApplyTemplate Conditional1 Oem2 4 4 1 5>
<ApplyTemplate Conditional2 Period 2 4 1 3 Oem2>
<ApplyTemplate Conditional1 Comma 4 3 1 5>
<ApplyTemplate Conditional2 M 2 3 1 3 Comma>
<ApplyTemplate Conditional3 N 1 M Period>
<ApplyTemplate Conditional1 B 4 2 1 5>
<ApplyTemplate Conditional2 V 2 2 1 3 B>
<ApplyTemplate Conditional4 C 2 1 V N>
<ApplyTemplate Conditional1 X 4 1 1 5>
<ApplyTemplate Conditional2 Z 2 1 1 3 X>
<ApplyTemplate Conditional4 "Oem5; Alt Ctrl F1" 1 1 Z C>
<ApplyTemplate Conditional1 Oem3 4 4 2 5>
<ApplyTemplate Conditional2 Oem1 1 4 2 3 Oem3>
<ApplyTemplate Conditional1 L 4 3 2 5>
<ApplyTemplate Conditional2 K 1 3 2 3 L>
<ApplyTemplate Conditional3 J 2 K Oem1>
<ApplyTemplate Conditional1 H 4 2 2 5>
<ApplyTemplate Conditional2 G 1 2 2 3 H>
<ApplyTemplate Conditional4 F 2 2 G J>
<ApplyTemplate Conditional1 D 4 1 2 5>
<ApplyTemplate Conditional2 S 1 1 2 3 D>
<ApplyTemplate Conditional4 "A; Alt Ctrl F2" 1 2 S F>
<ApplyTemplate Conditional1 Oem4 4 4 3 5>
<ApplyTemplate Conditional2 P 1 4 3 2 Oem4>
<ApplyTemplate Conditional1 O 4 3 3 5>
<ApplyTemplate Conditional2 I 1 3 3 2 O>
<ApplyTemplate Conditional3 U 3 I P>
<ApplyTemplate Conditional1 Y 4 2 3 5>
<ApplyTemplate Conditional2 T 1 2 3 2 Y>
<ApplyTemplate Conditional4 R 2 3 T U>
<ApplyTemplate Conditional1 E 4 1 3 5>
<ApplyTemplate Conditional2 W 1 1 3 2 E>
<ApplyTemplate Conditional4 "Q; Alt Ctrl F3" 1 3 W R>
<ApplyTemplate Conditional1 plus 3 4 4 5>
<ApplyTemplate Conditional2 minus 1 4 4 2 plus>
<ApplyTemplate Conditional1 0 3 3 4 5>
<ApplyTemplate Conditional2 9 1 3 4 2 0>
<ApplyTemplate Conditional1 8 3 2 4 5>
<ApplyTemplate Conditional1 7 3 4 5 4>
<ApplyTemplate Conditional2 6 1 4 5 2 7>
<ApplyTemplate Conditional1 5 3 3 5 4>
<ApplyTemplate Conditional2 4 1 3 5 2 5>
<ApplyTemplate Conditional3 3 4 9 minus>
<ApplyTemplate Conditional2 2 1 2 4 2 8>
<ApplyTemplate Conditional1 1 3 1 4 5>
<ApplyTemplate Conditional4 F12 2 4 2 3>
<ApplyTemplate Conditional2 F11 1 1 4 2 1>
<ApplyTemplate Conditional4 "F10; Alt Ctrl F4" 1 4 F11 F12>
<ApplyTemplate Conditional4 "F9; Alt Ctrl F5" 1 5 F1 F3>
<ApplyTemplate Conditional1 F8 3 2 5 4>
<ApplyTemplate Conditional2 F7 1 2 5 2 F8>
<Hotkey Alt Ctrl Shift F6>
<If MouseIsOverWindow WoW1>
<DoHotkey Hotkey Alt Ctrl Shift Oem5>
<EndIf>
<Hotkey Alt Ctrl Shift F5>
<If MouseIsOverWindow WoW3>
<DoHotkey Hotkey Alt Ctrl Shift Q>
<Else If MouseIsOverWindow WoW2>
<DoHotkey Hotkey Alt Ctrl Shift A>
<Else>
<DoHotkey Hotkey Alt Ctrl Shift F6>
<EndIf>
<ApplyTemplate Conditional3 F4 5 4 6>
<ApplyTemplate Conditional4 F3 2 5 F7 F4>
<ApplyTemplate Conditional1 F2 3 1 5 4>
<ApplyTemplate Conditional2 F1 1 1 5 2 F2>
<Hotkey Alt Ctrl X>
<DisplayVars>
<If MouseIsOverWindow WoW5>
<DoHotkey Hotkey Alt Ctrl Shift F9>
<Else If MouseIsOverWindow WoW4>
<DoHotkey Hotkey Alt Ctrl Shift F10>
<Else>
<DoHotkey Hotkey Alt Ctrl Shift F5>
<EndIf>
<Label w1 Local SendWinM WoW1>
<Label w2 Local SendWinM WoW2>
<Label w3 Local SendWinM WoW3>
<Label w4 Local SendWinM WoW4>
<Label w5 Local SendWinM WoW5>
<KeyList TheKeyList 0-9, Plus, Minus, F2>
<Hotkey LCtrl TheKeyList; LAlt TheKeyList>
<SendLabel w4>
<Key %Trigger%>
<Hotkey TheKeyList>
<SendLabel w1, w2, w3, w4, w5>
<Key %Trigger%>
<Hotkey Alt Ctrl L>
<SetTaskbarAutoHide On>
<LaunchAndRename WoW1>
<LaunchAndRename WoW2>
<LaunchAndRename WoW3>
<LaunchAndRename WoW4>
<LaunchAndRename WoW5>
<DefaultWindowLayout>
<Template Launch>
<Hotkey Alt Ctrl %1%>
<If WinDoesNotExist WoW%1%>
<LaunchAndRename WoW%1%>
<DefaultWindowLayout>
<EndIf>
<EndTemplate>
<ApplyTemplate Launch 1>
<ApplyTemplate Launch 2>
<ApplyTemplate Launch 3>
<ApplyTemplate Launch 4>
<ApplyTemplate Launch 5>
<Hotkey pause>
<sendpc local>
<If HotkeysAreOff>
<TurnHotkeysOn>
<SetButtonColors ON 0x00FF00 0x0F0F0F>
<SetButtonText ON HKN>
<Else>
<TurnHotkeysOff>
<SetButtonColors ON 0xfF0000 0xffFFff >
<SetButtonText ON off>
<EndIf>
<Hotkey Alt Ctrl A>
<Toggle>
<sendpc local>
<SetButtonColors ACT 0x00FF00 0x0F0F0F>
<SetButtonText ACT AWT>
<SetActiveWindowTrackingDelay 0>
<SetActiveWindowTracking On>
<Toggle>
<sendpc local>
<SetButtonColors ACT 0xfF0000 0xffFFff >
<SetButtonText ACT off>
<SetActiveWindowTracking Off>
<Hotkey Alt Ctrl D>
<DefaultWindowLayout>
Still pretty ugly but, much shorter, also it might prove harder to maintain if there are any bugs.
Often while playing I accidentally close a window when I meant to maximise or restore its size, so I've added hot keys for Ctrl Alt 1 - 5 to launch and rename individual windows.
If you're interested in how it works theres a version with comments on pastebin http://pastebin.com/pbgL9exG
Connect With Us