VBscript SAP loose focus by Task Scheduler - vbscript

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.

Related

C:\windows\SysWow64\CScript.exe window pop up

I created a macro in Excel and i am running it from a .vbs file. It's working fine on my laptop. I copied the same work on a new laptop and each time i am running the vbs file this window appears on the screen.
I have made some research and read that the situation i mentioned is happening when loading CheckNDISPort service on the startup. But i don't believe it's the reason because when i go to task manager and check in the startUp tab i don't find this service. Also when i restart my laptop i don't get this window, only when i am running my vbs file. I am sure there is any problem with my vbs file too because on the other laptops it's working fine.
Any suggestion please how to get ride of this pop up ? For now i am closing the window each time or ending the task from task manager but everytime i run it again so it pops up again.
Thank you very much.
Windows Scripting Host has two interpreter front-ends, wscript.exe and cscript.exe. cscript.exe is a console application and if cscript.exe is set as the default a console window will open every time you execute a script.
Run cmd.exe elevated as administrator and run wscript.exe //h:wscript.
Depending on the Windows version, you might also be able to right-click a .vbs file, select "Open with...", choose %windir%\system32\wscript.exe and check the "default" checkbox.

Making the browser reload user script automatically

I'm currently working on developing a user script for Firefox. Every time I've made a change, I have to manually refresh the tab with the script and reinstall the script. I want to do the thing that's asked in this question, but in Firefox.
Is there a way to automate this so that the user script automatically gets reinstalled every time I save the file in emacs?
If I understand your quesiton correctly you want to avoid the hassle of reinstalling your userscript each time you save it in your editor.
Here are the step-by-step instructions.
Install Greasemonkey in Firefox.
Install your script in Firefox (via Greasemonkey).
Firefox Menu -> Tools -> Greasemonkey -> Manage User Scripts -> Right-click on the script you are working on.
(a) Select "Edit" to open your script in your default editor (emacs?).
or
(b) Select "Show Containing Folder" to open the folder containing your script and subsequently open it with a custom editor (e.g. emacs).
Update the script in your editor as needed and the modification will take effect the moment you save it. Yet you still have to refresh the web page on which your script runs in order to see the result.

how to detect programmatically when a powerpoint slideshow starts

I would like to write a windows program that would enable the user to choose a ppt file. When that ppt file starts the slideshow, my program would automatically display some message in front of the slideshow. When the slideshow is over, my program would close itself. What do I need to learn to write this program?
I'm not good with VBS (which I'm sure you could use for this) but if you set your show's extensions to .PPS instead of .PPT that will force them to start playing automatically on open. Then you won't need to see when the show starts because you'll control that.
As for opening it, if you write BATCH script you can use it to prompt for a file location but it will all be manually typed because it will load from the command window. If a show opens, the command screen can stay open until that slideshow closes, then continue with the next line of script.
Depending on if these are your powerpoints that you want opened, I personally would put VBA script in them to trigger On_Open and On_Close That will get you a clean customizable popup error message.
Edit
After doing some quick searching the On_Open and On_Close is not found in PPT, you would need to install an add-in.

OS X kernel extension graphical uninstaller

XCode doesn't include uninstallation options for their packager. Generally users simply drag the app to the trash if they want to uninstall it - most apps are self contained in the app package.
However, I have a kernel extension which must be uninstalled using a few simple command lines. There is a script that works, but I am required to provide a graphical uninstaller.
I don't expect there's a plug-n-play example code out there that provides a way to run the script while showing a progress bar, but I'm hoping someone has dealt with this or has a few pointers on how to accomplish this quickly and easily
The script is only two lines with no feedback, so we can execute the commands in the app, as long as we can easily request and use root permissions securely (ie, let OS X handle the permissions - we merely ask for OS X to give them to us which should cause it to ask the user for them similar to how it happens with the package installer) inside the app.
There's a reasonably good approach using a Cocoa-Applescript project in xcode to run a shell script here:
http://www.mactech.com/articles/mactech/Vol.22/22.08/GUI-upyourScript/index.html
It covers using a progress bar, handling errors, and getting the correct root permissions to run the shell script.
Unfortunately it's a bit long to cut and paste here, but the general steps are:
Create new xcode project of type Cocoa-Applescript app
Create and test the intended shell script, add it to your project
Edit the MainMenu.nib to add and name a button(theObject) and progress bar(pMainProgress), then edit title and other aspects of the ui to taste
Tie the button to the applescript in the project (in the Inspector with the button selected check the action box and put in myprojectname.applescript)
Edit the applescript to something akin to the following:
on clicked theObject
-- setup
set myPath to POSIX path of (path to me) as string
-- Start progress bar
set uses threaded animation of progress indicator "pMainProgress" of window "wMain" to true
tell progress indicator "pMainProgress" of window "wMain" to start
-- Do it!
try
do shell script quoted form of myPath & "Contents/Resources/backup.sh" with administrator privileges
on error number 255
display dialog "Sorry, an error occurred. I can't make the copy."
end try
-- Stop progress bar
tell progress indicator "pMainProgress" of window "wMain" to stop
set uses threaded animation of progress indicator "pMainProgress" of window "wMain" to false
end clicked
You can further customize the app (name, for instance) and add text boxes to the window to alert the user what step is happening if you're running multiple scripts (put set the contents of text field "efStatus" of window "wMain" to "Copying files..." in your script after adding a text field to the ui with the name "efStatus")

Microstation launching into a blank window (no menus or anything)

We have a VB6 application here that automates the process of opening drawings and printing them with a specific printer that turns them into TIFF files.
I'm in the process of testing the application as we upgrade from V8 to V8i and I'm running into some problems just launching the application.
If I open the Microstation normally via the exe file everything works ok. But when I do:
Set msApp = CreateObject("MicrostationDGN.Application")
It opens a blank microstation window with no menus or anything (basically what the window looks like behind the file open dialog)
And then I do
msApp.OpenDesignFile ("dummy.dgn")
that looks like this: imgur.com/A5rc4.png
Is there something new with v8i where it doesn't bother loading the gui when opened as an object?
Did your application depends on some user preference of Microstation? I think you can debug your aplication step by step.
You can call the ustation.exe with the parameter -debug. This creates a file called debug.txt in the current working directory.
There you might find some helpful info.

Resources