Thema: Delphi Macro-Mausclick

Einzelnen Beitrag anzeigen

InZiDeR

Registriert seit: 2. Mai 2007
48 Beiträge
 
#4

Re: Macro-Mausclick

  Alt 21. Sep 2007, 20:36
Keysendung
Delphi-Quellcode:
Procedure PostKeyEx32( key: Word; Const shift: TShiftState;
                    specialkey: Boolean );
  Type
    TShiftKeyInfo = Record
                      shift: Byte;
                      vkey : Byte;
                    End;
    byteset = Set of 0..7;
  Const
    shiftkeys: Array [1..3] of TShiftKeyInfo =
      ((shift: Ord(ssCtrl); vkey: VK_CONTROL ),
      (shift: Ord(ssShift); vkey: VK_SHIFT ),
      (shift: Ord(ssAlt); vkey: VK_MENU ));
  Var
    flag: DWORD;
    bShift: ByteSet absolute shift;
    i: Integer;
  Begin
    For i := 1 To 3 Do Begin
      If shiftkeys[i].shift In bShift Then
        keybd_event( shiftkeys[i].vkey,
                    MapVirtualKey(shiftkeys[i].vkey, 0),
                    0, 0);
    End; { For }
    If specialkey Then
      flag := KEYEVENTF_EXTENDEDKEY
    Else
      flag := 0;

    keybd_event( key, MapvirtualKey( key, 0 ), flag, 0 );
    flag := flag or KEYEVENTF_KEYUP;
    keybd_event( key, MapvirtualKey( key, 0 ), flag, 0 );

    For i := 3 DownTo 1 Do Begin
      If shiftkeys[i].shift In bShift Then
        keybd_event( shiftkeys[i].vkey,
                    MapVirtualKey(shiftkeys[i].vkey, 0),
                    KEYEVENTF_KEYUP, 0);
    End; { For }
  End; { PostKeyEx32 }
Mausklick(bewegung?):
Delphi-Quellcode:
procedure MoveMouse (X,Y,Speed: Integer);
var
  wd, hh : integer;
  mm : TPoint;
begin
if Speed < 1 then Speed := 1;
wd := X;
hh := Y;

Repeat
   sleep(speed);
   Application.Processmessages;
   GetCursorPos(mm);
   with mm do
   begin
     If x > wd then
      dec(x)
     else
     If x < wd then
      inc(x);
     If y > hh then
      dec(y)
     else
     If y < hh then
      inc(y);
   end;
   SetCursorPos(mm.x,mm.y);
until (GetAsyncKeystate(Vk_Return) <> 0) or
       (GetAsyncKeystate(Vk_Escape) <> 0) or
       (GetAsyncKeystate(Vk_Space ) <> 0) or
       ((mm.X=X) and (mm.Y=Y));
end;

Bitteschön
Ich bin Anfänger in sachen Programmieren,aber ich steiger mich und steiger mich

Jeder der mir Hilfe anbieten kann soll dies tun ,ich wäre ihm sehr dankbar.
  Mit Zitat antworten Zitat