This endpoint makes a specified window the active foreground window, bringing it to the front of all other windows. This is particularly useful when you need to interact with a specific window that might be hidden behind others or when automating multi-window workflows.
The endpoint requires a Window ID, which can be obtained from the System Overview or Get Window Details endpoints. It corresponds to the "Bring to Front" action in the Windows Automation tool category.
                Authorization: Bearer {api-key} - Required for authentication.
            
                Content-Type: application/json - The request body should be formatted as JSON.
            
The request body should be a JSON object with the following properties:
{
    "windowId": "123456"
}The response is a JSON object with information about the result of the operation.
The response contains the following properties:
{
    "success": true,
    "message": "Window successfully brought to front",
    "timestamp": "2025-03-12T09:45:32.123Z"
}import requests
import json
# Configuration
api_key = "your_api_key_here"
base_url = "http://localhost:5000"  # Adjust if your server is on a different host/port
# Set up the request
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}
# Prepare the payload
data = {
    "windowId": "123456"  # Replace with an actual window ID
}
# Send the request
response = requests.post(
    f"{base_url}/tools-api/automation/bring-to-front",
    headers=headers,
    data=json.dumps(data)
)
# Process the response
if response.status_code == 200:
    result = response.json()
    if result.get("success"):
        print(f"Success: {result['message']}")
    else:
        print(f"Operation failed: {result['message']}")
else:
    print(f"Request failed with status code: {response.status_code}")
    print(response.text)interface BringToFrontRequest {
    windowId: string;
}
interface BringToFrontResponse {
    success: boolean;
    message: string;
    timestamp: string;
}
async function bringWindowToFront(apiKey: string, windowId: string): Promise {
    const baseUrl = "http://localhost:5000"; // Adjust if your server is on a different host/port
    
    const headers = {
        "Authorization": `Bearer ${apiKey}`,
        "Content-Type": "application/json"
    };
    
    const data: BringToFrontRequest = {
        windowId: windowId
    };
    
    try {
        const response = await fetch(`${baseUrl}/tools-api/automation/bring-to-front`, {
            method: "POST",
            headers: headers,
            body: JSON.stringify(data)
        });
        
        if (!response.ok) {
            throw new Error(`Request failed with status: ${response.status}`);
        }
        
        const result: BringToFrontResponse = await response.json();
        return result;
    } catch (error) {
        console.error("Error bringing window to front:", error);
        throw error;
    }
}
// Example usage
async function main() {
    const apiKey = "your_api_key_here";
    const windowId = "123456"; // Replace with an actual window ID
    
    try {
        const result = await bringWindowToFront(apiKey, windowId);
        if (result.success) {
            console.log(`Success: ${result.message}`);
        } else {
            console.log(`Operation failed: ${result.message}`);
        }
    } catch (error) {
        console.error("Error:", error);
    }
} using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class ToolsServerClient
{
    private readonly HttpClient _httpClient;
    private readonly string _apiKey;
    
    public ToolsServerClient(string apiKey, string baseUrl = "http://localhost:5000")
    {
        _httpClient = new HttpClient
        {
            BaseAddress = new Uri(baseUrl)
        };
        _apiKey = apiKey;
        _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _apiKey);
    }
    
    public class BringToFrontRequest
    {
        public string WindowId { get; set; }
    }
    
    public class BringToFrontResponse
    {
        public bool Success { get; set; }
        public string Message { get; set; }
        public DateTime Timestamp { get; set; }
    }
    
    public async Task BringWindowToFrontAsync(string windowId)
    {
        var request = new BringToFrontRequest
        {
            WindowId = windowId
        };
        
        var jsonContent = JsonSerializer.Serialize(request, new JsonSerializerOptions
        {
            PropertyNamingPolicy = JsonNamingPolicy.CamelCase
        });
        
        var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
        var response = await _httpClient.PostAsync("/tools-api/automation/bring-to-front", content);
        
        response.EnsureSuccessStatusCode();
        
        var jsonResponse = await response.Content.ReadAsStringAsync();
        return JsonSerializer.Deserialize(jsonResponse, new JsonSerializerOptions
        {
            PropertyNameCaseInsensitive = true
        });
    }
}
// Example usage
public class Program
{
    public static async Task Main(string[] args)
    {
        try
        {
            var client = new ToolsServerClient("your_api_key_here");
            var result = await client.BringWindowToFrontAsync("123456"); // Replace with an actual window ID
            
            if (result.Success)
            {
                Console.WriteLine($"Success: {result.Message}");
            }
            else
            {
                Console.WriteLine($"Operation failed: {result.Message}");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
}  In this example, we first get the window ID of a Notepad window using the System Overview endpoint, then bring it to the front.
// First, request system overview to get window IDs
POST /tools-api/system/overview
// Response (truncated):
{
  "success": true,
  "windows": [
    {
      "title": "Untitled - Notepad",
      "processName": "notepad",
      "windowId": "65432",
      // other window information...
    },
    // other windows...
  ]
}// Request:
POST /tools-api/automation/bring-to-front
{
  "windowId": "65432"
}
// Response:
{
  "success": true,
  "message": "Window successfully brought to front",
  "timestamp": "2025-03-12T09:45:32.123Z"
}This example demonstrates what happens when an invalid window ID is provided.
// Request with invalid window ID:
POST /tools-api/automation/bring-to-front
{
  "windowId": "999999"
}
// Response:
{
  "success": false,
  "message": "Failed to bring window to front: Window with ID 999999 not found",
  "timestamp": "2025-03-12T09:46:15.456Z"
}