Introduction
This code uses the mouse's move and drag events to move Google map, then copy the map of the current-screen, finally merge them to a big one.
Background
When I have to go to another city, I always need the help of maps. Because my mobile cannot access the Web when I travel, I always collect the Google map, then merge it into one big map, and put it into my mobile. The code I discuss below does the task.
Using the Code
First, open Google Map, select a place you want to copy.
Second, move the mouse to the left-top point of the useful map, then stop for two seconds; the code will remember the left-top point.
Third, move the mouse to the right-bottom point of the useful map, then stop for two seconds; the code will remember the right-bottom point.
Fourth, select how big the map will be. The code will copy the map as shown in the following picture. The current screen will be centered.
Finally, click start.
The mouse move code looks like this:
[DllImport("user32.dll")]
static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern void mouse_event
(uint mouseEvent, int dx, int dy, uint data, int extrainfo);
SetCursorPos(x1, y1);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Thread.Sleep(500);
SetCursorPos(x2, y2);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
History
- 15th December, 2007: Initial version
- 21st December, 2007: Updated to delete Temp folder