Interrupting a service/thread that is simulating keyboard/mouse input

MattNorman

Well-known member
Joined
May 22, 2021
Messages
62
Programming Experience
1-3
I am using keyboard and mouse simulation as part of a windows service that is essentially selecting different open windows and exporting data every 3 seconds.

This is all working fine however i'm not sure how I would go about stopping the service/thread when it is constantly simulating keyboard/mouse input.

The only way I have come up with is to have a state stored in the database that the thread checks on each run to see if it has been set to disabled.

That should work fine but would mean opening the app from another PC/server to change that flag in the database.

Can anyone suggest any way of achieving this on the servers that is running the service?
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,083
Location
Chesapeake, VA
Programming Experience
10+
If you look at most modern AV software, the AV software is running as a service (because it needs the elevated rights), but the AV software also has an icon in the system tray through which you can bring up UI to change settings, pause the scanning, etc. You can do the same thing.

How the UI communicates with the service is going to be up to you. You can use named pipes, shared memory, TCP/IP port, a file, etc. Personally, I would just have the service check for the existence of a file to determine whether it's screen scraping should be paused or not.
 
Top Bottom