Ich versuche die x,y-Koordinaten des Clientbereiches(Fenster ohne Titel, Status, Rahmen). eines Fenster zu bekommen, da diese Funktion (WinGetClientSize ( "title" [, "text"] )) nur die Breite und Höhe zurückgibt. Kennt jemand eine Lösung?
Client Position eines Fensters!
-
- [ gelöst ]
-
Faweyr -
2. Mai 2010 um 09:34 -
Geschlossen -
Erledigt
-
-
- Offizieller Beitrag
Die Lösung kann man doch schnell selbst schreiben:
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <Array.au3>
$hGui = GUICreate('test', 577, 499, 600, 200)
GUISetState()
$aClient = _WinGetClientPos($hGui)
_ArrayDisplay($aClient)Func _WinGetClientPos($hTitle, $hText = '')
[/autoit]
Local $aWPos, $aCSize, $iBorder, $iTitle
$aWPos = WinGetPos($hTitle, $hText)
$aCSize = WinGetClientSize($hTitle, $hText)
$iBorder = ($aWPos[2] - $aCSize[0]) / 2
$iTitle = ($aWPos[3] - $aCSize[1]) - $iBorder
Local $aOut[4] = [$aWPos[0] + $iBorder, $aWPos[1] + $iTitle, $aCSize[0], $aCSize[1]]
Return $aOut
EndFunc -
meinst du so?
Spoiler anzeigen
[autoit]#include <WindowsConstants.au3>
[/autoit]
$hWnd = GUICreate("Test Wnd", 100, 20, -1, -1, -$WS_POPUP, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$hButton = GUICtrlCreateButton("Koordinaten", 0, 0, 100, 20)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $hButton
$aWPos = WinGetPos($hWnd)
MsgBox(64, "Info", "X "&$aWPos[0]&@CRLF&"Y "&$aWPos[1])
Case -3
Exit
EndSwitch
WEnd -
- Offizieller Beitrag
Nein, er will eben nicht die Position des Fenster, sondern des Clientbereichs (ohne Rahmen, etc.).
-
Oscar : Jub, das wusste ich schon, jedoch weiß ich nicht ob bei allen Designs der untere Rand genauso hoch ist wie die Breite der linke/rechten Randes!
-
- Offizieller Beitrag
Ich weiß ja nicht, was Du vorhast, aber vielleicht reicht Dir ja auch WinGetCaretPos.
-
Alternativer Vorschlag:
Linker oberer Rand vom Client bezüglich der Bildschirmkoordinaten sollte sein:- BlockInput damit die Maus stabil bleibt
- Unterschied = MouseGetPos bei Opt("MouseCoordMode", 0) - MouseGetPos bei Opt("MouseCoordMode", 2)
- Linker ober Rand des Clients absolut = WinGetPos() + Unterschied
Größe dann wie gehabt über WinGetClientSize
-
mhm...Ja ok...das muss woll reichen...dachte nur, vielleicht gibs noch eine "bessere" Lösung...
Danke...
Wenn jemand noch was einfällt dann einfach schreiben -
Ich habe gerade diesen Befehl hier entdeckt:
Spoiler anzeigen
[autoit]$tRect = _WinAPI_GetClientRect($hWnd)
[/autoit] [autoit][/autoit] [autoit]$iLeft = DllStructGetData($tRect, "Left")
[/autoit]
$iTop = DllStructGetData($tRect, "Top")
$iRight = DllStructGetData($tRect, "Right")
$iBottom = DllStructGetData($tRect, "Bottom")
Vielleicht hilft er dir ja weiter. -
super...danke
-
Sooo....nun brauchte ich entlich die Funktion und musste feststellen, das sie nicht richtig arbeitet, da sie nur die Breite und Höhe wieder ausgibt.
-
Sie gibt auch X und Y zurück aber auch nur relativ zum Fenster, du müsstest WinGetPos und _WinAPI_GetClientRect kobinieren.
-
Nun, jedoch kommt bei mir als X und Y Punkt immer 0 raus. Damit kann ich relativ wenig anfangen
[autoit]
[/autoit][autoit][/autoit][autoit][/autoit][autoit]
#include$hWnd = GuiCreate("",200,100,10,10)
[/autoit][autoit][/autoit][autoit]$tRect = _WinAPI_GetClientRect($hWnd)
[/autoit][autoit][/autoit][autoit]$iLeft = DllStructGetData($tRect, "Left")
[/autoit][autoit][/autoit][autoit]
$iTop = DllStructGetData($tRect, "Top")
$iRight = DllStructGetData($tRect, "Right")
$iBottom = DllStructGetData($tRect, "Bottom")ConsoleWrite($iLeft & @lf & $iTop & @lf & $iRight & @lf & $iBottom)
[/autoit] -
Die X/Y Position relativ zur GUI ist fast immer 0 ;).
Ich hab ja gesagt du musst das irgendwie mit WinGetPos kombinieren...
Oder willst du die Position des Clients mit einem Koordinatensystem das den Ursprung in der linken oberen Ecke der Titelleiste hat? Dann musst du wohl schummeln und zu WinGetPos einen festen Wert dazuzählen bzw. abziehen. -
Also ich möchte den die X,Y-Position des Clients eines Fensters (siehe Bild Anhang). Der "feste Wert" kann ja bei verschiedenen Windows Designs varieren...womit wir wieder am Anfang sind.
-
Zitat
womit wir wieder am Anfang sind.
Stimmt leider. Und ich bin mit meinem Latein am Ende .
Jetzt hilft nur noch Google... -
Ja, auch im englischen Forum ist nichts zu finden...zumindest auf meiner Suchart!
-
Hi,
also entweder steh ich jetzt auf der Leitung oder Ihr habt die Lösung eigentlich schon genannt.
Also ich hab mal aus zwei Beispielen ein weiteres zusammengebaut:
Spoiler anzeigen
[autoit]#include<GuiStatusBar.au3>
[/autoit] [autoit][/autoit] [autoit]
#include<GUIConstantsEx.au3>
Opt('CaretCoordMode', 0)
Opt('GUIOnEventMode', 1)
$hGUI = GUICreate('test', 400, 400, -1, -1)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, '_Move')
GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
Global $aParts[1] = [-1]
$hStatus = _GUICtrlStatusBar_Create ($hGUI)
_GUICtrlStatusBar_SetParts ($hStatus, $aParts)
GUISetState()$aCords = _GetClientRect ($hGUI)
[/autoit] [autoit][/autoit] [autoit]
_Move()While True
[/autoit] [autoit][/autoit] [autoit]
Sleep(100)
WEndFunc _End()
[/autoit] [autoit][/autoit] [autoit]
Exit
EndFuncFunc _Move()
[/autoit] [autoit][/autoit] [autoit]
$posWin = WinGetPos('test')
$pos = WinGetCaretPos()_GUICtrlStatusBar_SetText($hStatus, 'Position X:' & $posWin[0] & '+' & $pos[0] & ' Y: ' & $posWin[1] & '+' & $pos[1] &' width:' & $aCords[2] & ' height:' & $aCords[3])
[/autoit] [autoit][/autoit] [autoit]
EndFuncFunc _GetClientRect ($hWnd)
[/autoit] [autoit][/autoit] [autoit]Local $aRes, $stRECT, $lpRect, $aRect[4]
[/autoit] [autoit][/autoit] [autoit]
$stRECT = DllStructCreate ('long left; long top; long right; long bottom;')
$lpRect = DllStructGetPtr ($stRECT)
Local $aRes = DllCall ('user32.dll', 'int', 'GetClientRect', _
'hwnd', $hWnd, _
'ptr', $lpRect)
If $aRes[0] <> 0 Then
$aRect[0] = DllStructGetData ($stRECT, 'left')
$aRect[1] = DllStructGetData ($stRECT, 'top')
$aRect[2] = DllStructGetData ($stRECT, 'right')
$aRect[3] = DllStructGetData ($stRECT, 'bottom')
EndIfReturn $aRect
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit]Ist das nicht, was Du wolltest?
Grüße,
t002 -
Mhm, wies aussieht ist es genau das was ich such
Vielen vielen Dank -