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?

User Image
AlanBes
29 discussion posts
Simple script in ClipboardFusion to replace text.
But I need the macro to only run if Chrome is the focused application.
Had a look at GetMainFileByWindow and other functions but can't get them implemented into the code.
Here's a sample of the current code, and help to add a statement if a window (chrome) is the focused app will be appreciated.

Code

using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //use the Regex class to replace any matched text with an empty string
    if (text.Contains("**"))
    {
    text = text.Replace ("**","");
    text = Regex.Replace (text, @"(.*),.*- (.*),.*(\(.*)", "$1 vs $2 $3");
    }    
    else
    {
        text = Regex.Replace (text, @"\n", "");
        text = Regex.Replace (text, @".*\[Date ""([1-2][0-9][0-9][0-9]).*\[White ""(.*)"".*\[Black ""(.*)"".*\[Result.*", "**$2 - $3** ($1)");
    }
        
        BFS.Clipboard.PasteText(text);
        //get ClipboardFusion to replace the text on the clipboard with the text variable
        return text;
    }
}
May 6, 2019  • #1
User Image
AlanBes
29 discussion posts
After an all-nighter I managed to solve this

Code

using System;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{

        
    public static string ProcessText(string text)
    {
        // Checking that Chrome os active
                
        IntPtr windowHandle = BFS.Window.GetFocusedWindow();
        string file = BFS.Application.GetMainFileByWindow(windowHandle);
        //BFS.Dialog.ShowMessageInfo(file);      
        if (file.Contains("chrome.exe") == true)
        {
        
        //If Chrome is active ... do your stuff here
            
        }
        
        return text;
    }
}
May 7, 2019  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)