How to simulate a mouse click of the screen on Windows XP ?
February 23, 2021 2:17 AM   Subscribe

I've tried various software (it seems) for doing this. I'm finding it either can't be scheduled or it doesn't work with Windows XP. I think AutoHotKey could do it but I can't wrap my head around how to use it. Basically we have an old Windows box which is solely and simply used for displaying (in VLC) the output of two IP cameras on the screen.

I have managed to automate the opening and resizing of the two windows so that they load on boot, but about 8 times out of 10 the resizing doesn't quite work and one of the windows simply needs a mouse click on it to bring it into focus and my resizing script recognises there's a job to be done and it's instantly resized and brought to heel.

Anyone know of a script, tool, program, macro I can use to automate a click on the errant VLC window (can be anywhere on the window) so that my script can do the rest?

many thanks!!
posted by dance to Computers & Internet (8 answers total) 2 users marked this as a favorite
 
CMDOW can change the window status to active.
posted by Lanark at 3:39 AM on February 23 [1 favorite]


autoit is what I use for similar tasks.

But sometimes you need to add some delays, retries, etc to make the script more resilient.
posted by TheAdamist at 3:44 AM on February 23 [2 favorites]


Fine suggestions above, if you want to use autohotkey you could use a script like:
#Persistent
SetTimer DoTheThing, 5000

DoTheThing:
	if WinExist("Untitled - Notepad")
	    WinActivate  ; Uses the last found window.
	return
Save as an .ahk file then you can run or compile it to an .exe by right clicking on it with autohotkey installed. Change the "Untitled - Notepad" thing to the window title you want to focus (e.g. "192.168.1.2 - TightVNC Viewer"), and 5000 is milliseconds between runs.
posted by samj at 4:26 AM on February 23


Windows has a quirk that the specific window or app has to be in the foreground to accept clicks / keys. It sort of makes sense, but it also means mouse clicks into the background doesn't bring forward the app in the background.

It sounds like you just want to "layout" the windows so it display two VLC instances side by side, say, in top half of the screen?

I think this archived post on Reddit explains it quite well, and some of the math bits can help you avoid hard-coding anything, rather just get the resolution from the settings and calculate the Windows coordinates and sizes for you.
posted by kschang at 4:52 AM on February 23


I once wrote a script for XP to tile 2 windows on the screen. See it here. What I found is that delays were necessary between some steps to wait for Windows to catch up. The delays would need to be customized relative to the speed of the machine.
posted by DarkForest at 5:08 AM on February 23 [2 favorites]


@darkforest - that looks cool, I've tried it, any idea how I'd refer to two already open VLC windows?!

@kschang - are you sure that's the case for XP? Because all I need to do at the mo is click anywhere once on the VLC window to bring it into focus? Maybe I'm misunderstanding. I DO know what you mean that you can't type into inactive window and expect the input to go 'in'

@samj - thanks - tried this but it just kept moaning "this line does not contain a recognised action" don't know why!

@TheAdamist & @Lanark - thanks - will investigate these!
posted by dance at 5:24 AM on February 23


Does your script already open the two VLC windows and are they the only windows open? Could you add a delay after that long enough to make sure they are both fully open, and then use (or call as a separate script):

Set objShell = CreateObject("Shell.Application")
objShell.TileVertically

This should tile all non-minimized windows. This was pretty much the only windows script I ever wrote, so I don't have good general knowledge about windows scripting.
posted by DarkForest at 5:42 AM on February 23


@lanark - thanks all, turns out, cmdow can, with a simple argument to the command tile all open windows. Job done! Thanks!
posted by dance at 6:41 AM on February 23 [1 favorite]


« Older Funny, light-hearted memoirs from outside the US   |   Deleted an entire text convo on iPhone, can I get... Newer »

You are not logged in, either login or create an account to post comments