Computer Science Canada

More Advanced Mouse Procedures

Author:  Wolf_Destiny [ Fri Aug 11, 2006 10:34 am ]
Post subject:  More Advanced Mouse Procedures

With Turing 4.0.5 out, I haven't got it myself, but I was wondering if you can finally use their Mouse.SetPosition code with an actual working result. I've got 4.0.3 and it exports the procedure, but it doesn't work, and I can't do anything about that since it's an external procedure.

Either that, or if someone knows how to get the same result with Turing code, or even Java since I use that too, I'd appreciate it. Actually moving the mouse though not just:
code:
var x,y,btn : int
mousewhere (x,y,btn)
x := 100
y := 100
btn := 1


So, yes or no does it work, and is there equivelant code in Java or Turing?

Thanks for the help beforehand.

Author:  Cervantes [ Fri Aug 11, 2006 11:00 am ]
Post subject: 

You've got a Mouse.SetPosition in the predefs/Mouse.tu?

I'm on 4.0.5 and there's no such thing. Moving the mouse is not possible, in Turing, because that requires access to the Windows API. If we had that, students in classrooms could do things like, say, hide the mouse, to screw up the kid using the computer next period.

Author:  Wolf_Destiny [ Fri Aug 11, 2006 11:15 am ]
Post subject:  Mouse.tu

What I would really love to do actually, if figure out a way to mess with the signals that Windows is getting from the mouse, and make it think it's getting the ones I want. Ideally it'd be like a mouse macro, but controllable through code in a given language. It looked like HoltSoft was starting to do that, but by what you said they didn't. I'd love to see:
Mouse.SetState (x,y,btn:int)

Can you imagine the programs that could make? Of course, like you said it would allow for rather bothersome programs...

code:
loop
Mouse.SetState (1,1,0)
end loop


Without any output sent to the main run window, you'd never see it.

Anyways, here's the file, mouse.tu from Turing 4.0.3 note the export list, and the external procedure at the bottom.
code:
/*
** Mouse module - the simplified mouse interface
**
** NB:  DO NOT IMPORT OR INCLUDE THIS FILE INTO YOUR PROGRAM.
**      IT WILL BE IMPLICITLY IMPORTED.
*/

unit
module Mouse
    export Where, Hide, Show, ButtonMoved, ButtonWait, ButtonChoose,
           SetPosition

    external "mouse_where"
        procedure Where (var x, y, buttonUpDown: int)

    external "mouse_hide" procedure Hide

    external "mouse_show" procedure Show

    external "mouse_buttonmoved"
        function ButtonMoved (motionStr: string): boolean

    external "mouse_buttonwait"
        procedure ButtonWait (motionStr: string, var x, y: int,
                              var btnNumber, buttonUpDown: int)

    external "mouse_buttonchoose"
        procedure ButtonChoose (chooseStr: string)


    /* Experimental */

    external "mouse_setposition" procedure SetPosition (x, y: int)

end Mouse

Author:  [Gandalf] [ Fri Aug 11, 2006 3:14 pm ]
Post subject: 

Likely it's one of those things that they planned on doing in much earlier versions and then completely scrapped. It doesn't exist in Turing 4.1 either, and I wouldn't expect it from future versions. Like Cervantes said, that would require access to the Windows API, and it doesn't seem like that's on HoltSoft's priority list (if they even have one).

Author:  TokenHerbz [ Sat Aug 12, 2006 7:09 am ]
Post subject: 

How do you access the Windows API??

Author:  Cervantes [ Sat Aug 12, 2006 8:17 am ]
Post subject: 

Please TokenHerbz, read the thread. The point is that, in Turing, you can't.


: