c# winform above chrome in kiosk mode - c#

I'm having trouble getting a winform to appear above chrome in kiosk mode.
My goal is to have a transparent window display certain system information on top of all other windows. I have set this.TopMost = true and have even added the script:
private void keepWindowOnTop()
{
while (true)
{
if (!this.TopMost || !this.TopLevel)
{
this.TopMost = true;
this.TopLevel = true;
}
Thread.Sleep(1);
}
}
Still, when my winform launches chrome kiosk is on top.
Any suggestions would be greatly appreciated!
Edit: I need the transparent window to always be in the foreground even when other windows are selected (clicked). This feature works fine when running from Visual Studios, but after the application is installed on a separate system it breaks.
Could it be because I'm importing the .dll at run time? Does that have any effect on TopLevel?
cheers

Related

C# Winforms change taskbar icon

I have an old legacy system that uses Winforms and is published with the built in One click,
I look after 3 different installs and each one has its own database it connects to, so its been set up that when a different system is click, it check isCompany1 and will set the Favicon accordingly
so when depoyment is done in the application window the Icon and Manifest is set to the correct ICO, when installed the .exe icon will be what is set there,
However i am trying to bring these all inline as when we debug a drop asks which database we would like to connect to, and depending on that it will set things up differently.
When running in VS the icons in the taskbar will change accoring to the dynamic Favicon however when its depolyed with this new selection it wont change, (it will change once on first load, then wont again)
The issue is some users need access to the different instances so would like different icons at the bottom, but its not changing the task menu, but everything else such as ALT-TAB and the control panel icon is changing,
all forms link into a baseform and call this :
if (App.IsCompany1)
{
this.Icon = new Icon("Resources\\Company1.ico");
}
else if (App.Company2)
{
this.Icon = new Icon("Resources\\Company2.ico");
}
else if (App.Company3)
{
this.Icon = new Icon("Resources\\Company3.ico");
}
AS i said this will change everything but not the Taskbar, but will from VS debugging,
I have made sure the .ico has all sizes, by writing their sizes on each one, and they display correctly the Taskbar and ALT-TAB both use 32x32
If it's any consolation, I couldn't reproduce your complaint.
I put 3 icons in resources, a single button on a form, this code:
private int iconum = 0;
private Icon[] icons = new[] { Properties.Resources.icon1, Properties.Resources.icon2, Properties.Resources.icon3 };
private void button1_Click(object sender, EventArgs e)
{
this.Icon = icons[iconum++ % icons.Length];
}
And it cycled through the icons in the main form title bar and the windows task bar over and over on every button click (made sure to run a release built exe too, not a debug start):
Note: the thing in the top right is my taskbar

Bringing focused window to the front

I have a wpf/.net 4.6.2 application. What I need to do is to open browser (IE) in full screen mode and after that, in 5 seconds for ex, bring my application window to the top and make it focused, so that when I click on the browser (which is apparently behind) the application would appear covered
window.Topmost = true;
window.Topmost = false;
window.Focus();
window.Activate();
On Windows 7 it works perfectly, but on Windows 10 it appears as topmost but non-focused, and as a consequence, when I click on the browser, the application stays on top, and I have to click the application first (to give it focus) and then the browser, and only after that, browser covers the application
Unfortunately I am unable to comment yet due to my low rep; however, I would like to suggest that you swap the focus and activate calls around.
window.Topmost = true;
window.Topmost = false;
window.Activate();
window.Focus();
Also, why are you setting the window topmost twice? This seems to be rather counter-intuitive as the final result would always be false.

Alert or Open login window while switching between application using wpf application

Let me first explain the scenario:
If in case , I have more than two windows open say for example notepad++,paint,chrome,Skype etc. Now any of the these windows come into focus using ALT+TAB or on left click of mouse. The alert or login window created using wpf should always open.In short it should get alert on each of window come into focus in my computer whether it is notepad++, chrome, vlc or any application listed as open(running application) in task manager.
I tried below code but it throws alert only when any of application is opened for the first time and not while switching between already opened applications so far.
Automation.AddAutomationEventHandler(
WindowPattern.WindowOpenedEvent,
AutomationElement.RootElement,
TreeScope.Children,
(sender, e) =>
{
var element = sender as AutomationElement;
this.Dispatcher.Invoke(() =>
{
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
this.Topmost = true;
this.WindowState = System.Windows.WindowState.Normal;
MessageBox.Show("window opened");
});
Hope the point is clear. I m stuck here for switching between the windows scenario. Thanks

Selenium Chrome C# doesn't work if browser is minimized

I integrated Selenium Chrome driver with my little .NET application. I'm doing automation on a google page. All is working fine and as expected as long as the browser is visible or in the background. If I minimize it it stops before doing any work. I have a lot of code with lots of DISPLAYED tests:
var collection = cdriver.FindElements(By.TagName(#"input"),10);
//var collection = cdriver.FindElementsByClassName("gwt-TextBox");
bool found = false;
IWebElement texter = null;
do
{
foreach (IWebElement element in collection)
{
if(element.GetAttribute("class").ToString() == "gwt-TextBox" )
{
if(element.Displayed==true) { found = true; texter = element; }
}
}
} while(!found);
texter.SendKeys(readerCSV.apkTitle);
Is there a way for me to minimize the chrome window so all the code that is working fine when the window is maximized or visible will also work fine with it minimized ? Enabled tests don't work as expected.
Another example:
var btnUpload = cdriver.FindElement(By.Id("gwt-uid-170"),10);
btnUpload.Click();
The above btnUpload.click() code gives me QpenQA.Selenium.ElementNotVisibleException
Is there a startup option for the chrome driver so I can start the window without the minimize button?
Chrome has to be pulled up because the driver is checking to make sure that the element is visible/enabled/etc to the user. Just stop minimizing it and let it run in the background and it will work.

Hide the taskbar using C#

I am running Windows XP 64 bit. I want to hide the taskbar when I run my application.
I tried codes by searching the web. In all those, it hides the task bar. But the problem is, when i open a notepad and maximize it, it is not actually into full screen. Because the space where task bar was there is still blocked with empty space. I want it fit really into full screen mode.
If you like to replace the windows shell (taskbar) you'll have to change a registry key.
Changing the default shell (all users):
open regedit (start menu > run, and type in regedit)
go to: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.
Change Shell from explorer.exe to your program path and name e.g. c:\myKioskApp\Kiosk.exe
Changing the default shell (only current user):
open regedit (start menu > run, and type in regedit).
go to: HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon.
add a new string value (Edit > New > String Value) called shell. and set the value to the path of the new shell e.g. c:\myKioskApp\Kiosk.exe
log out and log back in.
I've done this by making the application borderless, maximized, and setting it to be Topmost. Here's a perfect example from CodeProject.
As one of the commenters has said, replacing disabling Explorer and running your application might be the best way, security-wise.
You Can Hide your task bar by setting Following Properties of your C# Form.
WindowState : Maximized
FormBorderStyle : FixedDialog
on window 7 (or maybe higher) using FormWindowState.Maximized is wrong because the maximum size will be subtracted by Taskbar height but you can do this
this.WindowState = FormWindowState.Normal; // or default
this.FormBorderStyle = FormBorderStyle.None;
this.TopMost = true;
// do it here
this.Location = new Point(0,0);
var fullscreenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
this.Size = fullscreenSize;

Categories

Resources