Monitormaß-Abfrage klappt nicht wie gewünscht

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

Wick3d
Posts: 31
Joined: 04 Apr 2014, 03:24

Monitormaß-Abfrage klappt nicht wie gewünscht

31 May 2023, 05:56

Hi, ich benötige ein wenig Hilfe.

Ich möchte meinen Bildschirm in 3x2 gleich große Felder unterteilen. Wenn ich strg+alt+1 drücke, soll der Mauscursor in die Mitte vom Feld 1 springen.
Wenn ich nun die Tastenkombination auf dem Desktop drücke, funktioniert es wie erwartet. Wenn allerdings ein aktives Fenster im Vordergrund ist, werden die Felder anhand der Fensterposition berechnet, was ich aber nicht möchte.

Was mache ich falsch oder habe ich vergessen?

Hier mein Code:

Code: Select all

^!1::
    ; Bildschirmgröße abrufen
    SysGet, MonitorCount, MonitorCount
    SysGet, Monitor, Monitor, %MonitorCount%
    screenWidth := MonitorRight - MonitorLeft
    screenHeight := MonitorBottom - MonitorTop

    ; Feldgröße berechnen
    fieldWidth := screenWidth // 3
    fieldHeight := screenHeight // 2

    ; Feldmitte berechnen
    field1CenterX := MonitorLeft + fieldWidth // 2
    field1CenterY := MonitorTop + fieldHeight // 2

    ; Mauscursor positionieren
    MouseMove, field1CenterX, field1CenterY

    return
   
Ich danke für eure Hilfe.

Freundliche Grüße
Alex
just me
Posts: 9464
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Monitormaß-Abfrage klappt nicht wie gewünscht

31 May 2023, 06:39

Moin,

Code: Select all

^!1::
   CoordMode, Mouse, Screen
:arrow: CoordMode

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 113 guests