Archive: LockedList.dll - auto next button


LockedList.dll - auto next button
Our tester requested that the next button be pressed automatically when no files are locked. Here is a code segment that does just that:

// Simulate Left Mouse Button Click of Next button
void simulateMouseClick(int x, int y, HWND hWnd) {
RECT windowRect;
GetWindowRect(hWnd,&windowRect);
MOUSEINPUT miDown = { windowRect.left + x, windowRect.top + y,
0, MOUSEEVENTF_LEFTDOWN, 0, 0 };
INPUT inDown;
inDown.type = INPUT_MOUSE;
inDown.mi = miDown;
MOUSEINPUT miUp = { windowRect.left + x, windowRect.top + y,
0, MOUSEEVENTF_LEFTUP, 0, 0 };
INPUT inUp;
inUp.type = INPUT_MOUSE;
inUp.mi = miUp;
INPUT inputs[2];
inputs[0] = inDown;
inputs[1] = inUp;
SendInput(2,inputs,sizeof inUp);
}

In the FilesThread procedure:
POINT pt; // cursor location
RECT rc; // client area coordinates
...
EnableWindow(g_hNext, TRUE);

// Put the cursor on the Next button
GetClientRect(g_hNext, &rc);
pt.x = rc.left + 5;
pt.y = rc.top + 5;
ClientToScreen(g_hNext, &pt);
SetCursorPos(pt.x, pt.y);
simulateMouseClick(5,5,g_hNext);


That's an awful lot of code. What's wrong with sending BM_CLICK?

I am working on LockedLists at the moment. I can add this feature if you wish.

Stu