Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Response Time Challenge


Matt
 Share

Recommended Posts

This website clocks response time. I myself average around at about 250ms. But who cares about a human's response time?
I present a challenge to you to make an application that takes the test. You can use any language you want. Post the **average** response times below!

http://www.humanbenchmark.com/tests/reactiontime

**Rankings**

1. Slasheree with 33ms average in VB.net
2. GalacticGlum with 34ms average in C#
3. Marsh with 47ms average in C++
4. Matt with 60ms average in C#
5. Matt with 60ms average in Python

My submission with a C# application.

>! ![](http://i.imgur.com/mVkcjmr.png)
Link to comment
Share on other sites

Yeah, I just tried writing a lil 2 minute app and I got hung up on conditional expressions and operators.. I've forgotten so much.. Lol. Took me at least 5 minutes to write something as simple as

if (bool != true)
bool = !bool;

Absolutely ridiculous. =/
Link to comment
Share on other sites

![](https://i.imgur.com/6f1VNR6.png)
Source if anyone wants it

```
#include int main()
{
COLORREF green = 7002955;
COLORREF lastColor = 0;

while (true)
{
POINT p;
if (GetCursorPos(&p))
{
HDC dc = GetDC(NULL);
COLORREF color = GetPixel(dc, p.x, p.y);

if (color == green && lastColor != color)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
}

lastColor = color;
ReleaseDC(NULL, dc);
}
}

return 0;
}

```
Link to comment
Share on other sites

![](http://puu.sh/mQ8xe/73417c1444.png)

```
using System;

using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ResponeTimeChallenge
{
    class Program
    {
        [DllImport("user32.dll")]
        static extern bool GetCursorPos(ref Point lpPoint);
        [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
        public static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

        private const int MouseLeftDown = 0x02;
        private const int MouseLeftUp = 0x04;

        static void Main(string[] args)
        {
            int count = 0;
            Color lastColour = new Color();
            while(count <= 4)
            {
                Point cursor = new Point();
                GetCursorPos(ref cursor);

                Color currentColor = GetColorAt(cursor);

                if (currentColor == Color.FromArgb(75, 219, 106) && lastColour != currentColor)
                {
                    count++;
                    Click(MouseLeftDown);
                }
                lastColour = currentColor;
                Click(MouseLeftUp);
            }
        }

        public static void Click(int mouseEvent)
        {
            mouse_event((uint)mouseEvent, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0);
        }

        public static Color GetColorAt(Point location)
        {
            Bitmap screenPixel = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
            using (Graphics gdest = Graphics.FromImage(screenPixel))
            {
                using (Graphics gsrc = Graphics.FromHwnd(IntPtr.Zero))
                {
                    IntPtr srcHDC = gsrc.GetHdc();
                    IntPtr destHDC = gdest.GetHdc();
                    int retValue = BitBlt(destHDC, 0, 0, 1, 1, srcHDC, location.X, location.Y, (int)CopyPixelOperation.SourceCopy);
                    gdest.ReleaseHdc();
                    gsrc.ReleaseHdc();
                }
            }
            return screenPixel.GetPixel(0, 0);
        }
    }
}

```
Link to comment
Share on other sites

Python submission

>! ![](http://i.imgur.com/PR7ElOE.png)

```
from ctypes import windll
import pyautogui

dc = windll.user32.GetDC(0)

while (True):
   color = windll.gdi32.GetPixel(dc, 400, 200)

   if (color == 7002955):
       pyautogui.click()

```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...