Author Topic: How to copy a file with voiceattack?  (Read 869 times)

Ruken

  • Newbie
  • *
  • Posts: 4
How to copy a file with voiceattack?
« on: August 23, 2022, 05:32:49 PM »
Is it possible to copy a file with voiceattack?

I want to paste images into a drawing program with voiceattack.

Basically a command to paste a car outline onto the drawing canvas would go like this:

When I say "Car outline"
Press Ctrl-C on car_outline.png at C:\Users\user\Documents\voiceattack_pictures\car_outline.png
Press Ctrl-V

Whats the best way to do this?

I can't find any built in options to copy a file with voiceattack. I figured an inline function would work but I'm having trouble figuring out how to copy a file with c# or vb.net. There is lots of information on copying a file to another directory but not much about copying a file to the clipboard.

I did find a script in autohotkey that does this here https://www.autohotkey.com/board/topic/23162-how-to-copy-a-file-to-the-clipboard/ on post #5. But I don't know how this translates into c#

I'm very new to programming and would appreciate any help someone can give me.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: How to copy a file with voiceattack?
« Reply #1 on: August 24, 2022, 02:46:15 AM »
You can use the FileDrop DataFormat to store a reference to your image file in the clipboard (which is what would happen when you use Ctrl-C in Explorer as well), E.G.:
Code: [Select]
Clipboard.SetData(DataFormats.FileDrop, @"C:\my image.png");

Ruken

  • Newbie
  • *
  • Posts: 4
Re: How to copy a file with voiceattack?
« Reply #2 on: August 24, 2022, 12:48:39 PM »
This does not seem to be working, is there anything else I need to put inside the inline function with the Clipboard function? I'll attach a screenshot of what I have so far. And please have my thanks for helping me.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: How to copy a file with voiceattack?
« Reply #3 on: August 24, 2022, 12:54:58 PM »
Have you tried manually pressing Ctrl-V after executing that command?

You're triggering the command using the left Shift key, so unless you release that key inhumanly fast, what's actually being pressed is left Shift + left Ctrl + V, which does not trigger pasting in most applications.


You may want to enable the "Shortcut is invoked only when all keys are released" option.

Ruken

  • Newbie
  • *
  • Posts: 4
Re: How to copy a file with voiceattack?
« Reply #4 on: August 24, 2022, 02:13:05 PM »
Sorry, I should have said what I tried before. I have tried manually hitting ctrl-v, and have the "Shortcut is invoked only when all keys are released" option checked. I have also tried using other keys to trigger the command. And using the full path inside the inline function didn't work either. Running as administrator also didn't work.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: How to copy a file with voiceattack?
« Reply #5 on: August 24, 2022, 02:33:13 PM »
I did test it, but ran a different method (Clipboard.SetFileDropList(), which requires a specialized collection) first. Must have gotten the results from the other method instead.


Code: [Select]
Clipboard.SetData(DataFormats.FileDrop, new string[] { @"C:\test2.png" });works.


Ironically I was pleasantly surprised that the method took a plain string, even though a FileDrop is actually an array of strings. Turns out it actually doesn't after all.
« Last Edit: August 25, 2022, 12:03:40 PM by Pfeil »

Ruken

  • Newbie
  • *
  • Posts: 4
Re: How to copy a file with voiceattack?
« Reply #6 on: August 25, 2022, 12:02:02 PM »
Thank you so much! This works a treat  :)