PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Programm wo die Maus herunter bewegt



David1
11.01.2012, 15:21
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

Tarkoon
11.01.2012, 15:28
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.

Visceroid
11.01.2012, 15:30
Tastaturmaus in Windows einschalten und die Numblock Tasten verwenden?

-Sapphire-
11.01.2012, 15:34
Sowas geht normal mit autoit relativ einfach.

DerKleine49
11.01.2012, 15:47
@
Hast du kein Mausrad?

ryan_blackdrago
11.01.2012, 15:54
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:


#include <Misc.au3>
While 1
If _IsPressed("58") Then
Send("{DOWN}")
EndIf
WEnd

lynxx
11.01.2012, 16:37
...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#

Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 8);

David1
11.01.2012, 20:04
@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
11.01.2012, 22:23
8 Pixel

lynxx
11.01.2012, 22:48
8 Pixel
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


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.

David1
12.01.2012, 16:16
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?

voodoo44
12.01.2012, 17:52
Wie willst du denn 8.2 Pixel nach unten gehen?!

David1
12.01.2012, 18:30
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?

Darlis
12.01.2012, 19:17
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.

David1
12.01.2012, 20:36
Ok, danke.
Das obige Programm erfüllt aber seinen Zweck!
Danke für jede Hilfe :)

lynxx
12.01.2012, 22:07
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.

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);
}