Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?
Save up to 50% on our desktop apps during our big Year End Sale!Save up to 50% on our desktop apps during our big Year End Sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save up to 50% on our desktop apps during our big Year End Sale!

User Image
Derek Ziemba
7 discussion posts
Since DisplayFusion only allows a 1:1 mapping per hotkey & script, I have 20 copies of the same script with the only differences being 2 variables at the top:
private const int NUMPAD_KEY = 0...9;
and
private const bool CTRL = true|false
.

Ideally, I'd be able to assign all variants of
WinKey + Numpad_#
and
Ctrl + WinKey + Numpad_#
keybinds to one function. The inability to do so results in workarounds & my current issue.
I need to share context between these 20 function variants: wich windows they've moved, from where, & where to. Currently it works something like this:

Code

public static partial class DisplayFusionFunction {

  record HistoricPosition(
    bool Maximized, 
    int Monitor, 
    Point Cell, 
    Point RowsCols, 
    Rectangle Pos, 
    int? NumKey = null, 
    bool? Ctrl = null
  );

  class ExpirableEntryList(uint Age): List<HistoricPosition> { 
    public uint Age { get; set; } = Age;
  };

  class Context: Dictionary<uint, ExpirableEntryList> {
    const uint MAX_AGE = 12; // 12hrs
    static readonly DateTime Epoch = new DateTime(2025, 1, 1);
    
    static uint Now => (uint)DateTime.Now.Subtract(Epoch).TotalHours;
    
    static uint ToKey(IntPtr whnd) => unchecked((uint)whnd.ToInt32());
    
    public ExpirableEntryList Get(IntPtr whnd) => this.TryGetValue(ToKey(whnd), out var list) ? list : null;
    
    public void Load() {
      this.Clear();
      uint now = (uint)DateTime.Now.Subtract(Epoch).TotalHours;
      var dict = JsonSerializer.Deserialize<Dictionary<uint, ExpirableEntryList>>(
        BFS.ScriptSettings.ReadValue("NumpadPositions.WindowHistory") ?? "{}"
      );
      foreach(var (Key, Value) in dict) {
        if(Value.Age < now - MAX_AGE) continue; # Skip expired entries
        this.Add(Key, Value);
      }
    }

    public void AddRecord(IntPtr whnd, HistoricPosition entry) {
      var list = this.Get(whnd);
      if(list != null) {
        list.Age = Now;
        list.Add(entry);
      } else { 
        this.Add(ToKey(whnd), new ExpirableEntryList(now) { entry });
      }
      BFS.ScriptSettings.WriteValue("NumpadPositions.WindowHistory", JsonSerializer.Serialize(this));
    }
  }
}

The issues with this are:
  • Kind of annoying to have to do.
  • It persists when DisplayFusion is restarted.
  • It persist on reboots.
  • Collisions could happen on the HWND key. There's still more than enough entropy when coercing the 64bit HWND to 32bit. However, Windows handles start over across reboots... And my settings persist...
  • There's 20 script variants so I can't check the state of a static variable to detect if DisplayFusion was restarted then clear the ScriptSettings, each script has its own distinct static variables.

At least one of the following would be greatly appreciated in the BFS API.
  • Ability to assign multiple keybinds to a single script. The Script could then check
    BFS.Input.IsKeyDown
    to figure out what it needs to do from there.
  • A session storage/settings API.
  • Perhaps an options param that can specify ExpirationPolicy to
    BFS.ScriptSettings.WriteValue
  • Ability to Query basic info like System Uptime, Session Uptime, DisplayFusion Start Time.
Aug 6, 2025 (modified Aug 6, 2025)  • #1
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
This is currently on our feature request list, so I've added your vote to it. We'll be sure to let you know if/when we're able to implement it in the future.

Thanks!
Aug 6, 2025  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)