Skip to content

pavelnil/HFS-Hide2TrayLauncher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Project Description

HFS-Hide2TrayLauncher is a lightweight launcher utility for HTTP File Server version 3 (HFS 3) that starts the HFS server and provides tray minimization for the HFS console.

Core principles:

  • Portable: Requires no installation.
  • Zero configuration: Works out-of-the-box with existing HFS installations.
  • Resource-efficient: Minimal memory footprint (~1 MB RAM).
  • Integration: Automatically terminates when HFS exits.

screenshot


Key Features

Console Management

  • Automatically hides the console when the server starts.
  • Quick visibility toggle via the tray icon:
    • Double left-click.
    • Context menu: "Hide/Show HFS Console".
  • Reliable hiding: Background checks prevent accidental console exposure.
  • Automatic termination:
    • Closes HFS when the launcher exits.
    • Closes the launcher when HFS exits.

Smart Process Handling

  • Automatic HFS detection:
    • Searches for hfs.exe in the current directory.
    • Supports manual path specification via command-line arguments.
  • Compatibility:
    • Classic consoles (ConsoleWindowClass).
    • Windows 11 ConPTY support (CASCADIA_HOSTING_WINDOW_CLASS): Handles HWND changes when dragging console tabs.

Technical Implementation

Window Detection Algorithm

HWND FindConsoleWindowUniversal(DWORD pid) 1. Search via AttachConsole() (classic/pseudo-consoles) 2. Scan for "ConsoleWindowClass" (legacy versions) 3. Detect Windows Terminal via "CASCADIA_HOSTING_WINDOW_CLASS" 4. Handle pseudo-console owner window → Returns NULL after 300 attempts (30-second timeout)

flowchart TD
    A[Start FindConsoleWindowUniversal] --> B[Call AttachConsole]
    B --> C{Success?}
    C -->|Yes| D[Get hConsole]
    D --> E{Determine window class}
    E -->|ConsoleWindowClass| F[Return hConsole]
    E -->|PseudoConsoleWindow| G[Find owner window]
    G --> H{Owner class}
    H -->|CASCADIA_HOSTING| I[Return hOwner]
    H -->|Other| J[Proceed to manual search]
    
    C -->|No| K[Manual search]
    K --> L[Find all PseudoConsoleWindows]
    L --> M{Window found?}
    M -->|Yes| N[Check window PID]
    N -->|Match| O[Get owner]
    O --> P{Owner class}
    P -->|CASCADIA_HOSTING| Q[Return hOwner]
    P -->|Other| R[Next window]
    N -->|No match| R
    
    M -->|No| S[Search ConsoleWindowClass]
    S --> T{Window found?}
    T -->|Yes| U[Check window PID]
    U -->|Match| V[Return hConsole]
    U -->|No match| W[Next window]
    T -->|No| X[Return NULL]
    
    J --> K
    R --> L
    W --> S
    
    X --> Y[Start timer]
    Y --> Z[300 attempts]
    Z --> AA[100 ms interval]
    AA --> AB{Window appeared?}
    AB -->|Yes| AC[Return HWND]
    AB -->|No| AD[Decrement counter]
    AD -->|Counter > 0| AA
    AD -->|Counter = 0| AE[Show warning]
    AE --> AF[Return NULL]
    
    F --> AG[End]
    I --> AG
    Q --> AG
    V --> AG
    AC --> AG
    AF --> AG
Loading
  • Technologies:
    • Win32 API
    • Window message handling (WM_USER +1 for tray events)
    • Multi-threaded process monitoring

Use Cases

  1. Server deployment:
    HFS-Hide2TrayLauncher.exe "C:\hfs\hfs.exe"
  2. Quick desktop setup:
    • Place the launcher in the HFS directory → Launch by double-clicking.
  3. Background operation:
    • HFS console remains hidden until interacting with the tray icon.

Tip: Use with HFS Monitor.


Requirements

  • Server:
    • HTTP File Server v3
  • Client:
    • Windows 7 or newer.
    • Dependencies: None (self-contained binary)

Support:

  • BTC: bc1qeuq7s8w0x7ma59mwd4gtj7e9rjl2g9xqvxdsl6
  • TON: UQAOQXGtTi_aM1u54aQjb8QiXZkQdaL9MDSky5LHN0F5-yF2

About

Utility for HTTP File Server version 3 (HFS 3) that starts the HFS server and provides tray minimization for the HFS console. Windows 11 ConPTY support (CASCADIA_HOSTING_WINDOW_CLASS).

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors