News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Mouse position?

Started by Bieb, May 31, 2005, 05:48:19 PM

Previous topic - Next topic

Bieb

Is there a way to find out what the mouse position is on the whole screen, not just a window.  It seems to me that the best way to go about getting "random" data would be to sit in the background and just take the mouse position every minute or so.  Frequently enough to generate data at a reasonable rate, but not frequently enough to have distinct patterns.  So, how exactly would I do it?


Eóin

Use a System-wide Hook on the mouse and among the info its returns is a POINT struct which holds the curser position.

If you're going to use this to generate random data then you should perform skew correction. Below is the method used by Random.org. You should check out that site also for further info and links.

Skew correction is performed on the bit stream, in order to ensure that there is an approximately even distribution of 0s and 1s.

The skew correction algorithm used is based on transition mapping. Bits are read two at a time, and if there is a transition between values (the bits are 01 or 10) one of them - say the first - is passed on as random. If there is no transition (the bits are 00 or 11), the bits are discarded and the next two are read. This simple algorithm was originally due to Von Neumann and completely eliminates any bias towards 0 or 1 in the data. It is only one of several ways of performing skew correction, though, and has a number of drawbacks. First, it takes an indeterminate number of input bits. Second, it is quite inefficient, resulting in the loss of 75% of the data, even when the bit stream is already unbiased.

Bieb

Thanks, y'all.  On a related note, how can I make a program have its window closed, but keep running in the background until its task is completed?

Eóin

Just don't call ExitProcess. But really you should minimise to the tray or something, that way user will know your app is still running in the background.

thomasantony

Hi,
   Another way to get somewhat random data is to run a random algo like the nrandom function in the MASM32.lib with the value taken from, RDTSC, GetTickCount or QueryPerformanceCounter as the seed.

Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free