Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hiding the Mouse on Start of Movie

Explorer ,
Jun 14, 2013 Jun 14, 2013

Hello All,

I have a flash program that runs on a PC that is connected to a TV. In case it helps at all, the PC is running OpenSuSE 12.1/KDE 4.

The PC is acting as a kiosk like device where no user is actually sitting at the PC doing stuff. If we ever need to do anything with it

we do it remotley using something like VNC or Remote Desktop or SSH, etc....

So what happens is when the PC is powered on it boots up and automatically logs in the default user. Then I set Firefox to start

automatically on boot and I set it's Homepage to the URL where the swf file lives (*which is located on another Server). Also, Firefox

automatically goes into Fullscreen mode mode using the Firefox Plugin "Full Fulscreen".

The issue is that, after the PC boots up and Firefox starts and the Flash movie begins playing, I can see the Mouse pointer sitting in the

middle of the screen which does NOT go away. So I found some code online that will hide the mouse after 'n' seconds. But the problem

is that when the Flash movie starts the mouse will NOT disappear after 'n' seconds. It is possible to get it to disappear, but in order to do

so I would have to tap the mouse so that it moves even the slightest, then after it stops moving it then disappears after 'n' seconds...

Since there really isn't any person who starts the movie manually, or since no one sitting in front of it with a mouse in their hand this won't

do what I wanted it to do....

Here is what I have so far in order to hide the mouse:

// Added this line after testing the code below. But still didn't hide the pointer when the movie was started

//Mouse.hide();                   // Hide the mouse automatically when started (*no time limit for this one)

var timeLimit:int = 3;         // Integer to hold what the Time Limit will be

// Add the EventListener for when the Mouse is moved:

stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);

// Create a Timer Object and multiply timeLimit by 1000 to get seconds:

var timer:Timer = new Timer(timeLimit * 1000);

// Add the EventListener for the Timer:

timer.addEventListener(TimerEvent.TIMER, onInactiveMouse);

// Function "onMove()":

//        *This will show the Mouse, stop the timer, then restart the timer...

function onMove(event:MouseEvent):void {

        trace("In onMove() --- Showing the Mouse Now...");

        Mouse.show();

        timer.stop();

        timer.start();

}


// Function "onInactiveMouse()":

//        *This will hide the Mouse when the TimeLimit has been reached...

function onInactiveMouse(event:TimerEvent):void {

        trace("In onInactiveMouse() --- Hiding the Mouse Now...");

        Mouse.hide();

}

So I guess my question is, is there a way to hide the mouse without a Human having to intervene and move the mouse pointer?

Also, I don't know if it was just some weird thing that happens, but say the movie is up and I move the mouse so it then disappears after n seconds.

Then the Frame changes and under where the mouse is hiding a TextField appears (*NOT an input TextField, just a Dynamic Text) suddenly the mouse

reappears, but it appears as the text selection pointer (*i.e. the one that looks like an Upper-Case "i"). And it won't disappear unless I move the pointer

again, Strange..!  I guess I could fix this by changing all my TextFields to be NOT selectable, but I was just curious if anyone else had experienced this?

Anyway, any thoughts/suggestions would be greatly appreciated!

Thanks in Advance,

Matt

TOPICS
ActionScript
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 14, 2013 Jun 14, 2013

The Flash player doesn't have focus until you "interact" with it (in your case moving the mouse), which is probably why Mouse.hide() won't work right away. I would recommend trying JavaScript to hide the mouse instead. This might be helpful: http://stackoverflow.com/questions/1361404/web-browser-hide-mouse-cursor

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 14, 2013 Jun 14, 2013

Hey Stenrap2, thanks for the reply!

Ohh Ok that explains alot.

I kinda figured it was something with the "focus", I just couldn't think of the words to describe it. I figured that was probably it because

I know if your watching flash within Firefox for example, and you click somewhere in the movie you can no longer use shortcuts for the

firefox window, like F11 to turn-on/off fullscreen, ctrl-tab to switch tabs, etc.... So I figured it was something to do with having to click into

the window and put the "focus" on that. Thanks for the clarification!

Ok, I'll check out the link you posted. So I guess you can embed JavaScript within your flash movie?

Thanks Again,

Matt

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 17, 2013 Jun 17, 2013

Ok, so I checked out that link and found a few good ideas for this.

Along with what you sent I found a few other ideas.

So I could try a few different things here:

  • Found some CSS Stylesheet code that works to hide the mouse (*it works I tested in an HTML page). But I would have to embed the Movie in an HTML page.
    • * { cursor: none; }
  • Also I found some other Linux Utilities that could also help me with this.
    • Command called xMacroPlay and xMacroRecord, which is used to programmatically simulate a mouse click or keyboard press.
    • Also, another command that is an extension of the Xserver but I can't remember what it was called at the moment...
  • A C/C++ program called clickMouse.cpp which also uses Xserver libraries like "xLib.h" and "Xutil.h":

Right now I am testing the last one in the list, the C/C++ clickMouse program, so I'll check back with my results...

Thanks Again for the suggestion,

Matt

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 18, 2013 Jun 18, 2013
LATEST

I decided which way I'm going to go with this and it seems to be doing the trick

I'm using this C/C++ program I found online, which I eneded up tweeking a little bit since it was a pretty old code so some things were

a bit out dated like the libraries, and a few other things. It uses the "X11" library in order to access elements of the screen including input

devices like the mouse and keyboard.

You simply execute the command on the CLI and pass it an X and Y Coordinate. Then once executed it will simply move the mouse to those

coordniates specified, and apparently emulate a Right-Click from the mouse. I'm not exactly sure if it will actually do the right-click, but for my

purposes just moving the mouse ever so slightly will be enough to bring the Flash Movie inside Firefox into focus.

I then created a simple Shell Script which will run on boot up and will sit in a loop checking if Firefox is running, if it is found running, then it waits

about 10 seconds or so, then executes the "clickMouse" program and moves the mouse to the specified coordinates. I tested it once or twice

and it seems to be doing the trick.

Here is the uncompilied code for the C program:

     *Once compilied you execute the program and pass it an X and Y Coordinate like this -->   "./clickMouse 1000 500"

#include <X11/Xlib.h>

#include<stdio.h>

#include<unistd.h>

#include <stdlib.h>

#include <string.h>

#include <unistd.h>

#include <X11/Xlib.h>

#include <X11/Xutil.h>

void mouseClick(int button)

{

    Display *display = XOpenDisplay(NULL);

    XEvent event;

   

    if(display == NULL)

    {

        fprintf(stderr, "Errore nell'apertura del Display !!!\n");

        exit(EXIT_FAILURE);

    }

   

    memset(&event, 0x00, sizeof(event));

   

    event.type = ButtonPress;

    event.xbutton.button = button;

    event.xbutton.same_screen = True;

   

    XQueryPointer(display, RootWindow(display, DefaultScreen(display)), &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);

   

    event.xbutton.subwindow = event.xbutton.window;

   

    while(event.xbutton.subwindow)

    {

        event.xbutton.window = event.xbutton.subwindow;

       

        XQueryPointer(display, event.xbutton.window, &event.xbutton.root, &event.xbutton.subwindow, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);

    }

   

    if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) fprintf(stderr, "Error\n");

   

    XFlush(display);

   

    usleep(100000);

   

    event.type = ButtonRelease;

    event.xbutton.state = 0x100;

   

    if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0) fprintf(stderr, "Error\n");

   

    XFlush(display);

   

    XCloseDisplay(display);

}

int main(int argc,char * argv[])

{

     int i=0;

     int x , y;

     x=atoi(argv[1]);

     y=atoi(argv[2]);

     Display *display = XOpenDisplay(0)

     Window root = DefaultRootWindow(display);

     XWarpPointer(display, None, root, 0, 0, 0, 0, x, y);

     mouseClick(Button1);

     XFlush(display);

     XCloseDisplay(display);

     return 0;

}

I'm not too proficient in C, a little bit more in C++, so I didn't realy change much from the original code except add a "main()" section to this one in order

to execute the "mouseClick()" function.

F.Y.I.

I kept the Actionscript code for the Mouse.hide() stuff, so this C program works with the Mouse.hide() code...

Thanks Again,

Matt

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines