# How can I capture the "currently active" frontmost window?

**URL:** <https://community.folivora.ai/t/how-can-i-capture-the-currently-active-frontmost-window/41899>\
**Category:** Configuration Help & General Discussion\
**Created:** [January 25, 2025, 5:51pm UTC](https://community.folivora.ai/t/how-can-i-capture-the-currently-active-frontmost-window/41899 "2025-01-25T17:51:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnofcamas](https://community.folivora.ai/user_avatar/community.folivora.ai/johnofcamas/32/10180_2.png) [@johnofcamas](https://community.folivora.ai/u/johnofcamas)\
**Post date:** [January 25, 2025, 5:51pm UTC](https://community.folivora.ai/t/how-can-i-capture-the-currently-active-frontmost-window/41899/1 "2025-01-25T17:51:04Z")

</div>

I noticed that I can capture a window by ID but I'd like to dynamically capture my currently active frontmost window.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [January 25, 2025, 6:10pm UTC](https://community.folivora.ai/t/how-can-i-capture-the-currently-active-frontmost-window/41899/2 "2025-01-25T18:10:37Z")

</div>

It would require some scripting:

This script would save it to your downloads folder:

```auto

async function screenshotFocusedWindow() {
     let foucsedWindowID = await get_number_variable("BTTActiveWindowNumber");
		
    let screenshotActionDefinition = {
        "BTTPredefinedActionType" : 169,
        "BTTPredefinedActionName" : "Capture Screenshot (Configurable)",
        "BTTScreenshotOptions" : `-l;;${foucsedWindowID};;-t;;png;;~\/Downloads\/Screenshot_{datetime}_{random}.png;;`,
        "BTTScreenshotDateFormat" : "yyyy-MM-dd HH.mm.ss",
  };
	let result = await trigger_action({json: JSON.stringify(screenshotActionDefinition), wait_for_reply: false});

	return false;
}

```

 ![image](https://community.folivora.ai/uploads/default/original/3X/1/8/1898e129780d84f44740c8be33da6792ab914914.jpeg)

---

<div class="post-metadata">

**Author:** ![johnofcamas](https://community.folivora.ai/user_avatar/community.folivora.ai/johnofcamas/32/10180_2.png) [@johnofcamas](https://community.folivora.ai/u/johnofcamas)\
**Post date:** [January 25, 2025, 6:23pm UTC](https://community.folivora.ai/t/how-can-i-capture-the-currently-active-frontmost-window/41899/3 "2025-01-25T18:23:16Z")

</div>

I'm thinking this is a good chance to combine Keyboard Maestro and BTT. I can call a KM macro that screenshots the currently active front window and copies it and call that from BTT when I hit that spot in my macro

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [January 25, 2025, 6:34pm UTC](https://community.folivora.ai/t/how-can-i-capture-the-currently-active-frontmost-window/41899/4 "2025-01-25T18:34:06Z")

</div>

running the java script should be more performant, but yes that would also work
