Alternate 5

Programm wo die Maus herunter bewegt

David1

Ensign
Registriert
Okt. 2011
Beiträge
193
Hi
ich suche ein Programm, welches den Mauszeiger immer um ein bestimmten Abstand nach unten beweget, sobal ich eine Taste drücke.
Quasi beim drücken von x eine halbe Zeile im Browser runter geht.
Vielleicht könnte das auch einer schreiben, ich denke das wird nicht soviel Schreibarbeit sein.
Da kenn ich mich aber nicht aus...

Schonmal Danke im Voraus.

David
 
NirCMD
Und das das einfach mit irgendeiner StandardSoftware auf ne Taste belegen...
...oder noch einfacher als Verknüpfung speichern und über Windows per Tastenkombination starten.
 
Zuletzt bearbeitet:
Tastaturmaus in Windows einschalten und die Numblock Tasten verwenden?
 
@
Hast du kein Mausrad?
 
-Sapphire- schrieb:
Sowas geht normal mit autoit relativ einfach.
Wenn man's kann schon klar. Wenn man's kann, kann man gleich seine eigene Windows-API basteln. Für denjenigen ist es einfach... :freak:

Via AutoIT-Skript. Durch das Drücken der x-Taste wird die Cursor-Taste UNTEN gedrückt:
Code:
#include <Misc.au3>
While 1
      If _IsPressed("58") Then
      Send("{DOWN}")
    EndIf
WEnd
 
Zuletzt bearbeitet:
David1 schrieb:
...welches den Mauszeiger immer um ein bestimmten Abstand nach unten beweget, sobal ich eine Taste drücke.
Quasi beim drücken von x eine halbe Zeile im Browser runter geht.

In C#
Code:
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 8);
 
@lynx.
Wenn ich jetzt mit Visual Studio damit ein Programm erstelle, dann verschiebt es bei jedem Start den Zeiger quasi nach unten.
Der Wert "8" steht dann für? 8 Zeilen? Oder was für ein Wert ist das?
Könnte ich da auch Kommazahlen einsetzen?

ps. Es ist im Grunde egal, ob Zeiger oder Seite im Browser, ich sollte nur den Abstand sehr präzise einstellen können...
 
Koksii schrieb:
Korrekt, damit man den Tastendruck immer mitkriegt muss man aber noch einen Hook installieren, hier das vollständige Programm das beim drücken von X die Maus 8 Pixel (halbe Zeile, kommt aber auf die Fontgröße des Browsers an) nach unten bewegt.

Have phun. :D

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

class MoveMouseDown {
  private const int WM_KEYDOWN = 0x0100;
  private const int WM_SYSKEYDOWN = 0x0104;
  private static LowLevelKeyboardProc _procKeyboard = HookCallbackKeyboard;
  private static IntPtr _hookIDKeyboard = IntPtr.Zero;

  public static void Main() {
    _hookIDKeyboard = SetHook(13, _procKeyboard); // WH_KEYBOARD_LL Hook installieren
    Application.Run();
    if (_hookIDKeyboard != IntPtr.Zero) UnhookWindowsHookEx(_hookIDKeyboard);
  }

  private static IntPtr SetHook(int idHook, Delegate proc) {
    using (Process curProcess = Process.GetCurrentProcess())
      using (ProcessModule curModule = curProcess.MainModule)
        return SetWindowsHookEx(idHook, proc, GetModuleHandle(curModule.ModuleName), 0);
  }

  private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);

  private static IntPtr HookCallbackKeyboard(int nCode, IntPtr wParam, IntPtr lParam) {
    if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN)) {
      Keys vkCode = (Keys)Marshal.ReadInt32(lParam);

      // Wenn x gedrückt 8 Pixel runtergehen
      if (vkCode == Keys.X)
        Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 8);
    }
    return CallNextHookEx(_hookIDKeyboard, nCode, wParam, lParam);
  }

  [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  private static extern IntPtr SetWindowsHookEx(int idHook, Delegate lpfn, IntPtr hMod, uint dwThreadId);

  [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  [return: MarshalAs(UnmanagedType.Bool)]
  private static extern bool UnhookWindowsHookEx(IntPtr hhk);

  [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);

  [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  private static extern IntPtr GetModuleHandle(string lpModuleName);
}

Hab die fertige Exe als Attachment hinzugefügt.
 

Anhänge

Genau sowas. Schonmal danke dafür :)
Der Wert passt schon ziemlich gut, wenn er 8,2 oder 8,3 wäre das perfekt.
Das wird aber nicht möglich sein oder?
 
Das sind doch nicht die Pixel vom Bildschirm? :freak:
Das wäre doch dann bei unterschiedlichen Auflösungen auch eine andere Entfernung, oder täusche ich mich?
 
Nein. Die Schrift hat bei gleichem Browser immer die gleiche Pixelhöhe. Wenn du die Auflösung auf 800x600 einstellt hast du zwar optisch eine sehr große Schrift, aber in Pixeln ist die Größe immer noch gleich.
 
Ok, danke.
Das obige Programm erfüllt aber seinen Zweck!
Danke für jede Hilfe :)
 
8.2 Pixel "geht nicht", zumindest nicht direkt über die Funktion, da sie nur Ganzzahlen unterstützt, aber hier eine Variante die "8.2 Pixel" nach unten geht, nach jedem vierten mal 8 Pixel runter geht sie 9 Pixel runter. ((4x8 + 9) / 5 = 8.2 Pixel)
Programm kann durch Ctrl+Escape beendet werden.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

class MoveMouseDown {
  private const int WM_KEYDOWN = 0x0100;
  private const int WM_SYSKEYDOWN = 0x0104;
  private static LowLevelKeyboardProc _procKeyboard = HookCallbackKeyboard;
  private static IntPtr _hookIDKeyboard = IntPtr.Zero;
  private static float pixeldown = 0;

  public static void Main() {
    _hookIDKeyboard = SetHook(13, _procKeyboard); // WH_KEYBOARD_LL Hook installieren
    Application.Run();
    if (_hookIDKeyboard != IntPtr.Zero) UnhookWindowsHookEx(_hookIDKeyboard);
  }

  private static IntPtr SetHook(int idHook, Delegate proc) {
    using (Process curProcess = Process.GetCurrentProcess())
      using (ProcessModule curModule = curProcess.MainModule)
        return SetWindowsHookEx(idHook, proc, GetModuleHandle(curModule.ModuleName), 0);
  }

  private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);

  private static IntPtr HookCallbackKeyboard(int nCode, IntPtr wParam, IntPtr lParam) {
    if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN)) {
      Keys vkCode = (Keys)Marshal.ReadInt32(lParam);

      // Wenn x gedrückt 8.2 Pixel runtergehen (4x 8 Pixel, dann 9 Pixel ..)
      if (vkCode == Keys.X) {
        pixeldown += 8.2f;
        int pixelsmoved = (int)pixeldown;
        pixeldown -= pixelsmoved;
        Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + pixelsmoved);
      }
      else if (vkCode == Keys.Escape) { // Ctrl+Escape = Exit Programm
        if (GetKeyState((int)Keys.ControlKey) != 1) {
          Application.Exit();
        };
      }
    }
    return CallNextHookEx(_hookIDKeyboard, nCode, wParam, lParam);
  }

  [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  private static extern IntPtr SetWindowsHookEx(int idHook, Delegate lpfn, IntPtr hMod, uint dwThreadId);

  [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  [return: MarshalAs(UnmanagedType.Bool)]
  private static extern bool UnhookWindowsHookEx(IntPtr hhk);

  [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);

  [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  private static extern IntPtr GetModuleHandle(string lpModuleName);

  [DllImport("user32.dll", EntryPoint = "GetKeyState", SetLastError = true)]
  public static extern int GetKeyState(int nVirtKey);
}
 

Anhänge

Zurück
Oben