Reputation: 1427
How can I Programmatically double click on a system tray icon in Windows xp/7 and cause an app window to open ?
Upvotes: 1
Views: 1117
Reputation: 5675
You can't. Using Spy++ looks that "User Promoted Notification Area" offers no way to click a button and you have no control what icon is visibile.
Upvotes: 1
Reputation: 841
You could use http://msdn.microsoft.com/en-us/library/ms646310.aspx to send an input to the OS and double click on a specific position :
void MouseMove (double x, double y )
{
double fx = x*65535.0f;
double fy = y*65535.0f;
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = (long)fx;
Input.mi.dy = (long)fy;
::SendInput(1,&Input,sizeof(INPUT));
}
void lClick(){
INPUT Input={0};
// left down
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1,&Input,sizeof(INPUT));
::ZeroMemory(&Input,sizeof(INPUT));
// left up
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1,&Input,sizeof(INPUT));
}
and then call mousemove on the place where is the icon, and lClick twice. But this would implicate that the program task bar icon doesn't move... Depends on what the program is, and if you know the computer or not.
Upvotes: 0
Reputation: 1771
Is the Program you want to open your own App ? Then you can send messages to this process to force it to open.
This article may help you with sending messages between processes. send message to other process
Upvotes: 1