Simulating Mouse Clicks within a minimized or inactive form - delphi

I'm having a hard time figuring out how to simulate mouse clicks and such in a window that is minimized or not currently active. In case it's not clear, I want my mouse to be able to click and stuff without actually using the mouse.
For example, while I'm browsing the web I would like my program to be able to be clicking inside of another application at the same time.
How can I accomplish this? All I can find is the same old movemouse and setcursorpos stuff... as we know that requires the use of your actual mouse/Cursor.

You are looking to automate applications. This is done not by faking input but by using an automation API. These days, the preferred one is UI Automation. This is perfectly accessible from Delphi: How to use MS UI Automation in Delphi 2009.

Related

Indy Telnet SendString robustness best practice

I have a simple Firemonkey application with a series of buttons and sliders (track bar) that when a user interacts with these controls it send a command using IdTelnet. i.e.
IdTelnet1.SendString(' '+str+#13);
The problem is that very occasionally the users experience total lockup of the app and windows reports the app as "Not responding" when clicking on something. I have not reproduced this myself however I suspect its related to clicking on buttons in quick succession.
My current theory is that I am getting re-entry into SendString and IdTelnet is not handling this well.
Before jumping into writing a queued sending system I wanted to ask for any best practice advice. Is this a known issue and what is the best way to do quick fire sends that are user initiated?

How to put a specific monitor into standby mode? [duplicate]

I have 3 monitors, but I don't need them all turned on all the time. I can just shut them down with power button, but I want to use their standby mode, like Windows does when we let PC idle for a while - it shuts down monitors, HDD, etc.
But of course, I wanna keep using PC and let just that monitor on standby. Others must remain on and that one doesn't wake up even with me using PC.
Is it possible to do that? It would be great to have a shortcut like Winkey+1, 2, 3 etc to shut down and wake up each monitor.
An existing app with this feature is not likely to exist, but is there a Windows API function that can control monitor state, for each monitor in a MultiMonitor system?
The display control panel applet calls SetDisplayConfig to start or stop forced projection on a particular target
You can probably use MS Detours or some other API hooking tool to inspect the usage pattern of the API while using the applet to adjust display settings.
You'll want to try Display Fusion. You should be able to do what you're asking for using Monitor configurations.
I know I'm late on this but use DDC to control your display. You can easily create hotkeys that send a command via DDC to the display to turn-off. This would be equivalent to turning off the display using the button. Works like a charm for me. The only trick is that DDC command specs vary across monitor manufacturers but its not hard to find the right codes to send with the help of google.
Ready made tools also exist for this; search for anything that is related to DDC or EDID and you should find.
Be aware though that this does not remove the display from Windows which means that apps may find their way onto displays that are off and you will be looking for them.

Is there a low overhead way to hook a mouse doubleclick using Delphi?

Here's what I would like to do in Delphi XE:
Capture a double-click in another application such that when it occurs and the text underneath the mouse is highlighted, this triggers a series of events in my application based on what the text highlighted was.
I am aware of ways to do this using a system-wide mouse hook but... Since my application and the other application will in many circumstances be hosted in a terminal service or citrix environment, I am rather reluctant to do this with a mouse hook as I'm concerned about the resource cost. (I'm picturing the server hosting hundreds of mouse hooks, one for each user... shudder). Am I being too cautious? How much is the performance and stability hit of a mouse hook? What about under the TS or citrix environment? If my gut is correct and the cost of multiple hooks would be too high, is there another way to do this?
I do not have access to the source code of the other application and the 3rd party richedit control wherein the text is found has been modified beyond all recognition and doesn't respond to the API when used as published. Help?
This isn't possible without using a system-wide mouse hook, AFAIK.
You're right to be concerned about overhead. The mouse hook (MouseProc) is called every time a window calls PeekMessage or GetMessage and there's a mouse message to be retrieved, and it will be called for every window of every application running. Even if your hook simply passes the event along to the next handler using CallNextHookEx(), it will have an impact on the system. I'd suspect that multiple sessions running under TS would be pretty nasty.

Handle forced full-screen and disable minimizing

I am working on porting an XNA game to another platform. Some of the items in the compliance check list involve making sure the game remains in full-screen mode, cannot be minimized and that the windows key, win - m, and alt-tab are disabled. The only way to exit the game is supposed to be through the platform API (think exiting an Xbox or PS3 game by pressing the home or guide buttons).
It been difficult to find any information on this since most responses to previous questions are "never remove system functionality" but in my case specifically, those are requirements.
So is there a way to handle forced full-screen and disable minimizing? I haven't been able to find a way to get WndProc to work. Likewise for key events I need to disable. I can't find a way to intercept and handle the windows messages that control these events.
This post seems to give the interop code needed for hooking into the window message loop and overriding the Windows key events:
Disable Special Keys in Win App C#
Will the .IsFullScreen = true property not solve your issue? It will help with the screen but not with the keyboard disablement.

Making Sure A ShowMessage Stays On Top

I have a few applications and I call a ShowMessage('Complete!'); at the end of a long operation.
Most of the time, this works great, but every once in awhile, the Message Dialog will show up behind the main form.
Is there any way for me to ensure the ShowMessage will always be on top?
Thanks!
Call the Windows MessageBox() API instead and pass in the handle to the active form. Actually, my code uses Application.MainFormHandle all the time which I am therefore sure is a reasonable and simple approach.
This will have the benefit of being the system native dialog rather than the home-grown Delphi version. It supports clipboard operations also.
If you want to get very fancy then you can use the Vista task dialog, but that's much more complex and you clearly don't need it for such a simple dialog.

Resources