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
Leon André Bergman
60 discussion posts

Code

using System;
using System.Collections.Generic;

// The 'text' parameter will contain the text from the:
//   - Current Clipboard when run by HotKey
//   - History Item when run from the History Menu
// The returned string will be:
//   - Placed directly on the Clipboard
//   - Ignored by ClipboardFusion if it is 'null'
public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
// your code goes here
//Opens new page in OneNote
BFS.Input.SendKeys("^({VK_78})");
//Adds title to the Page
BFS.Clipboard.PasteText("Company");
//Sends us to the note field
BFS.Input.SendKeys("{ENTER}");
//Adds 5 separate lines of text separated by a line break
BFS.Clipboard.PasteText("Customer Number: ");
BFS.Input.SendKeys("{ENTER}");
BFS.Clipboard.PasteText("Customer Name: ");
BFS.Input.SendKeys("{ENTER}");
BFS.Clipboard.PasteText("CI: ");
BFS.Input.SendKeys("{ENTER}");
BFS.Clipboard.PasteText("Ticket: ");
BFS.Input.SendKeys("{ENTER}");
BFS.Clipboard.PasteText("Note: ");
return text;
}
}

The above code shows how I put together the macro.
This opens a new page in onenote, and adds a title, and a list of items I want to have ready for noting down the calling customers information.

This is a slightly slower process than I would like, as it pastes one line, sends the enter, and pastes the next.

Is there a way for me to have it paste all the 5 lines simultaneously?

And in addition, I would like to add a timestamp of what hour and minute the customer called, in the title of the new page. Is there a code to add this? I found that you can search and only paste time or date from the text you copy, but I haven't found if you can add the current time.
Nov 1, 2017  • #1
Thomas Malloch (BFS)'s profile on WallpaperFusion.com
You can easily get ClipboardFusion to paste more than one line at a time by using the "\n" (newline) character in your code. Here's an example:

Code

BFS.Clipboard.PasteText("Customer Number: \nCustomer Name: ");


When this pastes, it should look like:

Customer Number:
Customer Name:

I hope this works for you!
Nov 1, 2017  • #2
User Image
UWK-87
166 discussion posts
@Leon André Bergman: I think you made it too complex with enter key strokes. Why not keep it simple :)
P.S: Didn't change the code which was handling your application.
P.P.S: The code also print an extra line with time of customer call

For ease of understanding, I am attaching the cfmacro file with this post. Just import it :)

Code

using System;
using System.Collections.Generic;

// The 'text' parameter will contain the text from the:
//   - Current Clipboard when run by HotKey
//   - History Item when run from the History Menu
// The returned string will be:
//   - Placed directly on the Clipboard
//   - Ignored by ClipboardFusion if it is 'null'

public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
//Opens new page in OneNote
BFS.Input.SendKeys("^({VK_78})");

//Adds title to the Page
BFS.Clipboard.PasteText("Company");

//Sends us to the note field
BFS.Input.SendKeys("{ENTER}");

//Nothing changed till here, since you are working with your app

//Adds 5 separate lines of text separated by a line break
string MyCustomerInfo = null;
string CurrentTimeofCustomer = DateTime.Now.ToString("h:mm:ss tt");

MyCustomerInfo =  "Customer Number: " + Environment.NewLine + "Customer Name: " + Environment.NewLine + "CI: " 
+ Environment.NewLine + "Ticket: " + Environment.NewLine + "Customer Contact Time: " + CurrentTimeofCustomer
+ Environment.NewLine +"Note: " ;

return MyCustomerInfo;
}
}
• Attachment: New One Note - Note.cfmacro [1,240 bytes]
Nov 1, 2017 (modified Nov 1, 2017)  • #3
User Image
Leon André Bergman
60 discussion posts
Thank you guys. I might have made it complicated, but only because this is the first time I have had anything to do with C# or coding.

EDIT: UWK-87: Your changes ended up not working for me.
It created a new pace, and added the title, like I wanted.
But nothing happened with your code. I didn't get anything after it jumped down from the title.

Thomas Malloch: Thank you. The \n worked like a charm.
The only thing I need now, is to get the current time in the title, directly behind where it says Company.
Like I said. I'm new to this coding stuff, so I will probably ask for more advice, but this is really shaping up to be a good replacement.
Nov 1, 2017 (modified Nov 1, 2017)  • #4
User Image
UWK-87
166 discussion posts
Hi Leon

There was a small mistake :( Try now :)

Code

using System;
using System.Collections.Generic;

// The 'text' parameter will contain the text from the:
//   - Current Clipboard when run by HotKey
//   - History Item when run from the History Menu
// The returned string will be:
//   - Placed directly on the Clipboard
//   - Ignored by ClipboardFusion if it is 'null'

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //Opens new page in OneNote
        BFS.Input.SendKeys("^({VK_78})");

        //Adds title to the Page
        BFS.Clipboard.PasteText("Company");

        //Sends us to the note field
        BFS.Input.SendKeys("{ENTER}");

        //Nothing changed till here, since you are working with your app

        //Adds 5 separate lines of text separated by a line break
        string MyCustomerInfo = null;
        string CurrentTimeofCustomer = DateTime.Now.ToString("h:mm:ss tt");

        MyCustomerInfo =  "Customer Number: " + Environment.NewLine + "Customer Name: " + Environment.NewLine + "CI: " 
        + Environment.NewLine + "Ticket: " + Environment.NewLine + "Customer Contact Time: " + CurrentTimeofCustomer
        + Environment.NewLine +"Note: " ;

        BFS.Clipboard.PasteText(MyCustomerInfo);
        return null;
    }
}
• Attachment: New Note.cfmacro [8,272 bytes]
Nov 1, 2017  • #5
User Image
UWK-87
166 discussion posts
Lastly, where do you want the time to be pasted?
Nov 1, 2017  • #6
User Image
Leon André Bergman
60 discussion posts
I want it to be pasted at the end of my title, so directly after Company.
I changed your code slightly, and it now ends up in the title:

Code

using System;
using System.Collections.Generic;

// The 'text' parameter will contain the text from the:
// - Current Clipboard when run by HotKey
// - History Item when run from the History Menu
// The returned string will be:
// - Placed directly on the Clipboard
// - Ignored by ClipboardFusion if it is 'null'

public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
//Opens new page in OneNote
BFS.Input.SendKeys("^({VK_78})");

//Adds title to the Page
string MyTitle = null;
string CurrentTimeofTitle = DateTime.Now.ToString("hh:mm:ss");
MyTitle = "Company " + CurrentTimeofTitle;
BFS.Clipboard.PasteText(MyTitle);

//Sends us to the note field
BFS.Input.SendKeys("{ENTER}");

//Nothing changed till here, since you are working with your app

//Adds 5 separate lines of text separated by a line break
string MyCustomerInfo = null;
string CurrentTimeofCustomer = DateTime.Now.ToString("h:mm:ss tt");

MyCustomerInfo = "Customer Number: " + Environment.NewLine + "Customer Name: " + Environment.NewLine + "CI: " 
+ Environment.NewLine + "Ticket: " + Environment.NewLine + "Customer Contact Time: " + Environment.NewLine +"Note: " ;

BFS.Clipboard.PasteText(MyCustomerInfo);
return null;
}
}


The only problems I face now, is that it does not show it with a 24 hour time format, and I get . instead of : as separators.
Nov 1, 2017 (modified Nov 1, 2017)  • #7
User Image
UWK-87
166 discussion posts
Did the new code work for you?
Nov 1, 2017  • #8
User Image
UWK-87
166 discussion posts
Here is the modified code for time in the title. Also cfmacro file attached for ease of import.

Code

using System;
using System.Collections.Generic;

// The 'text' parameter will contain the text from the:
//   - Current Clipboard when run by HotKey
//   - History Item when run from the History Menu
// The returned string will be:
//   - Placed directly on the Clipboard
//   - Ignored by ClipboardFusion if it is 'null'

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //Opens new page in OneNote
        BFS.Input.SendKeys("^({VK_78})");

        //Adds title to the Page
        string TimeTitle = null;
        string CurrentTime = DateTime.Now.ToString("h:mm:ss tt");
        TimeTitle = "Company " + CurrentTime;
        BFS.Clipboard.PasteText(TimeTitle);

        //Sends us to the note field
        BFS.Input.SendKeys("{ENTER}");

        //Nothing changed till here, since you are working with your app

        //Adds 5 separate lines of text separated by a line break
        string MyCustomerInfo = null;

        MyCustomerInfo =  "Customer Number: " + Environment.NewLine + "Customer Name: " + Environment.NewLine + "CI: " 
        + Environment.NewLine + "Ticket: " + Environment.NewLine + "Note: " ;

        BFS.Clipboard.PasteText(MyCustomerInfo);
        return null;
    }
}
• Attachment: New Note - With Time in Title.cfmacro [8,328 bytes]
Nov 1, 2017  • #9
User Image
Leon André Bergman
60 discussion posts
Same thing I did. hehe. Yea, it works, but I don't use am/pm, I use a 24 hour clock, so I googled it and found that I need to put upper case HH to get 24 hour time. Nice.
Bothers me that the output is with a period as a separator, and not a colon though.
Any idea why that happens?
Nov 1, 2017  • #10
User Image
UWK-87
166 discussion posts
yeh saw your post later.

I get this output when I execute it
https://cdn.pbrd.co/images/GRGsLGk.png


Do you get something else?
Nov 1, 2017  • #11
User Image
Leon André Bergman
60 discussion posts
After changing to 24 hour clock, and removing the seconds, I get this. Attached

EDIT: Never mind. That was a windows setting. Fixed it.
• Attachment: Capture.PNG [7,634 bytes]
Capture.PNG
Capture.PNG
Nov 1, 2017 (modified Nov 1, 2017)  • #12
User Image
UWK-87
166 discussion posts
For me it works fine with the changes.

https://cdn.pbrd.co/images/GRGv1JG.png


I don't think that is the issue of the code anymore. I highlighted the system time in my image. If you look at the system time in your One Note sheet, it is with ".". I am guessing here but you need to change the time and date display settings from Control Panel-> Region -> Change date, time, or number formats. Again this is a guess, hope it helps.
Nov 1, 2017 (modified Nov 1, 2017)  • #13
User Image
Leon André Bergman
60 discussion posts
Yes. In my edit, I said I found it as the system time was incorrectly formated. It's been changed now. Never noticed that until now. At work it should be fine.
Thank you for all your help. This will surely excel my skills in C# in the time going forward.
Nov 1, 2017  • #14
User Image
UWK-87
166 discussion posts
Hehe didn't see the edit.
You welcome :)
Nov 1, 2017  • #15
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)