dword ist kein String, du musst den Wert davon gucken und den stattdessen eingeben
DLLs sind kompliziert...
-
- [ gelöst ]
-
veronesi -
27. Mai 2010 um 14:43 -
Geschlossen -
Erledigt
-
-
dword ist kein String, du musst den Wert davon gucken und den stattdessen eingeben
Ähhh, ok. Sorry. Das war noch falsch drinnen. Trotzdem liegt das Problem eine Zeile weiter unten.
Spoiler anzeigen
[autoit]Local $Struct, $StructData, $hScreen
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{ESC}","End")
[/autoit] [autoit][/autoit] [autoit]While Sleep(100)
[/autoit] [autoit][/autoit] [autoit]
$Struct = DllStructCreate("long;long")
DllStructSetData($Struct, 1, MouseGetPos(0))
DllStructSetData($Struct, 2, MouseGetPos(1))
$StructData = DllStructGetData(DllStructCreate("uint64", DllStructGetPtr($Struct)), 1)$hScreen = DllCall("User32.dll", "handle", "MonitorFromPoint", "uint64", $StructData, "dword", 0)
[/autoit] [autoit][/autoit] [autoit]
$test = DllCall("User32.dll", "ptr", "GetMonitorInfo", "handle", $hScreen)ToolTip($hScreen[0])
[/autoit] [autoit][/autoit] [autoit]
WEndFunc End()
[/autoit]
Exit
EndFunc ;==>EndDie Zeile 12 mit $test = DllCall..... funktioniert nicht, aber wie müsste der korrekt Aufruf lauten?
Danke!
-
GetMonitorInfo gibt einen Bool(-ean) zurück und braucht noch einen Pointer hinter dem Handleparameter, um die Infos zurückzugeben (LONG_PTR)
-
-
[autoit]
#include <Array.au3>
[/autoit][autoit][/autoit][autoit]
#include <Constants.au3>
#include <GDIConstants.au3>HotKeySet("{ESC}","End")
[/autoit][autoit][/autoit][autoit]While Sleep(100)
[/autoit][autoit][/autoit][autoit]
$Struct = DllStructCreate("long;long")
DllStructSetData($Struct, 1, MouseGetPos(0))
DllStructSetData($Struct, 2, MouseGetPos(1))
$StructData = DllStructGetData(DllStructCreate("uint64", DllStructGetPtr($Struct)), 1)$hScreen = DllCall("User32.dll", "handle", "MonitorFromPoint", "uint64", $StructData, "dword", 0)
[/autoit][autoit][/autoit][autoit]
; $hscreen = DllCall("User32.dll", "handle", "MonitorFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1), "dword", 0)
;_arraydisplay($hscreen)
$tagmonitorinfo=dllstructcreate("dword cbSize;long[4];long[4];dword dwFlags")
DllStructSetData($tagmonitorinfo,1,DllStructGetSize($tagMonitorinfo))
$test = DllCall("User32.dll", "boolean", "GetMonitorInfo", "hwnd", $hScreen[0],"ptr",DllStructGetPtr($tagMonitorinfo))
;_arraydisplay($test)
;~ consolewrite(DllStructGetData($tagMonitorinfo,1,1)&@crlf) ;cbSitze
;~ for $i=1 to 4 ;rcMonitor
;~ consolewrite(DllStructGetData($tagMonitorinfo,2,$i)&@crlf)
;~ next
;~ for $i=1 to 4 ;rcWork
;~ consolewrite(DllStructGetData($tagMonitorinfo,3,$i)&@crlf)
;~ next
;~ consolewrite(DllStructGetData($tagMonitorinfo,4,1)&@crlf) ;dwFlags sollte die nummer des zzt aktiven monitors seinToolTip($hScreen[0]&" "&DllStructGetData($tagMonitorinfo,4,1))
[/autoit][autoit][/autoit][autoit]
WEndFunc End()
[/autoit]
Exit
EndFunc ;==>End/edit/ dwflags sind die Attribute des zzt aktiven Monitors, s. meinen Link einen Post drüber
-
Vielen Dank!
Ich habe das Skript mal etwas angepasst, damit ich das auch etwas besser verstehe!
Spoiler anzeigen
[autoit]Local $Struct, $StructData, $hScreen, $ptrInfo, $TagMonitorInfo
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{ESC}","End")
[/autoit] [autoit][/autoit] [autoit]While Sleep(100)
[/autoit] [autoit][/autoit] [autoit]
$Struct = DllStructCreate("long;long") ;Create struct
DllStructSetData($Struct, 1, MouseGetPos(0)) ;Insert actual mouse pointer position
DllStructSetData($Struct, 2, MouseGetPos(1))
$StructData = DllStructGetData($Struct, 1) ;Get struct data
$hScreen = DllCall("User32.dll", "handle", "MonitorFromPoint", "uint64", $StructData, "dword", 0) ;Get handle of screen on which the mouse cursor is$TagMonitorInfo = DllStructCreate("dword cbSize;long[4];long[4];dword dwFlags")
[/autoit] [autoit][/autoit] [autoit]
DllStructSetData($tagmonitorinfo, 1, DllStructGetSize($TagMonitorInfo))
DllCall("User32.dll", "boolean", "GetMonitorInfo", "hwnd", $hScreen[0], "ptr", DllStructGetPtr($TagMonitorInfo))ToolTip("rcMonitor: " & DllStructGetData($TagMonitorInfo,2,1))
[/autoit] [autoit][/autoit] [autoit]
WEndFunc End()
[/autoit]
Exit
EndFunc ;==>EndBin ich mit der Maus auf dem Bildschirm 2, sehe ich im ToolTip die X-Auflösung des Monitor 1!
Gehe ich mit der Maus auf Bildschirm 1, sehe ich als X-Auflösung 0!Wenn ich $TagMonitorInfo,4,1 verwende, dann lautet die Zahl auf Screen 2 = 0 und auf Screen 1 = 1.
Aber eigentlich möchte ich ja auf Screen 2 = 2 und auf Screen 1 = 1!
Oder noch besser: die Funktion, welche ich in einem Post am Anfang geschickt habe (_GetMonitorInfo()) sollte zu den zugehörigen Positionen und Koordinaten der Bildschirme auch die richtige Bildschirmnummer ausgeben!
Spoiler anzeigen
[autoit]#include-once
[/autoit] [autoit][/autoit] [autoit]Func _GetMonitorInfo()
[/autoit] [autoit][/autoit] [autoit]
;Returns some informations about your screens
;Call: _GetMonitorInfo()
;Return: Array With
;[0][0] Nr of Monitors
;[1][0] X Resolution of Monitor x
;[1][1] Y Resolution of Monitor x
;[1][2] X Position of Monitor x
;[1][3] Y Position of Monitor x;[2][0] X Resolution of Monitor y
[/autoit] [autoit][/autoit] [autoit]
;[2][1] Y Resolution of Monitor y
;[2][2] X Position of Monitor y
;[2][3] Y Position of Monitor y
;......Local $NrOfMonitors, $ResolutionX[32], $ResolutionY[32], $PositionX[32], $PositionY[32], $Ret
[/autoit] [autoit][/autoit] [autoit]
Local $cbMonitorEnumProc = DllCallbackRegister("MonitorEnumProc", "ubyte", "ptr;ptr;ptr;int")If @error Then Return SetError(1, 0, False)
[/autoit] [autoit][/autoit] [autoit]
Local $strctCount = DllStructCreate("uint Count;uint Width[12];uint Height[12];int left[12];int top[12]")
If @error Then Return SetError(2, @error, False)
Local $iCountDllStructSetData($strctCount, "Count", 0)
[/autoit] [autoit][/autoit] [autoit]$Ret = DllCall("User32.dll", "ubyte","EnumDisplayMonitors","ptr", 0,"ptr", 0, "ptr", DllCallbackGetPtr($cbMonitorEnumProc), "ptr", DllStructGetPtr($strctCount))
[/autoit] [autoit][/autoit] [autoit]
If @error Or $Ret[0] = 0 Then Return SetError(3, @error, False)DllCallbackFree($cbMonitorEnumProc)
[/autoit] [autoit][/autoit] [autoit]$iCount = Int(DllStructGetData($strctCount, "Count"))
[/autoit] [autoit][/autoit] [autoit]Local $aMonitors[$iCount+1][4] = [[$iCount]]
[/autoit] [autoit][/autoit] [autoit]For $i = 1 To $iCount
[/autoit] [autoit][/autoit] [autoit]
$aMonitors[$i][0] = Int(DllStructGetData($strctCount, "Width",$i))
$aMonitors[$i][1] = Int(DllStructGetData($strctCount, "Height",$i))
$aMonitors[$i][2] = Int(DllStructGetData($strctCount, "left",$i))
$aMonitors[$i][3] = Int(DllStructGetData($strctCount, "top",$i))
Next$strctCount = 0
[/autoit] [autoit][/autoit] [autoit]
Return $aMonitors
EndFuncFunc MonitorEnumProc($hMonitor, $hdcMonitor, $lprcMonitor, $dwData)
[/autoit] [autoit][/autoit] [autoit]
Local $strctRECT = DllStructCreate("long left;long top;long right;long bottom", $lprcMonitor)
Local $strctCount = DllStructCreate("uint Count;uint Width[12];uint Height[12];int left[12];int top[12]", $dwData)
Local $iNumber = DllStructGetData($strctCount, "Count")
Local $Height = Int(DllStructGetData($strctRECT, "bottom"))-Int(DllStructGetData($strctRECT, "top"))
Local $Width = Int(DllStructGetData($strctRECT, "right"))-Int(DllStructGetData($strctRECT, "left"))DllStructSetData($strctCount, "Width", $Width, $iNumber+1)
[/autoit]
DllStructSetData($strctCount, "Height", $Height, $iNumber+1)
DllStructSetData($strctCount, "left", Int(DllStructGetData($strctRECT, "left")), $iNumber+1)
DllStructSetData($strctCount, "top", Int(DllStructGetData($strctRECT, "top")), $iNumber+1)
DllStructSetData($strctCount, "Count", $iNumber+1)
Return True
EndFuncIst das möglich?
-
So, ich habe natürlich beim übersetzen einen kleinen Fehler gemacht!
Mit diesem Script kann ich erfolgreich die X und Y Position des Bildschirms bestimmen, auf welchem die Maus ist!
Vielen Dank an Alle!Spoiler anzeigen
[autoit]Local $Struct, $StructData, $hScreen, $ptrInfo, $TagMonitorInfo
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{ESC}","End")
[/autoit] [autoit][/autoit] [autoit]While Sleep(100)
[/autoit] [autoit][/autoit] [autoit]
$Struct = DllStructCreate("long;long") ;Create struct
DllStructSetData($Struct, 1, MouseGetPos(0)) ;Insert actual mouse pointer position
DllStructSetData($Struct, 2, MouseGetPos(1))
$StructData = DllStructGetData(DllStructCreate("uint64", DllStructGetPtr($Struct)), 1) ;Get struct data
$hScreen = DllCall("User32.dll", "handle", "MonitorFromPoint", "uint64", $StructData, "dword", 0) ;Get handle of screen on which the mouse cursor is$TagMonitorInfo = DllStructCreate("dword cbSize;long[4];long[4];dword dwFlags")
[/autoit] [autoit][/autoit] [autoit]
DllStructSetData($tagmonitorinfo, 1, DllStructGetSize($TagMonitorInfo))
DllCall("User32.dll", "boolean", "GetMonitorInfo", "hwnd", $hScreen[0], "ptr", DllStructGetPtr($TagMonitorInfo))ToolTip("X-Pos: " & DllStructGetData($TagMonitorInfo,2,1) & @LF & "Y-Pos: " & DllStructGetData($TagMonitorInfo,2,2))
[/autoit] [autoit][/autoit] [autoit]
WEndFunc End()
[/autoit]
Exit
EndFunc ;==>End -
Der Vollständigkeit halber hier noch ein korrigierter Fehler:
Zeile 16 und 17 von meiner Funktion TileWindows() enthielten einen Fehler!
Diese Funktion fragt den Bildschirm ab, auf welchem die Maus ist. Da ich aber immer einen falschen Bildschirm zurückbekam, dachte ich, dass deshalb die TileWindows() Funktion manchmal nicht funktioniere! Doch der Fehler lag an diesen beiden Zeilen!Somit ist alles in Ordnung!
Vielen Dank!
Korrigierte TileWindows()
Spoiler anzeigen
[autoit]#include-once
[/autoit] [autoit][/autoit] [autoit]
#include "Func_GetMonitorInfo.au3"
#include "Func_GetMouseInfo.au3"Func _TileWindows()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
;Tile Windows on that screen where the mouse is!
;Call: _TileWindows()Local $MonNr, $Left, $Top, $Right, $Bottom, $tStruct, $Rect, $aTmp[32][32]
[/autoit] [autoit][/autoit] [autoit]
$MonNr = _GetMouseInfo()
$aTmp = _GetMonitorInfo()$Left = $aTmp[$MonNr][2]
[/autoit] [autoit][/autoit] [autoit]
$Top = $aTmp[$MonNr][3]
$Right = $aTmp[$MonNr][0] + $Left
$Bottom = $aTmp[$MonNr][1] + $Top$tStruct = DllStructCreate("int[4]") ;4 points of values that are integers
[/autoit] [autoit][/autoit] [autoit]
DllStructSetData($tStruct, 1, $Left, 1)
DllStructSetData($tStruct, 1, $Top, 2)
DllStructSetData($tStruct, 1, $Right, 3)
DllStructSetData($tStruct, 1, $Bottom, 4)
$Rect = DllStructGetPtr($tStruct) ;Now $rect holds our left/top/right/bottom values in a type of array basicallyDllCall("user32.dll", "int", "TileWindows", "int", 0, "int", 0, "Ptr", $Rect, "int", 0, "int", 0)
[/autoit]
EndFunc -