www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - mouse pointer

reply "Cassio Butrico" <cassio_butrico ig.com.br> writes:
can anyone tell me that how to change mouse pointer in D console. 
please tell me the code. I have tried many from the internet but 
that are not working well.
Jun 05 2015
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Saturday, 6 June 2015 at 00:00:07 UTC, Cassio Butrico wrote:
 I have tried many from the internet but that are not working 
 well.
Link to one.. I'm not sure what you mean and seeing one of the possible solutions will help.
Jun 05 2015
parent reply "Cassio Butrico" <cassio_butrico ig.com.br> writes:
On Saturday, 6 June 2015 at 02:04:44 UTC, Adam D. Ruppe wrote:
 On Saturday, 6 June 2015 at 00:00:07 UTC, Cassio Butrico wrote:
 I have tried many from the internet but that are not working 
 well.
Link to one.. I'm not sure what you mean and seeing one of the possible solutions will help.
in a console application can get the mouse position read if there was click etc .. but do not know if I can change the mouse pointer . Thanks for answering.
Jun 05 2015
next sibling parent "Cassio Butrico" <cassio_butrico ig.com.br> writes:
import std.stdio;
import core.sys.windows.windows;



int main(string[] args)
{
   HANDLE hIn;
     HANDLE hOut;
     auto  MouseWhere  = COORD (18, 0);
     auto DClickWhere  = COORD (18, 1);
	auto  clickwher   = COORD (18, 2);


     bool Continue = TRUE;
     DWORD EventCount;
     int LoopCount = 0;
     int KeyEvents = 0;
     INPUT_RECORD InRec;
     DWORD NumRead;

     hIn = GetStdHandle(STD_INPUT_HANDLE);
     hOut = GetStdHandle(STD_OUTPUT_HANDLE);

     writeln("Mouse is at     = ");
     writeln("Double Click at = ");
     write  ("Click at        = ");
	stdout.flush();


     while (Continue)
     {

         Sleep(10); // To slow it down!!

         GetNumberOfConsoleInputEvents(hIn,&EventCount);
         while (EventCount > 0)
         {
            ReadConsoleInputA(hIn,&InRec,1,&NumRead);

             if (InRec.EventType == KEY_EVENT)
             {
                 if (InRec.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
                 {
                             Continue = FALSE;
                 }
             }
             else if (InRec.EventType == MOUSE_EVENT)
             {
                  if (InRec.MouseEvent.dwEventFlags == MOUSE_MOVED)
                 {
                     SetConsoleCursorPosition(hOut, MouseWhere);
                     write(InRec.MouseEvent.dwMousePosition.X ," : 
");
                     write(InRec.MouseEvent.dwMousePosition.Y ,"   
");
					stdout.flush();
                 }
                 else if (InRec.MouseEvent.dwEventFlags == 
DOUBLE_CLICK)
                 {
                     SetConsoleCursorPosition(hOut, DClickWhere);
                     write(InRec.MouseEvent.dwMousePosition.X ," : 
");
                     write(InRec.MouseEvent.dwMousePosition.Y ,"   
");
					stdout.flush();
                 }
				else if(InRec.MouseEvent.dwButtonState & 
FROM_LEFT_1ST_BUTTON_PRESSED)
				{
					SetConsoleCursorPosition(hOut, clickwher);
                     write(InRec.MouseEvent.dwMousePosition.X ," : 
");
                     write(InRec.MouseEvent.dwMousePosition.Y ,"   
");
					stdout.flush();
				}
              }

           GetNumberOfConsoleInputEvents(hIn,&EventCount);
         }
     }
	
      return 0;
}
Jun 05 2015
prev sibling parent reply "Kagamin" <spam here.lot> writes:
On Saturday, 6 June 2015 at 02:45:55 UTC, Cassio Butrico wrote:
 in a console application can get the mouse position read if 
 there was click etc .. but do not know if I can change the 
 mouse pointer .
 Thanks for answering.
You mean you want to change the position of mouse pointer?
Jun 06 2015
parent reply "Cassio Butrico" <cassio_butrico ig.com.br> writes:
On Saturday, 6 June 2015 at 09:35:20 UTC, Kagamin wrote:
 On Saturday, 6 June 2015 at 02:45:55 UTC, Cassio Butrico wrote:
 in a console application can get the mouse position read if 
 there was click etc .. but do not know if I can change the 
 mouse pointer .
 Thanks for answering.
You mean you want to change the position of mouse pointer?
I actually wanted to change the mouse pointer , the arrow to hand, but do not know if it is possible .
Jun 06 2015
parent "Kagamin" <spam here.lot> writes:
SetCursor? 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms648393%28v=vs.85%29.aspx
Jun 07 2015