I have a C# application that runs on a computer connected to a large display in our cafeteria. The application pulls all the PowerPoint files out of a folder and runs each one as a slide show continuously. Everything was working fine until someone decided to insert a movie clip onto a slide. The problem is that the movie never starts. If open the presentation in PowerPoint and run the show it works, and if I right click on the presentation and click 'show' it works. Here is the code I am using to open the presentation and start the slideshow.
pres = app.Presentations.Open(pptPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MMsoTriState.msoFals);
pres.SlideShowSettings.Run();
Is there something else I need to set to get the Run() method to also start movies?
Edit: The presentation in question only had one slide in it which contained the movie. If I added another slide to it, it worked fine. Also tried adding a slide before and had the same problem, so apparently the problem only exists for the last slide in the presentation.
The main issue here is that PowerPoint animations (video, audio, custom motion paths, etc.) will only play when the SlideShowWindow has the focus. What this means is that when you're running your app and launching PPT, your app still maintains the focus and hence animations don't run (that doesn't stop you from manually manipulating your running deck though).
There are a couple of ways around this:
You can call the API SetWindow to
bring your SlideShowWindow to the
front. Not a great way to do it in
my opinion.
The very easiest way is just to save
your .ppt/.pptx to a .pps/.ppsx
(PowerPoint Show). With that, you
can use your same code to run it and
it will launch and take the focus
automatically (and your animations [video, et al) will run as you've intended).
Found the problem. I had a thread.sleep statement in the presentation's app_SlideShowNextSlide event handler that handled the end of one slideshow and starting the next. I wasn't thinking at the time and this code was running in the same thread at the slideshow itself. I created a timer object instead and moved the necessary code into the timer's elapsed event handler.
Related
I know this issue has been addressed a lot, but I haven't found a problem similar to mine, so please tell me if there's a solution.
I'm using selenium webdriver (chrome) and C# to test a web application.
In the application I have a button, which opens a windows file dialog in order to select and upload the file.
I am using Click() to click on the button and SendKeys() to paste the file's path in the windows dialog and to hit "Enter".
I'm not trying to control the dialog with selenium.
It's successful most of the time, but sometimes the dialog isn't opened once the button is clicked and it seems to be frozen for several minutes (it's impossible to click the button manually as well), but the test resumes as if the dialog had been opened. After 2-3 minutes the windows dialog finally appears, but needless to say that the entire test is messed up.
It is not a problem in the program itself, as the problem never occurres when the click is preformed manually.
What could be the problem and how can I solve it?
Please have in mind I cannot change the program I'm testing.
Thank you
You can do it without White using Microsoft UI Automation directly.
Without TestStack White. No sense to use the whole library for one window automation. White is wrapper only.
var FirefoxWindowElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty,"MozillaWindowClass"));
FirefoxWindowElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty,"#32770"))
//You can navigate directly to input field or just use the keyboard because input field is always focussed
SendKeys.SendWait("YOUR FILE PATH here");
Keyboard.Press(Key.Return);
What if you create a wait for dialog?
public void waitForElement()
{
while(!yourDialogElement.Displayed)
{
yourButtonElement.Click()
System.Threading.Thread.Sleep(1000) // sleep for 1000 milliseconds
}
}
You will probably want to build a try/catch into that button click, and perhaps build a counter into your loop and pass a timeout limit.
Let me know if this works or if you need more help!
You should consider adding a library called WHITE to your framework. This acts like Selenium but for Win32 applications and can handle most types of Windows dialog objects via Microsoft UI Automation.
With WHITE set up, you can add a method at the point in your code where the button is clicked by Selenium that opens up the dialog window. This method can poll for the presence of the dialog and if, after a set time, the window does not appear you could either fail the test there and then or try clicking the button again.
You could also poll indefinitely until the window appears if you are confident it always will. I would set an upper limit myself though to 5 minutes or whatever you feel is right here to prevent some sort of infinite loop situation.
I’m developing a screen saver in C# .NET4.0 on VS2010 which needs to do a fair bit of processing before it actually shows screens (fairly complex database access). This is fine because the user is unaware that this processing is going on and then the full screen forms kick in when everything is ready. That is, unless we are running on Windows 8.
Searching on the Microsoft Community (http://answers.microsoft.com/en-us/windows/forum/windows_8-desktop/bubbles-screensaver-has-black-background/e0807324-5ca6-4abe-b6ba-716848b41ff5?page=4) reveals that a design change was made in Windows 8 that prevents screensavers from drawing over an image of the desktop. Any screensaver that previously drew over the desktop will instead draw over a plain background using your chosen “metro” background colour. Experimenting reveals that this background kicks in immediately the .scr file launches i.e. before any forms can be displayed. Hence tricks like displaying forms minimised or with 0% opacity don’t work because this simply reveals the plain background underneath.
The best I’ve been able to come up with is to display full screen plain black forms as first action when my code starts i.e. before any database processing or other screen construction takes place. Why try to replace a plain screen with another plain screen? Well, because the default Windows background colour seems to be blue. That’s blue as in BSOD blue which looks kind of alarming when it kicks in. So the best I can do for a Windows 8 user experience is a quick flicker of blue followed by 3-4 seconds of plain black before screens are populated with something meaningful.
This new behaviour from Microsoft is apparently “by design”. The fact that it doesn’t manifest itself in Preview mode is apparently an error which one supposes MS will tidy up later.
So my question is does anyone know any way around this so that I can continue to have the desktop showing until screensaver forms are ready to kick in?
I struggled quite a lot with a similar problem regarding this awkward design decision in win8.
I the end had to compromise but my search continues for a a bullet proof solution, when I have time.
Now what I ended up with is running a batch file after the monitoring system starts and have thread detect idle time and run that batch again.
#start /wait Bubbles.scr /s & rundll32 user32.dll,LockWorkStation
What this does is:
starts screensaver preview in fullscreen (this works in win8) and waits
on user action lock screen is show and user prompted for password
As I said it's a compromise until a find something better. Hope it helps
Updated to win10; try to use that cool scr and found same issue;
Try to trick ms restriction and found only one very long solution:
enable logging of screensaver invoked events;
here instruction via gpedit: https://superuser.com/questions/538146/run-a-batch-cmd-upon-screensaver
now you will able to start other comand or app when screensaver starting;
goto C:\Windows\System32
copy Bubbles.scr and rename to Bubbles.exe
then config task to run C:\Windows\System32\Bubbles.exe with argument /s (administration->taskcheduler)
use some windows screensaver and config to use 1 min or more; (or use 'runsarver' with empty options from upper link or create your own empty.exe and rename to .scr and install with right menu, etc)
Found cool app to customize hidden screensaver features: http://winaero.com/download.php?view.8
(work with small bugs but work as needed under win10)
All work fine one cons checkbox to lock PC must be unchecked;
If needed create own app to run Bubbles and on exit lock PC or bat file as above, etc;
hope people will have fun with my solution :)
I wrote a command line application in C#.NET that programmatically edits an existing powerpoint, and then starts the slideshow. The powerpoint is automatically configured to advance slides. The problem I am running into is that powerpoint will quit after 4 hours. Any ideas?
I think the computer is going to sleep or my other guess is that the program is causing a memory leak causing the program to crash out and close.
If the computer's gone to sleep or the screensaver has kicked in, waking it back up should put you back inside a running slide show.
If the slide show has actually stopped, I think you can rule out a sleeping computer/screensaver problem. In that case, it might be a problem with your program or it might be that PPT just craps out after some amount of time running a slide show. In some versions on some computers (nobody's ever been able to pin down the magic combo that triggers this).
To rule that out, start the presentation independent of your app and see if it runs w/o problems.
Like everybody already mentioned. Maybe the screensaver or when the Presentation is over, it closes. Maybe you could write your program in such way, that when it is on the last slide, to start again from the 1st one, which will actually create an infinite loop. If your goal is to only show the slide show.
Hello I want to press a button with my app. So I use SendKeys class
SendKeys.SendWait("{RIGHT}");
Problem is that I need to wait 3-4 seconds after this line code for reaction from system. How can I speed it up or how can I delete this delay ?
// update 1
I've also tried
SendKeys.SendWait("{RIGHT}");
SendKeys.Flush();
BUt id didn't help
// update 2
I want my app that works in background to press a button programaticly in the actual active state of the user. So if he is in excel i want the right arrow to move the active cell, if he is in the game i want to turn right etc. SendWait does the thing I want but with some delay that I don't want.
Second important thing that this is not a virus or worm or anything like that. First of all as you can see I'm too stupid for that and secondly I'm playing with my KInect so this is some kind of interaction beetwen user and computer. Thats why it works in background and thats why I need to send it to the active app of the user
SendKeys is a nice little feature for Windows Form applications. Based on your tag it appears that you're using Windows Presentation Foundation, which will not support SendKeys.Send()
https://stackoverflow.com/a/1646568/340574
Take a look at the link above to use KeyEventArgs. I've read that you could also add a reference to System.Windows.Forms.dll through Visual Studio to use SendKeys, but I have not tried it myself.
How do you attach the debugger to the Windows Emulator (or Device) to debug runs from Secondary Tiles?
I'm created a secondary tile but it has some problems loading the data and I can quite figure out what is going wrong. How can i attach to the process so i can debug it?
Thanks for your help!
You can't. A click on a live-tile doesn't resume the previous instance, but creates a new one (or resets the navigation-stack, from a users perspective it's the same)
But considering that a Live Tile is nothing but a URI, I see no reason you need to click on the actual tile to test the functionality of such a URI. You could simply change the NavigationPage property of the DefaultTask in the WMAppManifest.xml, to be the URI your tile is meant to open with.
If you have a specialized functionality related to your tile, you should tell us, so we can give a more detailed answer.
This works for me...
Start app as normal
Tap Home
Tap second Live Tile
The debugger stays attached when the app closes (this allows testing of tombstoning etc) so it is still attached when you tap the second tile.