Ok, I am so noob at programming, and should I actually lean LSS, that would be my first programming language
Well, I had Programming 101 at my college just to satisfy my degree requirement, so I can read this:
VOID SolveMinesweeperBoard() {
HWND hWnd = FindWindow( "Minesweeper" );
if ( !hWnd ) { return; }
// Put the Minesweeper board in front if possible.
ShowWindowAsync( hWnd, SW_SHOW );
SetForegroundWindow( hWnd );
// Get its position.
INT iX;
INT iY;
GetWindowPos( hWnd, &iX, &iY );
PrintF( "Minesweeper board located at %d %d.", iX, iY );
if ( iX < 0 || iY < 0 ) {
PrintF( "Minesweeper board is out of range!" );
return;
}
extern struct BOARDSIZE {
INT iWidth;
INT iHeight;
} e_bwSize = { "winmine.exe", 0x5334 }; // The width and height of the board.
extern BYTE e_pbBoard[32*32] = { "winmine.exe", 0x5361 }; // The board array itself.
// Note that 32*32 here is meaningless, except to show us how
// large the array is in the target process (it does not actually
// declare the array in the target process; it already exists).
POINT pClick;
// To calculate the final click positions we need the screen
// resolution.
INT iScreenW = GetPrimScreenWidth();
INT iScreenH = GetPrimScreenHeight();
// System settings change the location of mines on the board, so
// get the settings needed to know where to click.
INT iBorderHeight = GetSystemMetrics( SM_CYEDGE ); // Window border (height).
INT iCaptionHeight = GetSystemMetrics( SM_CYCAPTION ); // Title bar height.
INT iMenuHeight = GetSystemMetrics( SM_CYMENU ); // Menu height.
INT iFinalYOffset = iBorderHeight + iCaptionHeight + iMenuHeight;
INT iFinalXOffset = GetSystemMetrics( SM_CXEDGE ); // Window border (width).
// Save the externs to locals. This makes it faster to scan the
// board.
INT iBoardWidth = e_bwSize.iWidth;
INT iBoardHeight = e_bwSize.iHeight;
// Run through the board and click on each square that has no mine.
for ( INT J = 0; J < iBoardHeight; J++ ) {
for ( INT I = 0; I < iBoardWidth; I++ ) {
if ( (e_pbBoard[(32*J)+I] & 0x80) == 0 ) {
GetClickPos( iFinalXOffset, iFinalYOffset, iX, iY, &pClick, I, J );
// Translate the click position into the actual screen coordinates (Windows® forces us to do this).
pClick.x = pClick.x * 65535.0f / iScreenW;
pClick.y = pClick.y * 65535.0f / iScreenH;
// Move there.
MouseEvent( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
pClick.x, pClick.y,
0 );
// Click there (down and up).
MouseEvent( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN,
0, 0, // X and Y positions aren’t used.
0 );
MouseEvent( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP,
0, 0,
0 );
// Optionally sleep for a bit in case you like to see the action unfold.
//Sleep( 10 );
}
}
}
}
// Constants that tell us the dimensions of the board.
const INT iSquareSize = 16;
const INT iXOff = 14;
const INT iYOff = 56;
const INT iFinalX = iXOff + (iSquareSize / 2);
const INT iFinalY = iYOff + (iSquareSize / 2);
VOID GetClickPos( INT iScreenOffX, INT iScreenOffY, INT iPosX, INT iPosY, POINT * ppRet, INT iX, INT iY ) {
// The window is at (iPosX, iPosY). From there, go to the corner of the board
// and then offset based on which square we are hitting.
ppRet->x = iPosX + iX * iSquareSize + iFinalX + iScreenOffX;
ppRet->y = iPosY + iY * iSquareSize + iFinalY + iScreenOffY;
}
my question is, though, can I learn LSS without know C first?