Using mouse clicks as inputs for neuroscience experiment?

NeuroSpace

New Member
Joined
Jan 2, 2014
Messages
6
Hello everyone!

I'm a complete VBA noob and I'm looking for a way to use Excel macros to allow me to do a neuroscience experiment for my graduate course.

What I need is simple, but I don't know how to execute it or whether it is possible at all, so I was wondering if you guys could help me out.

For my experiment, subjects will be turning around in a special chair with their eyes closed, and will tell me when they think they moved a quarter turn. I thought it would be neat to have a way of recording their input with a wireless mouse attached to the spinning chair.
So basically what I need is a way for, say, left mouse clicks to consecutively input a timestamp in a column in Excel.

Does it make any sense to do this in Excel?

Please if you have any questions fire away!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
trapping the left mouse clicks is better but harder to code - A simpler solution is to trap the Right mouse clicks via the native Worksheet BeforeRightClick event

Something like along these lines maybe :

Right click the active worksheet tab , select View Code and place the following in the worksheet module white pane :

Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    Cells(Rows.Count, 1).End(xlUp).Offset(1) = Format(Now, "HH:MM:SS")
End Sub
 
Upvote 0
Mike, thank you for your feedback, I will look into your suggestion as a back up option.

trapping the left mouse clicks is better but harder to code - A simpler solution is to trap the Right mouse clicks via the native Worksheet BeforeRightClick event
[/CODE]

Jaafar, thank you very much, this gets the job pretty much done!

It has one tiny flaw though: a cell needs to be clicked in order for the event to occur. So if the pointer moves accidentally then I would loose a data point. To get around this, I thought of using software that allows mapping of keystroke combination to mouse clicks.

How could then the code be slightly modified so as to be activated by a specific keyboard combination (which would in turn be assigned to a mouse click)?

Thanks!
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,167
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top