I need to write a program that forces Google Chrome to be in the front and disable all other actions like opening another program etc... I just need to have Google Chrome in front of the screen and that's all. I can't allow other programs to pop up.
Any ideas how it can be done?
Thank you!
Im pretty sure as far as you can get is a popup window that has no scrollbar or top bar, and can't be resized, but JS wont let you manipulate stuff outside the current window, just like you cant auto-click links inside an iframe
I highly doubt this is possible in Windows, and if it is it won't be ethical if used on home PCs. Will this be a kiosk style app?
You can control what appears in the browser to some extent, such as scrollbar-less windows but much more than that is impossible.
Definitely not ethical at all but applications such as Fortress 101 can do this. I have done similar things in the past using C and the Win32 API. I won't write the code for you but I basically did the following:
Find the desktop and hide it
Find and hide the taskbar
Find and destroy the start button
Capture special keypresses and prevent them from working as expected
You would also need to poll a process list because even doing all of that doesn't prevent the user from downloading a file and executing it. Thus if you found a new application in the process list, you could destroy it.
You could do this using user32.dll with C# but such an application would better be left to commercial software packages.
Related
Gday,
I am currently doing a small Unity project where the game takes place on the desktop, we have a creature that communicates with the player. It is currently severely limited with how it acts/reacts due to the only way that I can figure out how to make popups in the windows system style is through the use of the MessageBox function which is Modal (it suspends the application from running until the MessageBox has been answered or closed).
So I was wondering if there was any way to get the same effect without it suspending the entire application, I've tried looking into Forms however I can't get it to recognise it as a thing in VisualStudios. I have also looked at GUI.Window however doesn't create a window that looks like a Windows style popup.
What do yall reckon?
(Thankyou in advance)
In general, trying to mix Unity and WinForms is a really bad idea. They were built around completely different design philosophies and if you keep going down this path, they're going to keep fighting each other.
The best option here would be to create your own lookalike windows in-game. That would require quite a bit of work and infrastructure to set up at the beginning, but it would also give you full control over the style and behaviour of the dialogs.
Browse the asset store for assets that solve the problem for you. There are a number of dialog type assets you can grab and plug into your unity project to get you running quickly. A lot of them mimic windows features like moving around, scrolling or X to close.
Is it possible to take a screenshot of a partially hidden window without brining it to front? I know this is possible because the Screen Capture API already does this.
https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture
The picture shows the popup when you initiate a capture process. You can see the same popup on Discord or Slack whenever you would like to share your screen. In the popup, you can see the list of the windows that I have open. Some of the windows are partially or completely hidden. However the popup shows the entire contents of them, which is surprising to me. The popup does not show minimized windows, which is fine. This works cross-platform.
I would like to know how the Screen Capture API does this as I have never succeeded in doing so. I personally tried with Win32 + GDI32 APIs but I was unable to take the screenshot of a hidden window. I would prefer a cross-platform solution but for now I am only targeting Windows 10+.
Thank you in advance.
#simon-mourier Thank you for the comment. That was helpful.
https://blogs.windows.com/windowsdeveloper/2019/09/16/new-ways-to-do-screen-capture/
#NothingIsImpossible
I am interested to know how can I do the same thing that the apllication listed below does:
Start Menu Calculator
I want to know how can I create an custom tab in Start Menu Search and then handle it with my WPF application. It should only be enabled until my application is running.( Just like what The calculator does )
I read something about windows API Code Pack and I downloaded it but I don't know how can I use it. I searched through it but I didn't find anything.( If you know how I could do this using with Windows API Code Pack, please write an example that explains how to do it in C#)
The main exe "Start Menu Calculator.exe" installs a windows hook (using SetWindowsHookEx) into explorer.exe. The hook is implemented as usual in SBLib.dll which is then injected into Windows Explorer's memory space.
This hook searches for window handles belonging to the search box. See a discussion around this here:
How do I get a "handle" on the Windows Search textbox? and probably sub classes the search box windows (if you kill the "Start Menu Calculator.exe" process abruptly, it crashes Windows Explorer too... which kinda confirms this)
It then reacts to key presses, and I suppose it butchers up the result window. In the hierarchies of Windows, I think it's a Window named "Desktop Search Open View", you can get to it with SPY++ under "Start Menu", aside the windows mentioned in the msdn forum above.
So, no nice API behind this nice application. Massive hacks instead :-)
I think however, some level of integration is possible, using documented behavior, with the search box. I have not dug further, but there is the notion of federated search in Windows (Windows 7 Federated Search). I don't see if this would be capable of reacting instantaneously to what the user types in though...
As a side note, if you're also looking for a way to run javascript code from C#, there is a question here on SO that says it all: parse and execute JS by C#
When making Start Menu Calculator I initially tried to use federated search and Managed (.NET) code however you can't integrate into the start menu, only the shell search (for web service based search which lets you return custom results based on a search string). The problem is that the federated search is structured such that all the search data is pre-indexed so for the calculator to work I would have had to pre index every possible calculation! The reason it all works this way is to make sure that clicking the start menu is always fast and responsive (you don't want a web service call everytime you press start in the shell).
I ended up hiring someone to write a native windows app that places a IE control into the Start menu search area and passes the searched text in with the source. All the visual stuff is just css made to look like the start menu rendering and the calculations handled in javascript.
So yes, a bit of a hack but it seems to work and I havent had/heard of any crashing issues so far.
my objective is to attach a context menu (vista and win7) whenever user right clicks a picture/file.
I've got the file portion down (ie, they right click on a file and my menu shows up) but I am having trouble understanding what I would need to do in terms of right clicking in firefox or ie .
I am trying to add a context menu whenever someone right clicks on an image file in IE or firefox. is that possible?
If you want to plug in to what happens inside the user's browser, you should probably write a browser extension to do that, instead of trying to hack up something awful that sort of does what you want maybe.
The best solution would be to develop a plug-in for the browser used by your user, whether it be for Internet Explorer, FireFox or Chrome etc..
Trying to create some sort of hack will only lead to a bad experience for your user so it's better to develop something that would work properly.
Here's a few links to get you going in the right direction:
Google Chrome: http://www.mattcutts.com/blog/write-chrome-extension/
Mozilla FireFox: https://developer.mozilla.org/en/Gecko_Plugin_API_Reference/Plug-in_Development_Overview
(I can't seem to find any for Internet Explorer)
I'm sorry i cannot give you a definitive answer but hopefully this should get the ball rolling for you at least.
is that possible?
NO
For Browsers: You need to develop an extension for each browser you want to support
For Desktop: http://www.codeproject.com/KB/cs/dateparser.aspx (ignore all the stupid istruction about how to catch the datetime )
I'm sure others have run into this problem too...
I often watch videos in a small VLC window while working on other tasks, but no matter where the window is placed, I eventually need to access something in the GUI behind it, and have to manually reposition the video window first.
This could be solved by having the VLC window snap to another corner whenever the mouse pointer is moved over it. I haven't found an app that does this, so would like to write one. What technologies could I use to do this? Cross platform might be harder... so what if just on Windows?
I'd prefer something in C# (or Python), but am willing to learn something new if need be.
Here is a windows only solution. You dont need to actually put the mouse over the window. All you need to do is Find the window using its name and send WM_MOVE. I dont know the name of the window which VLC uses. You could use Spy++ to find its name.
This is a bit OOT, but in Windows 7, shaking the active window will hide others to reveal the desktop (and so will clicking/hovering the rightmost taskbar button). Instead of hiding/moving vlc, you could just temporarily reveal the whole desktop. Shaking the active window again brings everything back.