1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. veronesi

Beiträge von veronesi

  • UNC Pfad

    • veronesi
    • 15. Juni 2010 um 14:45

    So, nun bin ich ein bisschen weiter.
    Ich habe nun herausgefunden, wie man den aktuellen Pfad findet, in welchem man im Explorer ist.
    Dementsprechend habe ich auch die Funktion NewFolder angepasst.

    Doch wie finde ich den UNC Pfad der markierten Datei heraus?

    Spoiler anzeigen
    [autoit]

    Opt("TrayIconHide", 1)
    Opt("TrayAutoPause", 0)

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{F7}", "NewFolder") ;F7 Hotkey for creating new folder in Windows Explorer
    HotKeySet("{F10}", "UNCPath") ;F10 Hotkey for storing UNC path of the selected file in the clipboard.

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10000)
    WEnd
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Func NewFolder()
    Local $sPath = "", $aInfo, $sDirName = "Neuer Ordner", $iDirExtension = 2, $sDirFullName = ""

    [/autoit] [autoit][/autoit] [autoit]

    $sPath = WinGetText("[CLASS:CabinetWClass]")
    $aInfo = StringSplit($sPath, @LF)
    If Not IsArray($aInfo) Then Return -1
    $sPath = $aInfo[2]

    [/autoit] [autoit][/autoit] [autoit]

    DirGetSize($sPath & "\" & $sDirName)
    If @error <> 1 Then ;Directory already exist!
    While 1 ;While Directory exist which I want to create....
    DirGetSize($sPath & "\" & $sDirName & " (" & $iDirExtension & ")")
    If @error <> 1 Then ;Directory already exist!
    $iDirExtension += 1 ;Increment Index
    Else ;Directory not exist!
    $sDirFullName = $sDirName & " (" & $iDirExtension & ")"
    DirCreate($sPath & "\" & $sDirFullName) ;Create Directory with index-number
    ExitLoop ;Exit While
    EndIf
    WEnd
    Else
    $sDirFullName = $sDirName
    DirCreate($sPath & "\" & $sDirFullName) ;Create Directory without index-number
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Send("{F5}") ;Refresh explorer view
    Sleep(200)
    Send($sDirFullName, 1) ;Select created folder
    Send("{F2}") ;Edit name

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Send("+{F10}")
    ;~ Send("n")
    ;~ Send("o")
    EndFunc ;==>NewFolder

    [/autoit] [autoit][/autoit] [autoit]

    Func UNCPath()
    Local $sPath, $aInfo
    $sPath = WinGetText("[CLASS:CabinetWClass]")
    $aInfo = StringSplit($sPath, @LF)
    If Not IsArray($aInfo) Then Return -1
    $sPath = $aInfo[2]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>UNCPath

    [/autoit]
  • UNC Pfad

    • veronesi
    • 15. Juni 2010 um 14:15

    Danke, aber zuerst muss ich ja wissen, in welchem Verzeichnis ich überhaupt stehe!....

  • UNC Pfad

    • veronesi
    • 15. Juni 2010 um 13:39

    Hallo zusammen!

    Ich möchte ein kleines Progrämmchen schreiben, welches die folgenden zwei Dinge per HotKey tun kann:
    - Automatisch neuen Ordner erstellen. (Im aktuell geöffneten Windows Explorer) Dies ist für mich nützlich, da ich sonst immer rechte Maustaste > Neu > Ordner wählen muss! Jetzt geht's per HotKey!
    - Automatisch den UNC Pfad zu derjenigen Datei in die Zwischenablage kopieren, welche gerade markiert ist.

    Wie kann ich das machen? Den Ordner erstellen habe ich geschafft. Wenn auch nur über eine Tastensimulation. Geht es anderst? Eleganter?

    Danke!

    Spoiler anzeigen
    [autoit]

    Opt("TrayIconHide", 1)
    Opt("TrayAutoPause", 0)

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{F7}", "NewFolder") ;F7 Hotkey for creating new folder in Windows Explorer
    HotKeySet("{F10}", "UNCPath") ;F10 Hotkey for storing UNC path of the selected file in the clipboard.

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10000)
    WEnd
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Func NewFolder()
    Send("+{F10}")
    Send("n")
    Send("o")
    EndFunc ;==>NewFolder

    [/autoit] [autoit][/autoit] [autoit]

    Func UNCPath()

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>UNCPath

    [/autoit]
  • Hängen in einer Schleife.....

    • veronesi
    • 15. Juni 2010 um 13:07

    Was meinst Du mit:

    Zitat von LuZ1F3R

    Problem an der Sache ist nur, dass der case $button3 unendlich ausgeführt wird

    Im Code steht ja:

    Zitat von LuZ1F3R

    Case $Button3
    Exit

    Dann beendet er!

  • Hängen in einer Schleife.....

    • veronesi
    • 15. Juni 2010 um 13:00

    Du kannst auch

    [autoit]

    Send("{TAB 28}")

    [/autoit]

    benutzen!

  • GUIOnEventMode oder GUIGetMsg?

    • veronesi
    • 15. Juni 2010 um 12:54

    Ich nutze den GuiOnEventMode.
    Die meisten Programme von mir haben eine "grosse" Main-Schleife.

    D.h. in der Schleife werden viele verschiedene Subroutinen und Berechnungsprogramme ausgeführt. Die Schleife selbst wiederholt sich so nur ca. alle 2 Minuten.
    Wenn ich erst alle 2 Minuten auf die Switches reagieren würde, wäre das doof.
    Die einzelnen Subroutinen hingegen sind alle nach wenigen Millisekunden beendet. Dadurch kann ich praktisch in "Echtzeit" auf Events des Benutzers reagieren!

  • Stoppuhr - Verbesserungsvorschläge

    • veronesi
    • 15. Juni 2010 um 10:32

    Also so ganz steige ich nicht, wie ich aus meinen Millisekunden mittels Stringformat ein Format mit HH : MM : SS.hh machen könnte.
    Mindestens den _TicksToTime() brauche ich ja doch noch, oder?

    Edit: So, nun funktionieren auch die Millisekunden

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    #include <WindowsConstants.au3>
    #include <Date.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Dim $Start = False, $Timer = 0, $tmpTimer = 0, $LastTimer = 0
    Dim $iHours = 0, $iMins = 0, $iSecs = 0, $iHsecs = 0

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode",1) ;Enable Interrupts for GUI
    $GUI = GUICreate("Stoppuhr", 325, 126, 214, 139, 0x00080000, 0x00000008) ;Create GUI with Topmost ID
    $Stoppuhr = GUICtrlCreateLabel("Stoppuhr", 8, 8, 135, 41)
    GUICtrlSetFont(-1, 26, 400, 0, "Arial")
    $Zeit = GUICtrlCreateLabel("00:00:00.00", 8, 56, 178, 41)
    GUICtrlSetFont(-1, 26, 400, 0, "Arial")
    GUICtrlSetColor(-1, 0xFF0000)
    $StartStopp = GUICtrlCreateButton("Start", 225, 8, 89, 41, $WS_GROUP)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial")
    $Reset = GUICtrlCreateButton("Reset", 225, 56, 89, 41, $WS_GROUP)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial")

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetOnEvent($StartStopp, "StartStopp") ;Create events for Buttons
    GUICtrlSetOnEvent($Reset, "Reset")
    GUISetOnEvent(-3, "End") ;Create Event for {ESC} and Close
    GUISetState(@SW_SHOW) ;Show GUI

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(50) ;Main Loop
    If $Start Then ;Only if start is pressed....
    $tmpTimer = (TimerDiff($Timer)) + $LastTimer
    Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
    GUICtrlSetData($Zeit, $iHours & ":" & $iMins & ":" &$iSecs & "." & $iHsecs) ;Update GUI
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func StartStopp() ;Interrupt for start/stop buttons
    If $Start Then ;Stop button pressed
    GUICtrlSetData($StartStopp, "Start") ;Change button text
    $tmpTimer = (TimerDiff($Timer)) + $LastTimer
    $LastTimer = $tmpTimer
    $Start = False
    Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
    GUICtrlSetData($Zeit, $iHours & ":" & $iMins & ":" &$iSecs & "." & $iHsecs) ;Update GUI
    Else
    GUICtrlSetData($StartStopp, "Stopp") ;Start button pressed
    $Start = True
    $Timer = TimerInit()
    EndIf
    EndFunc ;==>StartStopp

    [/autoit] [autoit][/autoit] [autoit]

    Func Reset() ;Resets GUI
    GUICtrlSetData($Zeit, "00:00:00.00")
    $LastTimer = 0
    $Timer = TimerInit()
    EndFunc ;==>Reset

    [/autoit] [autoit][/autoit] [autoit]

    Func Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
    _TicksToTime($tmpTimer, $iHours, $iMins, $iSecs)
    $iHsecs = Round(($tmpTimer - (($iHours * 3600000) + ($iMins * 60000) + ($iSecs * 1000))) / 10)
    If $iHours < 10 Then $iHours = "0" & $iHours
    If $iMins < 10 Then $iMins = "0" & $iMins
    If $iSecs < 10 Then $iSecs = "0" & $iSecs
    If $iHsecs < 10 Then $iHsecs = "0" & $iHsecs
    EndFunc ;==>Convert

    [/autoit] [autoit][/autoit] [autoit]

    Func End() ;Exit
    Exit
    EndFunc ;==>End

    [/autoit]
  • Stoppuhr - Verbesserungsvorschläge

    • veronesi
    • 15. Juni 2010 um 10:27

    Erst mal vielen Dank für das Lob ;)

    Ich denke, man könnte schon noch einige Dinge verbessern....
    Übrigens funktionieren die Hundersttel Sekunden nicht korrekt.... Hmm muss ich noch schauen.

    Stringformat? Kenne ich nicht. Muss gleich mal die Hilfe durchlesen!
    Danke!

  • Stoppuhr - Verbesserungsvorschläge

    • veronesi
    • 15. Juni 2010 um 10:12

    Hallo zusammen,

    da ich momentan von zwei CAD-Programmen die Geschwindigkeitsunterschiede messen soll, habe ich mir mit AutoIt eine kleine Stoppuhr gebastelt.

    Nun wollte ich Euch fragen, was man am Code verbessern könnte. (Besserer Programmierstiel, einfachere Funktionen....)
    Natürlich ist mir bewusst, dass jeder einen eigenen Programmierstiel hat. Doch ich finde meinen nicht wirklich gut im Moment.
    Gut, ich fange erst an mit AutoIt und ich bin kein Programmierer!

    Auch finde ich in diesem Beispiel unschön, dass ich Strings und Integer vermische.
    Aber ich weiss nicht, wie ich sonst die Millisekunden auf HH : MM : SS . hh aufteilen könnte.

    Wenn jemand konstruktive Ideen hat, dann nur her damit!

    Danke!
    Veronesi

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <Date.au3>
    Opt("GUIOnEventMode",1) ;Enable Interrupts for GUI

    [/autoit] [autoit][/autoit] [autoit]

    $GUI = GUICreate("Stoppuhr", 325, 126, 214, 139, 0x00080000, 0x00000008) ;Create GUI with Topmost ID
    $Stoppuhr = GUICtrlCreateLabel("Stoppuhr", 8, 8, 135, 41)
    GUICtrlSetFont(-1, 26, 400, 0, "Arial")
    $Zeit = GUICtrlCreateLabel("00:00:00.00", 8, 56, 180, 41)
    GUICtrlSetFont(-1, 26, 400, 0, "Arial")
    GUICtrlSetColor(-1, 0xFF0000)
    $StartStopp = GUICtrlCreateButton("Start", 225, 8, 89, 41, $WS_GROUP)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial")
    $Reset = GUICtrlCreateButton("Reset", 225, 56, 89, 41, $WS_GROUP)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial")

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetOnEvent($StartStopp, "StartStopp") ;Create events for Buttons
    GUICtrlSetOnEvent($Reset, "Reset")
    GUISetOnEvent(-3, "End") ;Create Event for {ESC} and Close
    GUISetState(@SW_SHOW) ;Show GUI

    [/autoit] [autoit][/autoit] [autoit]

    Dim $Start = False, $Timer = 0, $tmpTimer = 0, $LastTimer = 0
    Dim $iHours, $iMins, $iSecs, $iHsecs

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(50) ;Main Loop
    If $Start Then ;Only if start is pressed....
    $tmpTimer = (TimerDiff($Timer)) + $LastTimer
    Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
    GUICtrlSetData($Zeit, $iHours & ":" & $iMins & ":" &$iSecs & "." & $iHsecs) ;Update GUI
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func StartStopp() ;Interrupt for start/stop buttons
    If $Start Then ;Stop button pressed
    GUICtrlSetData($StartStopp, "Start") ;Change button text
    $LastTimer = $tmpTimer
    $Start = False
    Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
    GUICtrlSetData($Zeit, $iHours & ":" & $iMins & ":" &$iSecs & "." & $iHsecs) ;Update GUI
    Else
    GUICtrlSetData($StartStopp, "Stopp") ;Start button pressed
    $Start = True
    $Timer = TimerInit()
    EndIf
    EndFunc ;==>StartStopp

    [/autoit] [autoit][/autoit] [autoit]

    Func Reset() ;Resets GUI
    GUICtrlSetData($Zeit, "00:00:00.00")
    $LastTimer = 0
    $Timer = TimerInit()
    EndFunc ;==>Reset

    [/autoit] [autoit][/autoit] [autoit]

    Func Convert() ;Convert ticks to time and splitt it into HH:MM:SS.hh
    _TicksToTime($tmpTimer, $iHours, $iMins, $iSecs)
    $iHsecs = StringRight($tmpTimer, 3)
    $iHsecs = Round($iHsecs / 10)
    If $iHours < 10 Then $iHours = "0" & $iHours
    If $iMins < 10 Then $iMins = "0" & $iMins
    If $iSecs < 10 Then $iSecs = "0" & $iSecs
    If $iHsecs < 10 Then $iHsecs = "0" & $iHsecs
    EndFunc ;==>Convert

    [/autoit] [autoit][/autoit] [autoit]

    Func End() ;Exit
    Exit
    EndFunc ;==>End

    [/autoit]
  • Grafikfehler bei _GDIPlus_GraphicsFillRect

    • veronesi
    • 11. Juni 2010 um 12:44

    Also ich habe hier Win7 64 bit mit 8 Bildschirmen und absolut kein Problem. (Auf keinem der Bildschirme)
    Auch nur mit einer "_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 50, 110, $iWidth, 44)".

    Vielleicht liegt das aber auch an meinen Grafikkarten. Die kosten jeweils 4'000€....

    Gruss
    Veronesi

    PS: Cooles Skript!

  • VNC / Hyena / Dameware / Remotedesktop

    • veronesi
    • 31. Mai 2010 um 13:38

    Ich hatte wirklich keine illegalen Absichten.
    Steht ja auch in meinem Post.

    Aber ich verstehe, dass man solche Funktionen auch zu bösartigen Zwecken misbrauchen könnte.

    In diesem Fall benötige ich "nur" noch die Bildübertragung. Und bei dieser kann ich den oben angegebenen Thread mitlesen!
    Trotzdem danke!

    Gruss
    Veronesi

  • VNC / Hyena / Dameware / Remotedesktop

    • veronesi
    • 31. Mai 2010 um 12:44

    Toll, kannte ich noch nicht! Ist ja auch noch ziemlich aktuell!
    Doch das scheint ein grösseres Projekt zu werden.

    Ich brauche keine Verschlüsselung und das Bild übertragen mache ich auch erst in zweiter Linie.
    Bei mir reicht eine langsame Übertragung der Bilder völlig aus! (Gigabit LAN vorhanden)

    Irgendwelche Ideen für die Tastatur / Mausübertragung (und nicht gerade: In Datei schreiben, auslesen,....) :)

  • VNC / Hyena / Dameware / Remotedesktop

    • veronesi
    • 31. Mai 2010 um 10:52

    Hallo zusammen,

    die Stichworte im Titel sollen darauf hinweisen, dass ich diese Programme alle kenne, und trotzdem hier eine Frage stelle: :D

    Konkret möchte ich so etwas änhliches wie VNC in AutoIt nachbauen.
    Also sobald auf zwei Rechnern im gleichen Netzwerk mein Programm läuft (1x Server, 1x Client), dann möchte ich alle Tastendrücke, die ich auf dem Server ausführe nur auf dem Client ausgeführt haben.
    Im zweiten Schritt möchte ich dann, dass der Client sein Bildschirm (Screenshot?) über das Netzwerk zurückschickt.

    Mit den Tastendrücken habe ich da so meine Probleme: Wenn ich _IsPressed verwende, dauert es ja ewig, bis ich alle möglichen Tastenkombinationen abgefangen habe! Gibt's da was elegantes?
    (Suche momentan nur das Konzept, bevor ich anfange zu programmieren!)

    Warum ich das nicht mit den genannten Programmen machen möchte?
    - Remotedesktop: Nur eine Person kann gleichzeitig daran arbeiten
    - VNC / Hyena / Dameware: zum Teil kostenpflichtig
    - Lerneffekt

    Es geht also überhaupt nicht um etwas illegales oder etwas, was gegen die Forenregeln (bot) verstossen würde!

    Zudem möchte ich, dass immer beide Benutzer gleichzeitig den PC bedienen können.
    (Mich rufen immer wieder Leute an, denen ich am PC was zeigen muss. Aber jedesmal meine Schuhe abwetzen ist nicht so mein Ding!)

    Vielen Dank für Eure Inputs!
    Gruss
    Veronesi

  • DLLs sind kompliziert...

    • veronesi
    • 28. Mai 2010 um 07:49

    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
    #include "Func_GetMonitorInfo.au3"
    #include "Func_GetMouseInfo.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Func _TileWindows()
    ;Tile Windows on that screen where the mouse is!
    ;Call: _TileWindows()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $MonNr, $Left, $Top, $Right, $Bottom, $tStruct, $Rect, $aTmp[32][32]
    $MonNr = _GetMouseInfo()
    $aTmp = _GetMonitorInfo()

    [/autoit] [autoit][/autoit] [autoit]

    $Left = $aTmp[$MonNr][2]
    $Top = $aTmp[$MonNr][3]
    $Right = $aTmp[$MonNr][0] + $Left
    $Bottom = $aTmp[$MonNr][1] + $Top

    [/autoit] [autoit][/autoit] [autoit]

    $tStruct = DllStructCreate("int[4]") ;4 points of values that are integers
    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 basically

    [/autoit] [autoit][/autoit] [autoit]

    DllCall("user32.dll", "int", "TileWindows", "int", 0, "int", 0, "Ptr", $Rect, "int", 0, "int", 0)
    EndFunc

    [/autoit]
  • DLLs sind kompliziert...

    • veronesi
    • 28. Mai 2010 um 07:28

    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)
    $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

    [/autoit] [autoit][/autoit] [autoit]

    $TagMonitorInfo = DllStructCreate("dword cbSize;long[4];long[4];dword dwFlags")
    DllStructSetData($tagmonitorinfo, 1, DllStructGetSize($TagMonitorInfo))
    DllCall("User32.dll", "boolean", "GetMonitorInfo", "hwnd", $hScreen[0], "ptr", DllStructGetPtr($TagMonitorInfo))

    [/autoit] [autoit][/autoit] [autoit]

    ToolTip("X-Pos: " & DllStructGetData($TagMonitorInfo,2,1) & @LF & "Y-Pos: " & DllStructGetData($TagMonitorInfo,2,2))
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func End()
    Exit
    EndFunc ;==>End

    [/autoit]
  • DLLs sind kompliziert...

    • veronesi
    • 27. Mai 2010 um 21:06

    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)
    $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

    [/autoit] [autoit][/autoit] [autoit]

    $TagMonitorInfo = DllStructCreate("dword cbSize;long[4];long[4];dword dwFlags")
    DllStructSetData($tagmonitorinfo, 1, DllStructGetSize($TagMonitorInfo))
    DllCall("User32.dll", "boolean", "GetMonitorInfo", "hwnd", $hScreen[0], "ptr", DllStructGetPtr($TagMonitorInfo))

    [/autoit] [autoit][/autoit] [autoit]

    ToolTip("rcMonitor: " & DllStructGetData($TagMonitorInfo,2,1))
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func End()
    Exit
    EndFunc ;==>End

    [/autoit]

    Bin 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()
    ;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

    [/autoit] [autoit][/autoit] [autoit]

    ;[2][0] X Resolution of Monitor y
    ;[2][1] Y Resolution of Monitor y
    ;[2][2] X Position of Monitor y
    ;[2][3] Y Position of Monitor y
    ;......

    [/autoit] [autoit][/autoit] [autoit]

    Local $NrOfMonitors, $ResolutionX[32], $ResolutionY[32], $PositionX[32], $PositionY[32], $Ret
    Local $cbMonitorEnumProc = DllCallbackRegister("MonitorEnumProc", "ubyte", "ptr;ptr;ptr;int")

    [/autoit] [autoit][/autoit] [autoit]

    If @error Then Return SetError(1, 0, False)
    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 $iCount

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($strctCount, "Count", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $Ret = DllCall("User32.dll", "ubyte","EnumDisplayMonitors","ptr", 0,"ptr", 0, "ptr", DllCallbackGetPtr($cbMonitorEnumProc), "ptr", DllStructGetPtr($strctCount))
    If @error Or $Ret[0] = 0 Then Return SetError(3, @error, False)

    [/autoit] [autoit][/autoit] [autoit]

    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
    $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

    [/autoit] [autoit][/autoit] [autoit]

    $strctCount = 0
    Return $aMonitors
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func MonitorEnumProc($hMonitor, $hdcMonitor, $lprcMonitor, $dwData)
    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"))

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($strctCount, "Width", $Width, $iNumber+1)
    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
    EndFunc

    [/autoit]

    Ist das möglich?

  • DLLs sind kompliziert...

    • veronesi
    • 27. Mai 2010 um 17:02
    Zitat von TheShadowAE

    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)
    $Struct = DllStructCreate("long;long")
    DllStructSetData($Struct, 1, MouseGetPos(0))
    DllStructSetData($Struct, 2, MouseGetPos(1))
    $StructData = DllStructGetData(DllStructCreate("uint64", DllStructGetPtr($Struct)), 1)

    [/autoit] [autoit][/autoit] [autoit]

    $hScreen = DllCall("User32.dll", "handle", "MonitorFromPoint", "uint64", $StructData, "dword", 0)
    $test = DllCall("User32.dll", "ptr", "GetMonitorInfo", "handle", $hScreen)

    [/autoit] [autoit][/autoit] [autoit]

    ToolTip($hScreen[0])
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func End()
    Exit
    EndFunc ;==>End

    [/autoit]

    Die Zeile 12 mit $test = DllCall..... funktioniert nicht, aber wie müsste der korrekt Aufruf lauten?

    Danke!

  • DLLs sind kompliziert...

    • veronesi
    • 27. Mai 2010 um 16:51

    Ich sagte es doch: Die DLLs sind kompliziert.

    Ich komme hier einfach nicht mehr weiter:

    [autoit]

    Local $Struct, $StructData, $hScreen

    [/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)

    [/autoit][autoit][/autoit][autoit]

    $hScreen = DllCall("User32.dll", "handle", "MonitorFromPoint", "uint64", $StructData, "dword", "Monitor_DefaultToNearest")
    $test = DllCall("User32.dll", "ptr", "GetMonitorInfo", "handle", $hScreen)

    [/autoit][autoit][/autoit][autoit]

    ;~ MsgBox(0,"",$test)

    [/autoit]

    Das Handle kann ich nun mit Eurer Hilfe korrekt bestimmen.
    Doch bereits beim nächsten DllCall wieder ein Absturz!
    Das kann doch nicht so kompliziert sein!

  • DLLs sind kompliziert...

    • veronesi
    • 27. Mai 2010 um 16:41

    Progandy, Du bist der Grösste ;)

    So gehts!
    Hast Du auch noch eine Idee, wie ich mit diesem Handle auf die Monitornummer komme?

  • DLLs sind kompliziert...

    • veronesi
    • 27. Mai 2010 um 16:32

    Super, danke!
    Wieder was gutes gelernt!

    Doch warum bekomme ich immer 0x00000000 als Rückgabewert?

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™