<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>VoiceBot RSS: SCRIPT-EDIT:  PabloMartinez's &quot;Capture Screenshot&quot; -Macro</title>
<atom:link href="https://www.voicebot.net/Discussions/RSS/?TopicID=ecfa730b-05f7-474f-876c-b751abd0a25e" rel="self" type="application/rss+xml" />
<link>https://www.voicebot.net/Discussions/RSS/?TopicID=ecfa730b-05f7-474f-876c-b751abd0a25e</link>
<description>VoiceBot RSS: SCRIPT-EDIT:  PabloMartinez's &quot;Capture Screenshot&quot; -Macro</description>
<lastBuildDate>Sun, 05 Apr 2026 16:58:22 GMT</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://www.voicebot.net/Discussions/RSS/?TopicID=ecfa730b-05f7-474f-876c-b751abd0a25e</generator>
<item>
<title>RE: SCRIPT-EDIT:  PabloMartinez's &quot;Capture Screenshot&quot; -Macro</title>
<link>https://www.voicebot.net/Discussions/View/script-edit-pablomartinezs-capture-screenshot-macro/?ID=ecfa730b-05f7-474f-876c-b751abd0a25e#2</link>
<pubDate>Tue, 15 Jun 2021 13:21:14 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.voicebot.net/Discussions/View/script-edit-pablomartinezs-capture-screenshot-macro/?ID=ecfa730b-05f7-474f-876c-b751abd0a25e#2</guid>
<category>VoiceBot</category>
<description><![CDATA[Hello,
Would you like us to add this to our script repository?
Thanks!]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Hello,<br/>
<br/>
Would you like us to add this to our script repository?<br/>
<br/>
Thanks!
</div>
]]></content:encoded>
</item>
<item>
<title>SCRIPT-EDIT:  PabloMartinez's &quot;Capture Screenshot&quot; -Macro</title>
<link>https://www.voicebot.net/Discussions/View/script-edit-pablomartinezs-capture-screenshot-macro/?ID=ecfa730b-05f7-474f-876c-b751abd0a25e</link>
<pubDate>Mon, 14 Jun 2021 00:41:23 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.voicebot.net/Discussions/View/script-edit-pablomartinezs-capture-screenshot-macro/?ID=ecfa730b-05f7-474f-876c-b751abd0a25e</guid>
<category>VoiceBot</category>
<description><![CDATA[Deleted some lines of code to make it fullscreen only. no dialog-box.
Code
Copy
Select All
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
public static class VoiceBotScript
{
public static void Run(IntPtr windowH...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
Deleted some lines of code to make it fullscreen only. no dialog-box.<br/>
<br/>
<div id="" class="col-md-12 BoxWrap"><div class="Box table-responsive"><a name="code" style="width:0; height:0;"></a><h2 class="TableTitle" style="border:0"><div class="TableTitleText">Code</div><div class="TitleButtons"><div class="TableTitleButton"><a href="#" onclick="return false;" data-clipboard-target="#code019d5e94ca7c7136a0e6eea0e94ca125" class="ClipboardCopyControl"><img src="https://www.voicebot.net/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019d5e94ca7c7136a0e6eea0e94ca125Js'); return false;"><img src="https://www.voicebot.net/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:auto;max-width:16px;height:16px;" /><span class="Text">Select All</span></a></div></div></h2><div class="TableTitleContent table-responsive"><div class="AceEditorWrapper" style="border-top:solid 1px var(--color-default-border);padding:0"><pre id="code019d5e94ca7c7136a0e6eea0e94ca125Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;

public static class VoiceBotScript
{
    public static void Run(IntPtr windowHandle)
    {
        // Here you set the path for saving screenshots
        string path = (@"C:\ScreenShots\");

        // Here you may change image format (Png, Jpeg, Bmp, Tiff, Gif, Icon, Wmf, Emf, Exif)
        ImageFormat ext = ImageFormat.Png;

        // If directory not exists call a method CreateDir
        if (!Directory.Exists(path))
        {
            Dir.CreateDir(path);
        }
        // Call a method Capture
        Capture.GetCapture(path,ext);
    }
}

static class Dir
{
    public static void CreateDir(string path)
    {
        // Create directory if sufficient permissons.
        try
        {
            Directory.CreateDirectory(path);
            // Get only name of directory
            string foldername = Path.GetFileName(Path.GetDirectoryName(path));
            BFS.Speech.TextToSpeech("Create directory" + foldername);
        }
        // Permission exception
        catch (UnauthorizedAccessException)
        {
            BFS.Speech.TextToSpeech("Insufficient permissions. Can't create the directory");
        }
    }
}

static class Capture
{
    private static string name, time, extension, filename;

    public static void GetCapture(string path, ImageFormat ext)
    {
        // Get and save fullscreen image
        Image imgFullScr = ScreenCapture.CaptureDesktop();
        GetFileName(path, ext);
        imgFullScr.Save(@filename, ext);
    }
    private static void GetFileName(string path, ImageFormat ext)
    {
        // Get handle focused window
        IntPtr hWnd = BFS.Window.GetFocusedWindow();
        // Get window name from hanle
        name = BFS.Window.GetText(hWnd);
        // Convert current time and date to string
        time = DateTime.Now.ToString("(yyyy-MM-dd@HH.mm.ss)");
        // Convert imageformat to string and to lowercase
        extension = ext.ToString().ToLower();
        // Set formatting for saving file
        filename = (path + name + " " + time + "." + extension);
    }
}

static class ScreenCapture
{
    [DllImport("user32.dll")]
    private static extern IntPtr GetForegroundWindow();
    
    [DllImport(@"dwmapi.dll")]
    private static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out Rect pvAttribute, int cbAttribute);

    [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern IntPtr GetDesktopWindow();

    [DllImport("user32.dll")]
    private static extern IntPtr GetWindowRect(IntPtr hWnd, ref Rect rect);

    [StructLayout(LayoutKind.Sequential)]

    private struct Rect
    {
        public int Left;
        public int Top;
        public int Right;
        public int Bottom;
    }
    public static Image CaptureDesktop()
    {
        return CaptureWindow(GetDesktopWindow());
    }
    public static Bitmap CaptureActiveWindow()
    {
        return CaptureWindow(GetForegroundWindow());
    }
    // Capture desktop or active window
    // and return it as a bitmap
    public static Bitmap CaptureWindow(IntPtr hWnd)
    {
        var rect = new Rect();
        // If Win XP and earlier use the old way
        if (Environment.OSVersion.Version.Major &lt; 6)
            GetWindowRect(hWnd, ref rect);
        // using DwmApi for border rectangle
        else
        {
            var res = -1;
            try
            {
                res = DwmGetWindowAttribute(hWnd, 9, out rect, Marshal.SizeOf(typeof(Rect)));
            }
            catch {}
            if (res &lt; 0)
                GetWindowRect(hWnd, ref rect);
        }
        
        var bounds = new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
        var result = new Bitmap(bounds.Width, bounds.Height);

        using (Graphics graphics = Graphics.FromImage(result))
        {
            graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
        }
        return result;
    }
}</pre><textarea id="code019d5e94ca7c7136a0e6eea0e94ca125" name="code019d5e94ca7c7136a0e6eea0e94ca125" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div>
</div>
]]></content:encoded>
</item>
</channel>
</rss>