I've got a problem I can't pass by. I have a script that is generating table in SAP and exporting is as spreadsheet and saving in proper location. It works perfectly when I do it by double-clicking on file, but it can't finish script via Task Scheduler in the moment it's exporting file from SAP in 'Save As' window. Script opens 'Save As' window on exporting and just SendVkey Tab Tab Tab Tab Tab, paste proper file location, Tab and Enter.
I figured out it works when i run it through Task Scheduler and simply click on SAP while script is running so it gets focus and everything is ok. And if I just run it by Task Scheduler and don't do anything it seems like it's working in background and SAP doesn't have any focus so my TAB keys are going somewhere else on windows (probably desktop) instead of going in 'Save As' window properly. The same story is when i Run file by double-clicking and minimize folder where the script is. It looks like SAP looses focus again and my TAB keys are not working.
So script is only working when I double-click it and don't do anything or when I run it by Task Scheduler and click on SAP window to give it focus.
Is there any way to bypass it? Can I somehow simulate click on SAP window when script is running automatically or do I have to change something?
I tried many ways, but I'm a beginner and can't figure it out.