/*
This is a minimal version of the function I am developing just to hightlight the behaviour of WIN Keys
Whatever WIN key is pressed, IsKeyDown always returns true values for both WIN keys.
To test this function, no hotkey assignment is needed
Load script into DF script editor
Hold down either WIN key and click <Run Code> button in DF script editor
*/
using System;
using System.Drawing;
// The 'windowHandle' parameter will contain the window handle for the:
// - Active window when run by hotkey
// - Trigger target when run by a Trigger rule
// - TitleBar Button owner when run by a TitleBar Button
// - Jump List owner when run from a Taskbar Jump List
// - Currently focused window if none of these match
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
/*
For calling directly from a hotkey combo
The assigned function hotkey needs to have a relevant WIN or MODIFIER key assigned in DF to actually work
i.e Function Hotkey = WIN + CTRL + W
But as DF doesn't distinguish between LEFT or RIGHT in hotkey assignments we do it in code
VK_SHIFT 16 (0x10)
VK_CONTROL 17 (0x11)
VK_MENU 18 (0x12)
VK_LWIN 91 (0x5B)
VK_LSHIFT 16 (0xA0)
VK_LCONTROL 17 (0xA2)
VK_LMENU 18 (0xA4)
VK_RWIN 92 (0x5C)
VK_RSHIFT 161 (0xA1)
VK_RCONTROL 163 (0xA3)
VK_RMENU 165 (0xA5)
VK_APPS 93 (0x5D)
*/
string sdbugtext = "";
string sNewLine = Environment.NewLine + Environment.NewLine;
// First check what WIN keys are pressed to run custom task assigned to WIN Key combo
//if (BFS.Input.IsKeyDown("91") && BFS.Input.IsKeyDown("92"))
if (BFS.Input.IsKeyDown("91;92"))
{
// BOTH WinKey Combo task
// First check for both WIN Keys as when both are pressed either WIN key will return true
sdbugtext = "!!! BOTH WIN KEYS PRESSED !!!" + sNewLine;
}
else if (BFS.Input.IsKeyDown("91"))
{
// LEFT WinKey Combo task
sdbugtext = "!!! LEFT WIN KEY PRESSED !!!" + sNewLine;
}
else if (BFS.Input.IsKeyDown("92"))
{
// RIGHT WinKey Combo task
sdbugtext = "!!! RIGHT WIN KEY PRESSED !!!" + sNewLine;
}
else
{
// Won't arrive here if function is called directly from a hotkey combo with a WIN key
// No WIN keys are pressed so do nothing and return
sdbugtext = "!!! NO WIN KEY PRESSED !!!" + sNewLine;
//BFS.Dialog.ShowMessageInfo(sdbugtext);
//return;
}
// Show Debug text
sdbugtext = sdbugtext + "WIN LEFT[" + BFS.Input.IsKeyDown("91") + "] : WIN RIGHT[" + BFS.Input.IsKeyDown("92") + "]" + sNewLine;
/*
// Debug text to show other modififer key checks
// RIGHT ALT also shows LEFT CTRL[True] which is a Windows VKey feature anyway
sdbugtext = sdbugtext + "LEFT SHIFT[" + BFS.Input.IsKeyDown("160") + "] : RIGHT SHIFT[" + BFS.Input.IsKeyDown("161") + "]" + sNewLine;
sdbugtext = sdbugtext + "LEFT CTRL[" + BFS.Input.IsKeyDown("162") + "] : RIGHT CTRL[" + BFS.Input.IsKeyDown("163") + "]" + sNewLine;
sdbugtext = sdbugtext + "LEFT ALT[" + BFS.Input.IsKeyDown("164") + "] : RIGHT ALT[" + BFS.Input.IsKeyDown("165") + "]" + sNewLine;
sdbugtext = sdbugtext + " APPS Key[" + BFS.Input.IsKeyDown("93") + "]" + sNewLine;
*/
BFS.Dialog.ShowMessageInfo(sdbugtext);
}
}