Click background window programmatically
Posted: Sat Mar 02, 2019 10:44 am
Hi all, I want my app to click a button control on my Winamp window when I press a hotkey, to go to the next track. Let's ignore the fact that Winamp may have a hotkey to do this, because the end goal is to adapt the code to work with any background window. 
So, without bringing Winamp to the front, how can I simulate a mouse click on it, without bringing it to the foreground, and at a specific X/Y mouse position without moving the mouse so obviously to the user?
I found this StackOverflow link:
https://stackoverflow.com/questions/123 ... ck-message
And it appears that I can perhaps do it with these two lines of code:
But it doesn't work.
According to this post, it should:
viewtopic.php?p=465341#p465341
Alternatively, how can I convert the following to PureBasic (from that same link), which also appears to be what I want:
Thanks!

So, without bringing Winamp to the front, how can I simulate a mouse click on it, without bringing it to the foreground, and at a specific X/Y mouse position without moving the mouse so obviously to the user?
I found this StackOverflow link:
https://stackoverflow.com/questions/123 ... ck-message
And it appears that I can perhaps do it with these two lines of code:
Code: Select all
Macro MAKELPARAM(loWord,hiWord) : (hiWord << 16 | loWord) : EndMacro
SendMessage_(Winamp_hWnd,#WM_LBUTTONDOWN,#MK_LBUTTON,MAKELPARAM(x,y))

viewtopic.php?p=465341#p465341
Alternatively, how can I convert the following to PureBasic (from that same link), which also appears to be what I want:
Code: Select all
{
INPUT input;
input.type=INPUT_MOUSE;
input.mi.dx=0;
input.mi.dy=0;
input.mi.dwFlags=(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE|MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP);
input.mi.mouseData=0;
input.mi.dwExtraInfo=NULL;
input.mi.time=0;
SendInput(1,&input,sizeof(INPUT));
return 0;
}