Mouse.GetCursorPos thePoint
I'm attempting to collect/track mouse position on a particular image on a slide. I want the position to be collected often, every 200ms or so, but NOT contingent upon a click: just continuously tracked coordinates as the participant moves the mouse cursor. I'm using the following in-line code before my slide named "Test:"
Dim thePoint As Point
Mouse.ShowCursor True
While Clock.ReadMillisec < Test.OnsetTime + Test.Duration
Mouse.GetCursorPos thePoint
Debug.Print "Mouse is at location: " & thePoint.x & " " & thePoint.y
sleep 200
Wend
The code is designed to print the coordinates in the "debug" tab, but I can't get that to work: they're not being printed anywhere. I'd prefer it in the .edat output files or a .txt file, but can't seem to get any modifications to print the position.
Can anyone tell me what I'm missing?
Thanks,
----------------------------------------------------------------
Catering Jakarta
Catering Sushi
Catering Gubukan Jakarta
Menu Gubukan Pernikahan
-
Hello Olive,
Great question! Without seeing the rest of your experiment, it's a little difficult to properly diagnose this issue, but I have a few ideas that should help you out with this problem.
First, I recommend checking out PST's sample. It sounds like it does exactly what you want to without having to reinvent the wheel. Check it out here: https://support.pstnet.com/hc/en-us/articles/115001909088-Track-Mouse-Coordinates-30090-.
To answer your question more directly though, if absolutely nothing is printing to the debug.print screen, it sounds like E-Prime isn't even getting into your While...Wend statement. In general, While...Wend statements have been replaced by Do While or Do...Loop Until Loops. I recommend replacing those. While there's nothing functionally wrong with a While...Wend loop, the Do loops just work a little cleaner in my opinion.
Next, let's talk about the conditions stopping it from getting into the While...Wend statement. You have one very important statement there: Clock.ReadMillisec < Test.OnsetTime + Test.Duration. My bet is that one of those three numbers isn't printing what you're expecting. I recommend putting the following script just before your While....Wend Statement:
Debug.Print "Current time: " & Clock.ReadMIlisec
Debug.Print "OnsetTime: " & Test.OnsetTime
Debug.Print "TestDuration: " & Test.Duration
My guess is that one of these three (probably your "Test." statements are returning values that you're not expecting, causing E-Prime to completely skip over your While...Wend statement. I then recommend keeping those Debug.Print statements in your experiment until the program is working exactly how you want it to. These are going to be useful tools for testing any more assumptions that your script is making.
If you would like more help with this or any experiment, I do offer consulting services for E-Prime as well. You can check out my site here: https://www.theprimeguyconsulting.com/
Sincerely,
Devon "The Prime Guy" Struthers
Experiment Design Consultant
Please sign in to leave a comment.
Comments
1 comment