Recent

Author Topic: move mouse pointer with keyboard  (Read 3819 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 258
move mouse pointer with keyboard
« on: February 17, 2013, 08:14:25 pm »
If I press 'key up' on keyboared, I want to, mouse pointer to move 1 px up.
How to do that ?

Next mouse up event should ofcourse have new coordinates.
lazarus 3.2-fpc-3.2.2-win32/win64

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: move mouse pointer with keyboard
« Reply #1 on: February 17, 2013, 08:32:58 pm »
Using MouseAndKeyInput package, something like:
Code: [Select]
uses ... , LCLType;
...
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if key=VK_UP then
    mouseinput.MoveBy([], 0, -1);
end;

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 258
Re: move mouse pointer with keyboard
« Reply #2 on: February 17, 2013, 10:03:34 pm »
Looks like this should work ....

Looked up the sample in lazarus source (where all runs & works OK), and made the same in my project:
Code: [Select]
...
implementation

uses
  MouseAndKeyInput, LCLType;

Have no idea why all that in implementation part. But anyway, putting that in first uses , result is the same:

Quote
unit1.pas(0,0) Fatal: Can not find unit MouseAndKeyInput used by Unit1.
and logicaly then:
unit1.pas(87,32) Error: Identifier not found "mouseinput"

Any idea how to solve that ?
« Last Edit: February 17, 2013, 10:05:51 pm by BubikolRamios »
lazarus 3.2-fpc-3.2.2-win32/win64

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: move mouse pointer with keyboard
« Reply #3 on: February 17, 2013, 10:08:05 pm »
Open from the Project menu -> Project Inspector dialog.
Add new requirement: lazmouseandkeyinput.

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 258
Re: move mouse pointer with keyboard
« Reply #4 on: February 17, 2013, 10:11:03 pm »
Heh, figured it out while you were writing answer.

Thanks !
lazarus 3.2-fpc-3.2.2-win32/win64

 

TinyPortal © 2005-2018