Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Support multiple files at once from context menu? #131

Open
e-t-l opened this issue Aug 8, 2023 · 0 comments
Open

Enhancement: Support multiple files at once from context menu? #131

e-t-l opened this issue Aug 8, 2023 · 0 comments

Comments

@e-t-l
Copy link

e-t-l commented Aug 8, 2023

Expected Behavior

Multiple files can be sent to VTU to upload to VT in a single action, including from the context menu.

Actual Behavior

When multiple files are drag-and-dropped into the application's window, it uploads each of them to VT and opens the results in a new browser tab, as expected. However, when multiple files are selected in File Explorer and sent to this app from the context menu, it does not do this; instead, it just opens the app's drag-and-drop window, and the user has to drag the selected files into it manually. (If it's unclear what I'm describing, I can screen-record it and share the video here).

Solution

I am far too inexperienced with C# to try to submit a PR (let alone successfully edit and compile VTU myself), but I think I know how this can be fixed.

I'm pretty sure the upload arguments are handled here for the drag-and-drop and context menu...

private void MainForm_DragDrop(object sender, DragEventArgs e)
{
var settings = Settings.LoadSettings();
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (var file in files)
{
var uploadForm = new UploadForm(this, settings, true, file);
uploadForm.Show();
this.Hide();
}
}
private void MainForm_Shown(object sender, EventArgs e)
{
var settings = Settings.LoadSettings();
var args = Environment.GetCommandLineArgs();
if (args.Length == 2)
{
var file = args[1]; // Second argument because .NET puts program filename to the first
var uploadForm = new UploadForm(this, settings, false, file);
uploadForm.Show();
this.Hide();
}
}

So I think it should work to add a Foreach loop after Line 75, maybe something like this:

else if (args.Length > 2)
{
    foreach (var file in args) 
    {
        if (Array.IndexOf(args, file)%2 == 1)
        {
             var uploadForm = new UploadForm(this, settings, false, file);
             uploadForm.Show();
             this.Hide();
        }
    }
}
micha3056 added a commit to micha3056/VirusTotalUploader that referenced this issue Aug 27, 2023
micha3056 added a commit to micha3056/VirusTotalUploader that referenced this issue Aug 27, 2023
micha3056 added a commit to micha3056/VirusTotalUploader that referenced this issue Aug 27, 2023
micha3056 added a commit to micha3056/VirusTotalUploader that referenced this issue Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant