@stottle
Sadly, EG's mouse emulation doesn't work right for UAC prompts. Even though EG can work in the background, while an UAC prompt is shown, EG doesn't seem to be able to move the mouse or do any mouse clicks on this "UAC desktop".
I use some program (InputDirector), that also has to emulate mouse movements and clicks, and this one is able to emulate the mouse while an UAC prompt is up. This program runs as a service, so I came to the assumption, that a service running under the system account might be able to do this.
So, could you please try (just as a proof of concept), if your service is able to emulate a mouse click with mouse_event(0x0002, 0, 0, 0, 0), followed by a mouse_event(0x0004, 0, 0, 0, 0) for the release of the button, while an UAC prompt is shown? I guess, you can simple start this on any reception of an IR sequence and move the mouse manually onto a button of the UAC prompt, just to see if it would react.
I don't want to start writing a service, just to find out, that I follow the wrong assumption.
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Calling mouse_event from a service
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
Calling mouse_event from a service
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Re: Calling mouse_event from a service
I'll give it a shot. It will be a day or two.
Brett
Brett
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
Re: Calling mouse_event from a service
There's no hurry. I already have enough to do with other problems. But it might get interesting someday.
You might also have to start your service with SERVICE_INTERACTIVE_PROCESS to get it working.
http://support.microsoft.com/?scid=kb%3 ... &x=10&y=18
You might also have to start your service with SERVICE_INTERACTIVE_PROCESS to get it working.
http://support.microsoft.com/?scid=kb%3 ... &x=10&y=18
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Re: Calling mouse_event from a service
Ok, this is a bit harder than I expected. You need to create the service as interactive, and impersonate the current user, as suggested (but without showing how, unfortunately) in the link you posted. Since the problem is getting a service to attach to the desktop, I've got an example service that successfully moves the mouse. But that's without a UAC prompt, and I can't easily get the service to work when the UAC prompt is up. I think it will work with UAC, but I'm not positive.
BTW, I also found this link useful, I don't know if you've seen it.
There are three problems going forward with having testing my service with UAC.
1) I would need a new thread specifically to impersonate from (since I need elevated privileges to connect to the IR Receiver, and the logged in user may not have those privileges) and run the mouse events.
2) I start the service on boot, when there isn't a logged on user. So that would need to change as well (or potentially kick off the above new thread when a EG starts?).
3) I pass all of my codes to EG, so I would need to put the decoding back into the service.
That's quite a bit to tackle. Maybe an easier way will come to me, but I thought I'd post my progress so far.
If you want to try any of this yourself, here are some of the particular parameters I been using so far:
To impersonate:
Also, I didn't use mouse_event, I used SendInput instead. And I moved the mouse to the top-left of the screen, rather than mouse click (easier to see if it worked). Here's the mouse code:
Brett
BTW, I also found this link useful, I don't know if you've seen it.
There are three problems going forward with having testing my service with UAC.
1) I would need a new thread specifically to impersonate from (since I need elevated privileges to connect to the IR Receiver, and the logged in user may not have those privileges) and run the mouse events.
2) I start the service on boot, when there isn't a logged on user. So that would need to change as well (or potentially kick off the above new thread when a EG starts?).
3) I pass all of my codes to EG, so I would need to put the decoding back into the service.
That's quite a bit to tackle. Maybe an easier way will come to me, but I thought I'd post my progress so far.
If you want to try any of this yourself, here are some of the particular parameters I been using so far:
Code: Select all
schService = CreateService(
schSCManager, // SCM database
SVCNAME, // name of service
SVCNAME, // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_INTERACTIVE_PROCESS | SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_DEMAND_START, // start type
SERVICE_ERROR_NORMAL, // error control type
szPath, // path to service's binary
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // no dependencies
NULL, // LocalSystem account
NULL); // no password Code: Select all
DWORD id = GetCurrentProcessId();
HANDLE hp = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
HANDLE t;
BOOL b = OpenProcessToken( hp, TOKEN_QUERY | TOKEN_DUPLICATE , &t);
if(!ImpersonateLoggedOnUser(t))
return;Code: Select all
MOUSEINPUT mi;
mi.dx=0;
mi.dy=0;
mi.dwExtraInfo=0;
mi.dwFlags=MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE;
mi.mouseData=0;
INPUT pInputs[1];
pInputs[0].mi=mi;
pInputs[0].type = INPUT_MOUSE;
SendInput(1,pInputs,sizeof(INPUT));