I've seen tons of discussions in the web about techniques to send files to WhatsApp Web or Telegram Desktop. Lots of ideas, people usually send the file to the clipboard, locate the WhatsApp window, set the focus to it, and paste the file using SendKeys. Yes, that works! But it fails very often too!
So, I tried using the OLEStartDrag / OLECompleteDrag methods, in order to provide a more friendly and reliable way to send files to these Apps. This resulted very promising, and the files were dropped to WhatsApp, but it seems that WhatsApp kept holding a reference to the parent Window from where the file was dragged, making it impossible to close the "Sender" window! Sample in Foxite forum
Finally, since we know that from the "Windows File Explorer" files can be dragged and dropped with no issues, my next obvious try was to add a WebBrowser control, navigate to any folder, and voilá! Files can be dropped normally to WhatsApp from the VFP window, bringing more productivity to our Apps!
Below is the final result, that was introduced to FoxyPreviewer 3:
In summary, the trick is:
- Create a new temporary folder
- Store only the files you want to allow to share
- From the WebBrowser control, navigate to that folder