Da du die Server ja vermutlich nicht allzusehr belasten möchtest würde ich die Empfehlen, UDP für die CPU-Auslastung zu verwenden, da dann die Daten gesendet werden, allerdings nicht überprüft wird, ob alles ankommt. Bei der CPU-Auslastung ist es ja nicht so wichtig, dass wirklich jeder Wert ankommt. Dadurch könnte etwas Traffic gespart werden...
Beiträge von Kanashius
-
-
Ohne Bibliothek (nach der ich auch erst Suchen müsste, ich denke, es gibt sie aber bestimmt) würd ich sagen, dass du die Bilder ausliest und kopierst. Dann könntest du sie mit
[autoit]GuiCtrlCreatepic()GuiCtrlSetImage()
[/autoit]
anzeigen lassen. Je nachdem, wie viele Bilder das sind würde es aber vermutlich flackern...Ansonsten hab ich nach kurzem suchen bei Google das hier gefunden:
http://www.autoitscript.com/forum/topic/14…-stream-record/Dabei geht es um die Aufnahme einer Ip Kamera. Ich denke da könntest du dir das passende Raussuchen und umschreiben.
Viel Glück noch!
-
Ich habe gerade angefangen mit der D3D (DirectX) Bibliothek von Autoit zu arbeiten. Dabei habe ich das Problem, dass das Programm bei der Funktion _jump, welche ich hinzufügte, jedesmal das Fenster weggeht und kurze Zeit später das Programm abschmiert...
Ich vermute, dass das an einem Dateitypfehler liegt. 0 (int) und 0.0 (float/double) macht allerdings keinen Unterschied... es schmiert bei beidem ab.
In der Konsole erscheint keine Fehlermeldung.Link zur D3D-Bibliothek:
Spoiler anzeigen
Spoiler anzeigen
[autoit]#include "Camera.au3"
[/autoit] [autoit][/autoit] [autoit]
#include "Terrain.au3"
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>Opt("MustDeclareVars", 1)
[/autoit] [autoit][/autoit] [autoit]
Opt("GUIOnEventMode", 1)global $nHeightSave=0,$oFont,$pFont,$pDevice,$tFontDesc,$jump=-1.0,$jumpUp=true
[/autoit] [autoit][/autoit] [autoit];Local Const $sHMapfile = "test2.raw"
[/autoit] [autoit][/autoit] [autoit]
;Local Const $sTerrainTex = "test2_texture.png"
Local Const $sHMapfile = ".\..\..\Media\map128.raw"
Local Const $sTerrainTex = ".\..\..\Media\background.jpg"; Weight modifier used by the weighted averaging of the mouse movement history array
[/autoit] [autoit][/autoit] [autoit]
; As the modifier value increases, the camera gets rotated smoothly but takes longer to rotate to the target.
Local Const $nWeightModifier = 0.3Local Const $iWidth = @DesktopWidth, $iHeight = @DesktopHeight
[/autoit] [autoit][/autoit] [autoit]
;Local Const $iWidth = 640, $iHeight = 480
Local Const $iCenterX = $iWidth/2, $iCenterY = $iHeight/2
; Camera mouse movement sensitivity. Decrease for faster scroll, increase for slower, yet more accurate scroll..
Local Const $nSensitivity = 100Local $hGUI = GUICreate("Direct3D9 - Terrain", $iWidth, $iHeight)
[/autoit] [autoit][/autoit] [autoit]
Local $pDevice, $oDevice; Offset to the window's center from the screen left-top
[/autoit] [autoit][/autoit] [autoit]
Local $iWndCenterX, $iWndCenterY
; History array used to hold last X mouse movement deltas,
; so we can use smooth mouse filtering. Smooth mouse filtering reduces
; the jerky motion of the camera caused by the native jerky mouse movement
Local $aHistory[10][2]; Camera and terrain objects
[/autoit] [autoit][/autoit] [autoit]
Local $tCamera, $tTerrain
; Direction to light holds the opposite vector of the light dir
; so if we're lighting our terrain with a source of light [0, -1, 0] or downward,
; the direction to light should be [0, 1, 0] or upward.
Local $tDirToLight
; Terrain texturing switch
Local $fSwitch_D3D_Startup()
[/autoit] [autoit][/autoit] [autoit]
; Check if failed to load necessary dlls
If @error Then
If @error = 1 Then
Exit MsgBox(0x10, "Error", 'Could not load "d3d9.dll"')
Else
Exit MsgBox(0x10, "Error", 'Could not load "d3dx9_36.dll"')
EndIf
EndIf$pDevice = _D3D_Init($hGUI, $iWidth, $iHeight)
[/autoit] [autoit][/autoit] [autoit]
$oDevice = _AutoItObject_WrapperCreate($pDevice, $tagIDirect3DDevice9)_Setup()
[/autoit] [autoit][/autoit] [autoit]
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
; Change terrain texturing using spacebar
GUIRegisterMsg($WM_KEYDOWN, "_WM_KEYDOWN")
OnAutoItExitRegister("_Cleanup")
GUISetState()While 1
[/autoit] [autoit][/autoit] [autoit]
_Render()
_HighPrecisionSleep(8000)
WEndFunc _Render()
[/autoit] [autoit][/autoit] [autoit]
; Allow user to update the camera view
Local $iRunFactor, $aDeltas, $tCameraPos, $nHeight, $tView, $tWorld,$walk=-1,$Strafe=-1; Left shift to run
[/autoit] [autoit][/autoit] [autoit]
If _IsPressed("A0") Then $iRunFactor = 0.5If _IsPressed("57") Then ; W - move forward
[/autoit] [autoit][/autoit] [autoit]
_CameraWalk($tCamera, 0.7 + $iRunFactor)
$walk=0.7 + $iRunFactor
ElseIf _IsPressed("53") Then ; S - move backward
_CameraWalk($tCamera, -0.7 - $iRunFactor)
$walk=-0.7 - $iRunFactor
EndIfIf _IsPressed("41") Then ; A - move leftward
[/autoit] [autoit][/autoit] [autoit]
_CameraStrafe($tCamera, -0.7 - $iRunFactor)
$Strafe=-0.7 - $iRunFactor
ElseIf _IsPressed("44") Then ; S - move rightward
_CameraStrafe($tCamera, 0.7 + $iRunFactor)
$Strafe=0.7 + $iRunFactor
EndIfif _IsPressed(31) then
[/autoit] [autoit][/autoit] [autoit]
AdlibRegister("_jump",100)
endif$aDeltas = _MouseSmoothFilter($aHistory)
[/autoit] [autoit][/autoit] [autoit]_CameraYaw ($tCamera, $aDeltas[0] / $nSensitivity)
[/autoit] [autoit][/autoit] [autoit]
_CameraPitch($tCamera, $aDeltas[1] / $nSensitivity)If IsDllStruct($tTerrain) Then
[/autoit] [autoit][/autoit] [autoit]
_CameraGetPos($tCamera, $tCameraPos)
$nHeight = _TerrainGetHeight($tTerrain, DllStructGetData($tCameraPos, "x"), DllStructGetData($tCameraPos, "z"))
if Abs($nHeight-$nHeightSave)<1 or ($nHeightSave=0 and DllStructGetData($tCameraPos, "x")=0.0 and DllStructGetData($tCameraPos, "z")=0.0) then
$nHeightSave=$nHeight
DllStructSetData($tCameraPos, "y", $nHeight + 5)
_CameraSetPos($tCamera, $tCameraPos)
else
if $walk<>-1 then
_CameraWalk($tCamera,-$walk)
endif
if $Strafe<>-1 then
_CameraStrafe($tCamera,-$Strafe)
endif
endif
EndIf; Get the camera view matrix
[/autoit] [autoit][/autoit] [autoit]
$oDevice.SetTransform("long", "int", $D3DTS_VIEW, "ptr", _CameraGetView($tCamera, $tView)); Draw the scene, clear the depth and back buffers
[/autoit] [autoit][/autoit] [autoit]
$oDevice.Clear("long", "uint", 0, "ptr", 0, "uint", BitOR($D3DCLEAR_TARGET, $D3DCLEAR_ZBUFFER), "uint", 0xFF5D6FA2, "float", 1, "uint", 0)
$oDevice.BeginScene("long")
; Draw the text
; The first pointer argument should be a sprite object if we call the DrawTextW function more than once in a row
; The fifth argument specifies the format (DT_LEFT, DT_CALCRECT, etc..) and is the same as the GDI DrawText function format argument
;$oFont.DrawTextW("int", "ptr", 0, "wstr", int($nHeight), "int", -1, "ptr", $pRect, "uint", 0, "uint", 0xFF000000) ; black
If IsDllStruct($tTerrain) Then
_D3DX_MatrixIdentity($tWorld)
_TerrainDraw($tTerrain, $tWorld)
EndIf$oDevice.EndScene("long")
[/autoit] [autoit][/autoit] [autoit]
$oDevice.Present("long", "ptr", 0, "ptr", 0, "hwnd", 0, "ptr", 0)
EndFuncFunc _jump()
[/autoit] [autoit][/autoit] [autoit]
if $jump=-1.0 then
$jump=0.1
local $tCameraPos
_CameraGetPos($tCamera, $tCameraPos)
$y=DllStructGetData($tCamera,"y")
_CameraFly($tCamera, $y+$jump)
elseif $jump=0.0 then
$jump=-1.0
$jumpUp=true
AdlibUnRegister("_jump")
elseif $jump<0.9 and $jumpUp then
$jump+=0.1
local $tCameraPos
_CameraGetPos($tCamera, $tCameraPos)
$y=DllStructGetData($tCamera, "y")
_CameraFly($tCamera, $y+$jump)
elseif $jump>0.9 then
$jumpUp=false
$jump=0.8
elseif $jump<0.9 and not $jumpUp then
$jump-=0.1
local $tCameraPos
_CameraGetPos($tCamera, $tCameraPos)
$y=DllStructGetData($tCamera, "y")
_CameraFly($tCamera, $y+$jump)
endif
EndFuncFunc _MouseSmoothFilter(ByRef $aMovement)
[/autoit] [autoit][/autoit] [autoit]
Local $aPos, $iDX, $iDY; Get cursor position
[/autoit] [autoit][/autoit] [autoit]
$aPos = _GetCursorPos()
; Reset mouse position back to the center of the window
_SetCursorPos($iWndCenterX, $iWndCenterY)
$iDX = $aPos[0] - $iWndCenterX
$iDY = $aPos[1] - $iWndCenterY_MousePerformFiltering($aMovement, $iDX, $iDY)
[/autoit] [autoit][/autoit] [autoit]
Return _MousePerformSmoothing($aMovement)
EndFuncFunc _MousePerformFiltering(ByRef $aMovement, $nDX, $nDY)
[/autoit] [autoit][/autoit] [autoit]
Local $aDeltas[2], $nAvgX, $nAvgY, $nAvgSum, $nCurrWeight = 1; Update the arraw by pushing all elements of the array, thus the array contains the last X deltas
[/autoit] [autoit][/autoit] [autoit]
; where X is the size of the array
For $i = UBound($aMovement)-1 To 1 Step -1
$aMovement[$i][0] = $aMovement[$i - 1][0]
$aMovement[$i][1] = $aMovement[$i - 1][1]
Next$aMovement[0][0] = $nDX
[/autoit] [autoit][/autoit] [autoit]
$aMovement[0][1] = $nDY; Weighted average of deltas
[/autoit] [autoit][/autoit] [autoit]
For $i = 0 To UBound($aMovement)-1
$nAvgX += $aMovement[$i][0] * $nCurrWeight
$nAvgY += $aMovement[$i][1] * $nCurrWeight
$nAvgSum += $nCurrWeight
$nCurrWeight *= $nWeightModifier
Next$aDeltas[0] = $nAvgX / $nAvgSum
[/autoit] [autoit][/autoit] [autoit]
$aDeltas[1] = $nAvgY / $nAvgSum
; Update the current mouse movement delta with the weighted delta
$aMovement[0][0] = $aDeltas[0]
$aMovement[0][1] = $aDeltas[1]Return $aDeltas
[/autoit] [autoit][/autoit] [autoit]
EndFuncFunc _MousePerformSmoothing(ByRef $aMovement)
[/autoit] [autoit][/autoit] [autoit]
Local $aDeltas[2]$aDeltas[0] = ($aMovement[0][0] + $aMovement[1][0]) * 0.5
[/autoit] [autoit][/autoit] [autoit]
$aDeltas[1] = ($aMovement[0][1] + $aMovement[1][1]) * 0.5Return $aDeltas
[/autoit] [autoit][/autoit] [autoit]
EndFuncFunc _Setup()
[/autoit] [autoit][/autoit] [autoit]
Local $tProj, $aPos, $aRet, $iSize$tFontDesc = _D3D_CreateFontDesc(25, 12, 500, "Times New Roman")
[/autoit] [autoit][/autoit] [autoit]
$pFont = _D3DX_CreateFontIndirect($pDevice, DllStructGetPtr($tFontDesc))
$oFont = _AutoItObject_WrapperCreate($pFont, $tagID3DXFont); Use the square root of the file size for dimensions of the terrain
[/autoit] [autoit][/autoit] [autoit]
$iSize = Int(Sqrt(FileGetSize($sHMapfile))); Create the first person camera object. Land object camera type.
[/autoit] [autoit][/autoit] [autoit]
$tCamera = _CameraCreate($CAMERATYPE_LANDOBJECT)
; Create the direction to light vector for colors shading. Light rays travel at -45 degrees down relative to the x-axis
; so the direction to light is upword at 135 degrees relative to the x-axis
; Note that the direction to light vector is a unit vector.
_D3D_CreateVector3($tDirToLight, -0.707, 0.707, 0)
; Higher cell spaced terrains are said to be lower resolution terrains.
$tTerrain = _TerrainCreate($pDevice, $sHMapfile, $iSize, $iSize, 8, 0.7)
If Not @error Then
_TerrainLoadTexture($sTerrainTex)
_TerrainGenerateTexture($tTerrain, $tDirToLight)
EndIf; Set texture filters
[/autoit] [autoit][/autoit] [autoit]
$oDevice.SetSamplerState("long", "uint", 0, "int", $D3DSAMP_MAGFILTER, "uint", $D3DTEXF_LINEAR)
$oDevice.SetSamplerState("long", "uint", 0, "int", $D3DSAMP_MINFILTER, "uint", $D3DTEXF_LINEAR)
$oDevice.SetSamplerState("long", "uint", 0, "int", $D3DSAMP_MIPFILTER, "uint", $D3DTEXF_LINEAR); Set projection matrix (45 degrees)
[/autoit] [autoit][/autoit] [autoit]
$oDevice.SetTransform("long", "int", $D3DTS_PROJECTION, "ptr", _D3DX_MatrixPerspectiveFovLH($tProj, ASin(1)/2, $iWidth/$iHeight, 1, 1000)); Calculate the screen position of our window's center
[/autoit] [autoit][/autoit] [autoit]
$aPos = WinGetPos($hGUI)
$iWndCenterX = $aPos[0] + $iCenterX
$iWndCenterY = $aPos[1] + $iCenterY; Reset mouse to the center of the window and hide the mouse cursor
[/autoit] [autoit][/autoit] [autoit]
_SetCursorPos($iWndCenterX, $iWndCenterY)
GUISetCursor(16)
EndFuncFunc _WM_KEYDOWN($hWnd, $iMsg, $iwParam, $ilParam)
[/autoit] [autoit][/autoit] [autoit]
If $iwParam = 0x20 Then
If IsDllStruct($tTerrain) Then
_TerrainSwitchTexture($fSwitch)
$fSwitch = Not $fSwitch
EndIf
EndIfReturn $GUI_RUNDEFMSG
[/autoit] [autoit][/autoit] [autoit]
EndFuncFunc _Quit()
[/autoit] [autoit][/autoit] [autoit]
Exit
EndFuncFunc _Cleanup()
[/autoit] [autoit][/autoit] [autoit]
$oDevice = 0
GUIDelete()
_D3D_Shutdown()
EndFunc; #FUNCTION#;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Name...........: _HighPrecisionSleep()
; Description ...: Sleeps down to 0.1 microseconds
; Syntax.........: _HighPrecisionSleep( $iMicroSeconds, $hDll=False)
; Parameters ....: $iMicroSeconds - Amount of microseconds to sleep
; $hDll - Can be supplied so the UDF doesn't have to re-open the dll all the time.
; Return values .: None
; Author ........: Andreas Karlsson (monoceres)
; Modified.......:
; Remarks .......: Even though this has high precision you need to take into consideration that it will take some time for autoit to call the function.
; Related .......:
; Link ..........;
; Example .......; No
;
;;==========================================================================================
Func _HighPrecisionSleep($iMicroSeconds,$hDll=False)
Local $hStruct, $bLoaded
If Not $hDll Then
$hDll=DllOpen("ntdll.dll")
$bLoaded=True
EndIf
$hStruct=DllStructCreate("int64 time;")
DllStructSetData($hStruct,"time",-1*($iMicroSeconds*10))
DllCall($hDll,"dword","ZwDelayExecution","int",0,"ptr",DllStructGetPtr($hStruct))
If $bLoaded Then DllClose($hDll)
EndFuncFunc _GetCursorPos()
[/autoit] [autoit][/autoit] [autoit]
Local $aRet[2], $tPoint = DllStructCreate("int;int")
DllCall("user32.dll", "bool", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))$aRet[0] = DllStructGetData($tPoint, 1) ; X
[/autoit] [autoit][/autoit] [autoit]
$aRet[1] = DllStructGetData($tPoint, 2) ; YReturn $aRet
[/autoit] [autoit][/autoit] [autoit]
EndFuncFunc _SetCursorPos($iX, $iY)
[/autoit]
DllCall("user32.dll", "bool", "SetCursorPos", "int", $iX, "int", $iY)
EndFunc -
Versuch es mal mit
[autoit]
[/autoit]
ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )
[autoit]
zum klicken undControlSend ( "title", "text", controlID, "string" [, flag = 0] )
[/autoit]
zum senden des Textes
Title=Titel des Fensters
Text=""
controlId:
siehe Au3Info.exe (installationsverzeichnis von Autoit)Ansonsten einfach die Hilfe zu den beiden Befehlen durchlesen.
Viel Glück noch.
PS: Würdest du dein komplettes Script lauffähig posten, bzw. auch das zu installierende Programm könnte ich dir evtl. auch präziser helfen
-
Dieses Programm dient dazu, EPUBs zu Verwalten. Es können Ordner importiert werden. Es werden zahlreiche Infos über das jeweilige EPUB ausgelesen und in eine Datenbank gespeichert.
Dabei habe ich besonders darauf geachtet, dass die Geschwindigkeit möglichst gering ist, da es möglich sein soll, auch eine große Menge an EPUBs zu verwalten, ohne das große Ladeprobleme entstehen.
Alle Vorgänge, bei denen geladen wird werden angezeigt. Zur besseren Verwaltung ist auch eine Sql-Konsole beigefügt, aber auch so können die Infos gut bearbeitet werden.
Desweiteren gibt es einen eigenen Epub-Reader, um die Epubs mit nur einem Doppelklick auf den Eintrag lesen zu können.Seht es euch einfach mal an. Ich wünsch euch viel Spaß!
Infos, die, wenn im EPUB vorhanden in die Datenbank eingetragen werden:
Identifier, Autor, Beschreibung, Titel, Genre, Erstelldatum, Pfad, SpracheScreenshots:
Spoiler anzeigen
Falls ihr noch Ideen habt, Fehler findet oder ähnliches, würde ich mich Freuen, sie zu hören
Noch geplant ist:
- Ein Integrierter FTP-Client, um die EPUBs zum Beispiel auf ein Handy hochzuladen, etc.
- Unterstützung anderer E-Book Formate
- ...
Umgesetzt:
- Einzelne Dateien Importieren- Beliebiger Pfad für Bücher
- Eigener Epub-Reader
- Bewertung einzelner Bücher mit 0-5 Sternen
- Die Anzeige für die Beschreibung wurde in ein IE-Objekt umgewandelt, da die Beschreibungen oftmals mit HTML-Tags versehen waren- EPUB ReaderNäheres zum Epub-Reader:
Der Epub-Reader öffnet Epubs und es kann Kapitel für Kapitel durchgeblättert werden.
Auf der linken Seite befindet sich eine Listbox, in der die Kapitel auch einzeln angeklickt werden können.
Der Epub-Reader besitzt eine Vorlese-Funktion, mit der das Epub vorgelesen werden kann. (Stimme und Audioausgang kann geändert werden)Es ist auch möglich, die Schriftgröße zu ändern.aktuell: Version 2.3
Changelog:
Spoiler anzeigen
Update 02.08.2014 (Version 2.3):
Funktionen:
- Es kann nun ein beliebiger Pfad verwendet werden. Wenn sich das Buch im Unterordner befindet, wird er local genutzt, andernfalls der Globale Pfad. Die Pfade können jederzeit zwischen Global und Lokal gewechselt werden. (Mit der Option sie in einen Unterordner zu verschieben
Intern:
- Einige Änderungen und Bugfixes (beim Importieren)
- Die Struktur der zur Buchsammlung gehörenden Dateien wurde geändert
Update 02.07.2014 (Version 2.2):Epub-Reader:
- Schriftgröße kann nun eingestellt werdenUpdate 02.07.2014 (Version 2.1):
Funktionen:
- Ladebildschirm nach Programmstart
- Beschreibung kann vorgelesen werden -> Einstellungsmöglichkeit: Stimme, Audioausgang, Lautstärke, Geschwindigkeit
- Bücher können nun einzeln importiert werden
- kleinere Bugfixes und Änderungen
Epub-Reader:
- kleinere Bugfixes und Änderungen
- Vorlese-Funktion auf ein Edit-Feld erweitert, sodass auch eigene Texte vorgelesen werden können
Update 23.05.2014 (Version 2.0):
Funktionen:
- In den Einstellungen kann festgelegt werden, ob die Datei mit dem eigenen Reader geöffnet werden soll
Erweiterungen:
- Epub-Reader hinzugefügt.
- Lesen mit einem IE-Objekt und einer Listbox als Kapitelübersicht
- Vorlese-Funktion mit der Möglichkeit, die Stimme, den Audioausgang, die Lautstärke und die Geschwindigkeit anzupassen
Update 03.05.2014 (Version 1.2):
Changes:
- Die Sql-Konsole gibt die abgefragten Daten nun in der Tabelle der MainGui aus
- kleinere Bugfixes
Update 29.04.2014 (Version 1.1):
Funktionen:
- Einzelne Bücher können Bewertet werden. Dabei sind 0-5 Sterne möglich. Nicht bewertet wird durch einen Leeren String dargestellt
Changes:
- Die Anzeige für die Beschreibung wurde in ein IE-Objekt umgewandelt
Release 28.04.2014 (Version 1.0):
Funktionen:
- Ordner Importieren
- Genre Suchkreterien manuell festlegen (Name wird in einer Listbox links angezeigt, dabei steht jeweils die Anzahl der enthaltenen Bücher)
- Suchfunktion
- Anzeige in einer Listview
- Infos über das in der Listview angeklickte Element werden auf der Rechten Seite angezeigt
- SqlKonsole für alle die sich damit auskennen, um manuell Änderungen vorzunehmen (mehrzeilig mit Kommentaren)
- Linksklick auf Listview: Ordner im Explorer öffnen und dabei die Datei markieren, Infos bearbeiten, Pfad in Zwischenablage kopieren, usw.
- ...Es befinden sich nun alle benötigten Dateien in den Zips. (Es ist nicht mehr notwendig, dass Sqlite und 7zip installiert ist.)
Ich habe das Projekt komplett in C++ (QT) erneut umgesetzt. Die Geschwindigkeit wurde dadurch von 30 auf 3 sec zum laden verbessert
Es gibt auch einige weitere Verbesserungen. Ich hänge den QT-Source an, falls es jemanden Interessiert. (QT Version 5.3.2)Den Source von Autoit findet ihr im Ordner Data\SourceCode.
-
Ich habe im Zusammenhang mit einem anderen Projekt einen Datei-Explorer geschrieben.
Navigiert wird über eine TreeView, über die auf alle Laufwerke und Unterordner zugegriffen werden kann. Mit Klick auf ein Item wird der jeweilige Ordner in der Listview angezeigt.
Dabei werden erst die Ordner und dann die Dateien aufgelistet. Ganz Oben befindet sich ein Ordner mit der Beschriftung "..", um in das übergeordnete Verzeichnis zu wechseln.
Zur Verschönerung werden auch Icons angezeigt.
Hier das Script:
Spoiler anzeigen
[autoit]#include <GuiListView.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <GuiTreeView.au3>
#include <StructureConstants.au3>
#include <TreeViewConstants.au3>
#include <array.au3>
#include <file.au3>
Opt("GUIOnEventMode", 1)global $ExplorerGui,$ExplorerGui_ListTree1,$ExplorerGui_ListView1
[/autoit] [autoit][/autoit] [autoit]
global $aktTreePath="",$FoldersCount=0
global $newServerGui,$newServerAdress,$newServerUser,$newServerPassword,$newServerPortCreateExplorerGui()
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
[/autoit] [autoit][/autoit] [autoit]
;Icons in eine Liste speichern
Global $hImage = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 3) ; Verzeichnis-Icon
_GUIImageList_AddIcon($hImage, 'shell32.dll', 110) ; Verzeichnis-Icon mit Haken
_GUIImageList_AddIcon($hImage, 'shell32.dll', 1) ; Datei-Icon
_GUIImageList_AddIcon($hImage, 'shell32.dll', 5) ; Diskette
_GUIImageList_AddIcon($hImage, 'shell32.dll', 7) ; Wechseldatenträger
_GUIImageList_AddIcon($hImage, 'shell32.dll',; Festplatte
_GUIImageList_AddIcon($hImage, 'shell32.dll', 11) ; CDROM
_GUIImageList_AddIcon($hImage, 'shell32.dll', 12) ; Netzwerklaufwerk
_GUIImageList_AddIcon($hImage, 'shell32.dll', 53) ; Unbekannt
_GUICtrlTreeView_SetNormalImageList($ExplorerGui_ListTree1, $hImage)
_GUICtrlListView_SetImageList($ExplorerGui_ListView1,$hImage,1)
;Icons für TreeView und ListView gesetzt;Laufwerke werden aufgelistet
[/autoit] [autoit][/autoit] [autoit]
If ToolTip('Please wait...', Default, Default, 'Read Directory', 1) Then Local $aDrives = DriveGetDrive('ALL'), $iLWindex, $hRoot
For $i = 1 To $aDrives[0]
$iLWindex = 0
Switch DriveGetType($aDrives[$i])
Case 'Fixed'
$iLWindex = 5
Case 'CDROM'
$iLWindex = 6
Case 'RAMDisk'
$iLWindex = 7
Case 'Removable'
$iLWindex = 4
If StringLeft($aDrives[$i], 2) = 'a:' Or StringLeft($aDrives[$i], 2) = 'b:' Then $iLWindex = 3
Case Else
$iLWindex = 8
EndSwitch
$hRoot = _GUICtrlTreeView_Add(GUICtrlGetHandle($ExplorerGui_ListTree1), 0, StringUpper($aDrives[$i]), $iLWindex, $iLWindex)
DirInTree("C:",$ExplorerGui_ListTree1,$hRoot,true,true)
_GUICtrlTreeView_AddChild(GUICtrlGetHandle($ExplorerGui_ListTree1), $hRoot, "test", 0, 0)
If DriveStatus($aDrives[$i]) <> 'READY' Then ContinueLoop
Next
ToolTip('');ein bestimmter Pfad wird aufgerufen (Desktop)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
openTreePath(@DesktopDir,$ExplorerGui_ListTree1);Dauerschleife bis zum Ende des Programms
[/autoit] [autoit][/autoit] [autoit]
while 1
sleep(100)
WEndFunc CreateExplorerGui()
[/autoit] [autoit][/autoit] [autoit]
;Fenster wird erzeut
$ExplorerGui=GUICreate("",800,600)
$ExplorerGui_ListTree1=GUICtrlCreateTreeView(10,10,780,280)
;Auf die Style der ListView achten!!!!
$ExplorerGui_ListView1=GUICtrlCreateListView("Dateiname |Größe |Erstelldatum (YYYY/MM/DD HH:MM:SS) ",10,300,780,290,BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT),BitOR( $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUISetOnEvent($GUI_EVENT_CLOSE, "_ExplorerGui_Close",$ExplorerGui)
GUISetState(@SW_SHOW,$ExplorerGui)
EndFuncFunc _ExplorerGui_Close()
[/autoit] [autoit][/autoit] [autoit]
exit
EndFuncFunc _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
[/autoit] [autoit][/autoit] [autoit]
Local $hChild, $hITEM, $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $ilParam)
;Notify Event für die Treeview
If DllStructGetData($tNMTREEVIEW, 'hWndFrom') = GUICtrlGetHandle($ExplorerGui_ListTree1) Then
Switch DllStructGetData($tNMTREEVIEW, 'Code')
Case $TVN_ITEMEXPANDINGA, $TVN_ITEMEXPANDINGW
;Eintrag wird expandiert
Switch DllStructGetData($tNMTREEVIEW, 'Action')
Case $TVE_EXPAND
$hITEM = DllStructGetData($tNMTREEVIEW, 'NewhItem')
DirInTree("",$ExplorerGui_ListTree1,$hITEM,true,true)
EndSwitch
Case $TVN_SELCHANGEDW
;Selektion wurde geändert
$sel=_GUICtrlTreeView_GetSelection(GUICtrlGetHandle($ExplorerGui_ListTree1))
if $sel<>0 then
Content(getPathFromTreeView(GUICtrlGetHandle($ExplorerGui_ListTree1),$sel)&"",$ExplorerGui_ListView1)
endif
EndSwitch
EndIf
;Notify Event für die ListView
If DllStructGetData($tNMTREEVIEW, 'hWndFrom') = GUICtrlGetHandle($ExplorerGui_ListView1) Then
Switch DllStructGetData($tNMTREEVIEW, 'Code')
Case $NM_DBLCLK
;doppelklick auf ein ListViewItem
$selIndex=int(_GUICtrlListView_GetSelectedIndices($ExplorerGui_ListView1))
if $selIndex>0 and $selIndex<$FoldersCount+1 then ;wechsle zum angeklickten Ordner $Folderscount, damit keine Dateien angeklickt werden können
$selText=_GUICtrlListView_GetItemText($ExplorerGui_ListView1,$selIndex,0)
openTreePath($selText,$ExplorerGui_ListTree1,_GUICtrlTreeView_GetSelection(GUICtrlGetHandle($ExplorerGui_ListTree1)))
DirInTree("C:",$ExplorerGui_ListTree1,_GUICtrlTreeView_GetSelection(GUICtrlGetHandle($ExplorerGui_ListTree1)),true,true)
elseif $selIndex=0 then ;erster Eintrag in der Listview angeklickt: in Übergeordneten Ordner wechseln
$path=getPathFromTreeView($ExplorerGui_ListTree1,_GUICtrlTreeView_GetSelection(GUICtrlGetHandle($ExplorerGui_ListTree1)))
$ar=StringSplit($path,"")
$string=""
for $i=1 to UBound($ar)-2 step 1
$string&=$ar[$i]&""
next
openTreePath($string,$ExplorerGui_ListTree1,_GUICtrlTreeView_GetSelection(GUICtrlGetHandle($ExplorerGui_ListTree1)),true)
DirInTree("C:",$ExplorerGui_ListTree1,_GUICtrlTreeView_GetSelection(GUICtrlGetHandle($ExplorerGui_ListTree1)),true,true)
endif
EndSwitch
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFYFunc DirInTree($sSearchPath,$Tree,$hItem=-1,$SearchAll=true,$ext=false) ;rekursiver Aufruf, um jeweils die nächste Ebenen anzuzeigen
[/autoit] [autoit][/autoit] [autoit]
if $SearchAll then
ToolTip('Please wait...', Default, Default, 'Read Directory', 1)
_GUICtrlTreeView_BeginUpdate($Tree)
endif
local $hItemNew,$parent
if $ext then
$sSearchPath=getPathFromTreeView($Tree,$hItem)
_GUICtrlTreeView_DeleteChildren($Tree,$hItem)
endif
$search=FileFindFirstFile($sSearchPath&""&"*.*")
$ChildDirs=false
While 1
$path=FileFindNextFile($search)
;msgbox(48,"",$path)
if @extended then
if $hItem=-1 then
$hItemNew=_GUICtrlTreeView_Add($Tree,0,$path,0,0)
else
$hItemNew=_GUICtrlTreeView_AddChild($Tree,$hItem,$path,0,0)
endif
if $SearchAll then
if not DirInTree($sSearchPath&""&$path,$Tree,$hItemNew,false) then
_GUICtrlTreeView_Delete($Tree,$hItemNew)
if $hItem=-1 then
$hItemNew=_GUICtrlTreeView_AddChild($Tree,0,$path,0,0)
else
$hItemNew=_GUICtrlTreeView_AddChild($Tree,$hItem,$path,0,0)
endif
endif
endif
$ChildDirs=true
endif
if @error=1 then
#cs
if not $ChildDirs then
if $hItem=-1 then
$hItemNew=_GUICtrlTreeView_Add($Tree,0,$path,0,0)
else
_GUICtrlTreeView_AddChild($Tree,$hItem,$path,0,0)
endif
endif
#ce
ExitLoop 1
endif
WEnd
FileClose($search)
if $SearchAll then
_GUICtrlTreeView_EndUpdate($Tree)
ToolTip('')
endif
return $ChildDirs
EndFuncFunc getPathFromTreeView($Tree,$hItem)
[/autoit] [autoit][/autoit] [autoit]
return StringReplace(_GUICtrlTreeView_GetTree($Tree,$hItem),"|","")
EndFuncFunc Content($directory,$ListView) ;ListView mit Dateien und Ordnern füllen
[/autoit] [autoit][/autoit] [autoit]
_GUICtrlListView_DeleteAllItems($ListView)
$item = GUICtrlCreateListViewItem("..||", $ListView)
_GUICtrlListView_AddSubItem( $ListView, 0, "..",0,0)
$FileList=_FileListToArray($directory,'*.*', 2) ; Only files
if @error then
$FoldersCount=0
else
$FoldersCount=UBound($FileList)-1
endif
for $n = 1 to UBound($FileList)-1
$File_Name = $FileList[$n]
$File_size = ""
$File_t = FileGetTime($directory & "" & $File_Name, 1) ; creation Time
$File_time = $File_t[0] & "/" & $File_t[1] & "/" & $File_t[2] & " " & $File_t[3] & ":" & $File_t[4] & ":" & $File_t[5] ; detailed
$item = GUICtrlCreateListViewItem($File_Name & "|" & $File_size & "|" & $File_time, $ListView)
;_GUICtrlListView_SetItemImage ( $ListView, $n-1, 0,0)
_GUICtrlListView_AddSubItem( $ListView, $n, $File_Name,0,0)
Next
$FileList=_FileListToArray($directory,'*.*', 1) ; Only files
for $n = 1 to UBound($FileList)-1
$File_Name = $FileList[$n]
$File_size = int(FileGetSize ( $directory & "" & $File_Name)/100)&" KB"
$File_t = FileGetTime($directory & "" & $File_Name, 1) ; creation Time
$File_time = $File_t[0] & "/" & $File_t[1] & "/" & $File_t[2] & " " & $File_t[3] & ":" & $File_t[4] & ":" & $File_t[5] ; detailed
$item = GUICtrlCreateListViewItem($File_Name & "|" & $File_size & "|" & $File_time, $ListView)
_GUICtrlListView_AddSubItem( $ListView,$FoldersCount+$n, $File_Name,0,2)
Next
EndFunc ;==>ContentFunc openTreePath($dir,$Tree,$current=0,$back=false) ;automatisch in ein bestimmtes Verzeichnis wechseln
[/autoit] [autoit][/autoit] [autoit]
$text=""
if $current=0 then
$text=-1
elseif $back then
$ar=StringSplit(_GUICtrlTreeView_GetTree($Tree,$current),"|")
$dir=""
for $i=1 to UBound($ar)-3 step 1
$dir&=$ar[$i]&""
next
$dir&=$ar[UBound($ar)-2]
$text=$ar[UBound($ar)-3]
;msgbox(48,"",$dir&"&"&$text)
else
$text=_GUICtrlTreeView_GetText($Tree,$current)
endif
$ar=StringSplit($dir,"")
;$current=0
for $i=1 to UBound($ar)-1 step 1
if $ar[$i]<>"" then
$ready=false
while not $ready
if $current<>0 then
$current=_GUICtrlTreeView_FindItem($Tree,$ar[$i],false,$current)
else
$current=_GUICtrlTreeView_FindItem($Tree,$ar[$i])
endif
$str=_GUICtrlTreeView_GetTree($Tree,$current)
$ar1=StringSplit($str,"|")
;msgbox(48,"",$ar1[UBound($ar1)-2]&"&"&$text)
if $i<>UBound($ar)-1 or $text=-1 or $ar1[UBound($ar1)-2]=$text then
_GUICtrlTreeView_Expand_self($Tree,$current,true)
$ready=true
else
$current=_GUICtrlTreeView_GetNext ( $Tree, $current)
endif
WEnd
endif
next
if UBound($ar)-1<3 then
_GUICtrlTreeView_Expand_self($Tree,$current,true)
endif
;_GUICtrlTreeView_SetSelected($Tree,$current)
_GUICtrlTreeView_SelectItem($Tree,$current)
Content(getPathFromTreeView($Tree,$current),$ExplorerGui_ListView1)
EndFunc; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Author ........: Holger Kotsch
; Modified.......: Gary Frost
; ===============================================================================================================================
Func _GUICtrlTreeView_Expand_self($hWnd, $hItem = 0, $fExpand = True)
If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)If $hItem = 0 Then $hItem = 0x00000000
[/autoit] [autoit][/autoit] [autoit]If $hItem = 0x00000000 Then
[/autoit] [autoit][/autoit] [autoit]
$hItem = $TVI_ROOT
Else
If Not IsHWnd($hItem) Then
Local $hItem_tmp = GUICtrlGetHandle($hItem)
If $hItem_tmp <> 0x00000000 Then $hItem = $hItem_tmp
EndIf
EndIfIf $fExpand Then
[/autoit] [autoit][/autoit] [autoit]
__GUICtrlTreeView_ExpandItem_self($hWnd, $TVE_EXPAND, $hItem)
Else
__GUICtrlTreeView_ExpandItem_self($hWnd, $TVE_COLLAPSE, $hItem)
EndIf
EndFunc ;==>_GUICtrlTreeView_Expand; #INTERNAL_USE_ONLY# ===========================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: __GUICtrlTreeView_ExpandItem($hWnd, $iExpand, $hItem)
; Description ...: Expands/Collapes the item and child(ren), if any
; Syntax.........: __GUICtrlTreeView_ExpandItem ( $hWnd, $iExpand, $hItem )
; Parameters ....: $hWnd - Handle to the control
; Return values .:
; Author ........: Holger Kotsch
; Modified.......: Gary Frost (gafrost), Kanashius
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func __GUICtrlTreeView_ExpandItem_self($hWnd, $iExpand, $hItem)
If Not IsHWnd($hWnd) ThenIf $hItem = 0x00000000 Then
[/autoit] [autoit][/autoit] [autoit]
$hItem = $TVI_ROOT
Else
$hItem = GUICtrlGetHandle($hItem)
If $hItem = 0 Then Return
EndIf
$hWnd = GUICtrlGetHandle($hWnd)
EndIf_SendMessage($hWnd, $TVM_EXPAND, $iExpand, $hItem, 0, "wparam", "handle")
[/autoit] [autoit][/autoit] [autoit]If $iExpand = $TVE_EXPAND And $hItem > 0 Then _SendMessage($hWnd, $TVM_ENSUREVISIBLE, 0, $hItem, 0, "wparam", "handle")
[/autoit] [autoit][/autoit] [autoit]$hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem, 0, "wparam", "handle")
[/autoit]
EndFunc ;==>__GUICtrlTreeView_ExpandItem -
[autoit][/autoit][autoit][/autoit][autoit]
ExitLoop [level]
[/autoit][autoit][/autoit][autoit][/autoit]willst du also nur eine Schleife beenden musst du einfach ExitLoop 1 eingeben...
[autoit]
Da das allerdings über einen Funktionsaufruf läuft funktioniert diese Methode nicht. Daher musst du eine Variable definieren, welche den wert true hat. Drückst du dein hotkey wird deine funktion aufgerufen und setzt den wert der variable auf false, sodass die Schleife abbricht... Probiers mal aus!HotKeySet("key","ende")
[/autoit][autoit][/autoit][autoit]
$var=truewhile $var
[/autoit][autoit][/autoit][autoit]
sleep(1000)
WEndFunc ende()
[/autoit]
$var=false
EndFunc -
Sorry. Flüchtigkeitsfehler von mir. StringReplace gibt einen String zurück. Ich habe den String nicht wieder gespeichert. Das ersetzte ist somit "verfallen"...
[autoit]#include <array.au3>
[/autoit][autoit][/autoit][autoit]
#include <File.au3>Dim $aContent
[/autoit][autoit][/autoit][autoit]
Dim $sData$sFile2 = @ScriptDir & "\file2.csv"
[/autoit][autoit][/autoit][autoit]
$sFile3 = @ScriptDir & "\protokoll.csv"_deltest()
[/autoit][autoit][/autoit][autoit]Func _deltest()
[/autoit][autoit][/autoit][autoit]
#cs
If Not _FileReadToArray($sFile2, $aContent) Then
MsgBox(0, "Achtung", "Datei konnte nicht eingelesen werden!")
Exit
EndIf
_FileReadToArray($sFile3, $aContent) ; protokoll.csv einlesen im Array
#ce
$aContent=FileReadToArray($sFile3)
_ArrayDisplay($aContent) ; Array anzeigen$sData = FileRead($sFile2)
[/autoit]
;MsgBox(0, "", $sData)
;msgbox(48,"",$sData)
For $i = 0 To UBound($aContent) - 1 Step 1
$sData=StringReplace($sData, $aContent[$i], "")
Next
$oFile=FileOpen($sFile2,2)
FileWrite($sFile2, $sData)
FileClose($oFile)
EndFunc ;==>_deltest
PS: Eventuell können noch "leere" zeilen übrig bleiben. Das liegt daran, dass dort dann @crlf oder @cr oder @lf drin steht. Dazu sieh dir die Makros am besten an (sie markieren das zeilenende). Daher sind sie im normalen Editor, etc. nicht sichtbar. (zum anzeigen kannst du z.B. Notepad++ verwenden. Dort kann man sich die anzeigen lassen.)
Ich hab noch nen paar kleinere Änderungen hinzugefügt. Sieh sie dir am besten selbst an.Viel Glück noch!
-
[autoit]
$sData=fileread($sFile2)
[/autoit]
for $i=0 to ubound($aContent)-1 step 1
StringReplace($sData,$aContent[$i],"")
next
FileDelete("pfad von $sFile2")
FileWrite("pfad von $sFile2",$sData)Müsste funktionieren.
-
Nur so als Idee:
Ich würde es so machen, dass ich z.B. in einer Text-Datei einen Pfad angeben würde, der auf die jeweilige Datei verweist. Ins Autostart packst du ne andere Exe, die den Pfad aus der txt ausliest und dann das Programm unter dem Pfad öffnet. Dadurch kannst du einfach ne andere Exe erstellen, den Dateinamen der zweiten exe geringfügig ändern und dann in die txt schreiben. Nach ner bestimmten Zeit, wenn keiner mehr auf die alte exe zugreift kannst du dann diese löschen, etc.Optional:
Statt txt-datei kannst du auch nen Registry eintrag anlegen,... Da gibts mehrere Möglichkeiten.Viel Glück noch!
-
Hmmm. Ich finds schade, dass es da von Autoit so keine Lösung gibt...
Ich werds jetzt mit ner extra Liste machen, die dann mit FTP-Client oder mit anderer ordner-Verarbeitung kopiert wird...
Trotzdem: Danke für deine Hilfe und Mühe
-
So. Hier ein lauffähiges Programm, wie ich es Verwende:
Die Koordinaten habe ich angefügt. Es funktioniert aber trotzdem nur beim Notepad.
Wenn ich die $cID einfüge funktioniert es nichteinmal beim Notepad (weiß aber nicht, wie ich die control sonst angeben könnte).Beim Explorer funktionieren auch die Methoden unter _MouseUp() nicht.
Zum testen benutze ich SciTe, Explorer, Filezilla.
Ich hoffe, du kannst mir beim anpassen des Scriptes helfen.Spoiler anzeigen
[autoit]#include "MouseOnEvent.au3"
[/autoit] [autoit][/autoit] [autoit]
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)Global $pos1 = MouseGetPos(),$pos2 = MouseGetPos(),$appHandle = 0,$mouseDown=false
[/autoit] [autoit][/autoit] [autoit]
_MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "_MouseUp")
_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_MouseDown")$MainGui = GUICreate("Bücherverwaltung", 800, 600, -1, -1,$WS_CAPTION +$WS_SYSMENU+ $WS_SIZEBOX +$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX,$WS_EX_ACCEPTFILES)
[/autoit] [autoit][/autoit] [autoit]
$MainGui_MainListView = GUICtrlCreateListView("Pfad", 10, 10,790 ,570 )
GUICtrlSetResizing ( -1, 102 )
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlCreateListViewItem("C:\Test\Test1.epub",$MainGui_MainListView)
GUICtrlCreateListViewItem("C:\Test\Test2.epub",$MainGui_MainListView)
GUICtrlCreateListViewItem("C:\Test\Test3.epub",$MainGui_MainListView)
GUISetState(@SW_SHOW)GUISetOnEvent($GUI_EVENT_CLOSE, "MainGui_Close")
[/autoit] [autoit][/autoit] [autoit]while 1
[/autoit] [autoit][/autoit] [autoit]
sleep(100)
WEndFunc MainGui_Close()
[/autoit] [autoit][/autoit] [autoit]
exit
EndFuncFunc _MouseDown()
[/autoit] [autoit][/autoit] [autoit]
$mouseDown=_Mouse_Control_GetInfoAdlib()
EndFuncFunc _MouseUp()
[/autoit] [autoit][/autoit] [autoit]
if $mouseDown then
;If _IsMouseInWindow() = False Then
if _GUICtrlListView_GetSelectionMark (GUICtrlGetHandle($MainGui_MainListView))<>-1 then
$mousePos = MouseGetPos()
$wInfo = _WinInfoFromPoint($mousePos[0], $mousePos[1])
$pfadtmp=_GUICtrlListView_GetItemText(GUICtrlGetHandle($MainGui_MainListView),_GUICtrlListView_GetSelectionMark (GUICtrlGetHandle($MainGui_MainListView)),0)
;@Scriptdir&MainGetDataRet("Select path as pfad from Buecher where id="&int(_GUICtrlListView_GetItemText(GUICtrlGetHandle($MainGui_MainListView),_GUICtrlListView_GetSelectionMark (GUICtrlGetHandle($MainGui_MainListView)),0)))[2]
If $wInfo[1] = "SysListView32" And $wInfo[3] = "Progman" Then
;Detect Desktop
FileCopy($pfadtmp , @DesktopDir)
msgbox(48,"","filecopy")
ElseIf $wInfo[1] = "SysListView32" And $wInfo[3] = "CabinetWClass" Then
;Detect Explorer.exe Window!!!
$oldData = _ClipBoard_GetData()
$newData = _ClipPutFile($pfadtmp)
$conSend = ControlSend($wInfo[4], "", "SysListView321", "Paste: ^v")
Sleep(1000)
_ClipBoard_SetData($oldData)
;DoDropFiles($wInfo[4], "C:\testfile.txt") - Doesn't Work
msgbox(48,"","controlSend")
Else
DoDropFiles($wInfo[4], $pfadtmp)
;msgbox(48,"","DoDropFiles")
EndIf
EndIf
;_Mouse_Control_GetInfoAdlib(@Scriptdir&MainGetDataRet("Select path as pfad from Buecher where id="&int(_GUICtrlListView_GetItemText(GUICtrlGetHandle($MainGui_MainListView),_GUICtrlListView_GetSelectionMark (GUICtrlGetHandle($MainGui_MainListView)),0)))[2])
$mouseDown=false
endif
EndFuncFunc _Mouse_Control_GetInfoAdlib($Files=-1)
[/autoit] [autoit][/autoit] [autoit]
if $Files<>-1 then
$pos1 = MouseGetPos()
;If $pos1[0] <> $pos2[0] Or $pos1[1] <> $pos2[1] Then ; has the mouse moved?
Local $a_info = _Mouse_Control_GetInfo()
Local $aDLL = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $a_info[0]) ; get the ID of the control
If @error Then Return
$GuiWhnd=WinGetHandle("Bücherverwaltung")
if _WinAPI_GetAncestor($appHandle, $GA_ROOT)<>$GuiWhnd then
DoDropFiles(_WinAPI_GetAncestor($appHandle, $GA_ROOT), $Files,$aDLL[0])
endif
#cs
ToolTip("Handle = " & $a_info[0] & @CRLF & _
"Class = " & $a_info[1] & @CRLF & _
"ID = " & $aDLL[0] & @CRLF & _
"Mouse X Pos = " & $a_info[2] & @CRLF & _
"Mouse Y Pos = " & $a_info[3] & @CRLF & _
"ClassNN = " & $a_info[4] & @CRLF & _ ; optional
"Parent Hwd = " & _WinAPI_GetAncestor($appHandle, $GA_ROOT))
#ce
;$pos2 = MouseGetPos()
;EndIf
else
$pos1 = MouseGetPos()
Local $a_info = _Mouse_Control_GetInfo()
Local $aDLL = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $a_info[0]) ; get the ID of the control
If @error Then Return
$GuiWhnd=WinGetHandle("Bücherverwaltung")
if _WinAPI_GetAncestor($appHandle, $GA_ROOT)=$GuiWhnd then
return true
endif
endif
EndFunc ;==>_Mouse_Control_GetInfoAdlibFunc _Mouse_Control_GetInfo()
[/autoit] [autoit][/autoit] [autoit]
Local $client_mpos = $pos1 ; gets client coords because of "MouseCoordMode" = 2
Local $a_mpos
;~ Call to removed due to offset issue $a_mpos = _ClientToScreen($appHandle, $client_mpos[0], $client_mpos[1]) ; $a_mpos now screen coords
$a_mpos = $client_mpos
$appHandle = GetHoveredHwnd($client_mpos[0], $client_mpos[1]) ; Uses the mouse to do the equivalent of WinGetHandle()If @error Then Return SetError(1, 0, 0)
[/autoit] [autoit][/autoit] [autoit]
Local $a_wfp = DllCall("user32.dll", "hwnd", "WindowFromPoint", "long", $a_mpos[0], "long", $a_mpos[1]) ; gets the control handle
If @error Then Return SetError(2, 0, 0)Local $t_class = DllStructCreate("char[260]")
[/autoit] [autoit][/autoit] [autoit]
DllCall("User32.dll", "int", "GetClassName", "hwnd", $a_wfp[0], "ptr", DllStructGetPtr($t_class), "int", 260)
Local $a_ret[5] = [$a_wfp[0], DllStructGetData($t_class, 1), $a_mpos[0], $a_mpos[1], "none"]
Local $sClassNN = _ControlGetClassnameNN($a_ret[0]) ; optional, will run faster without it
$a_ret[4] = $sClassNNReturn $a_ret
[/autoit] [autoit][/autoit] [autoit]
EndFunc ;==>_Mouse_Control_GetInfo; ===============================================================================
[/autoit] [autoit][/autoit] [autoit]
; Retrieves the Handle of GUI/Application the mouse is over.
; Similar to WinGetHandle except it used the current mouse position
; Taken from <a href='http://www.autoitscript.com/forum/index.php?showtopic=444962' class='bbc_url' title=''>http://www.autoitscript.com/forum/index.php?showtopic=444962</a>
; Changed to take params to allow only one set of coords to be used.
; Params
;~ $i_xpos - x position of the mouse - usually from MouseGetPos(0)
;~ $i_ypos - x position of the mouse - usually from MouseGetPos(1)
; ===============================================================================
Func GetHoveredHwnd($i_xpos, $i_ypos)
Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", "long", $i_xpos, "long", $i_ypos)
If IsArray($iRet) Then
$appHandle = $iRet[0]
Return HWnd($iRet[0])
Else
Return SetError(1, 0, 0)
EndIf
EndFunc ;==>GetHoveredHwnd; ===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;~ Gets the ClassNN of a control (Classname and Instance Count). This is checked with ControlGetHandle
;~ The instance is really a way to uniquely identify classes with the same name
;~ Big thanks to Valik for writing the function, taken from - <a href='http://www.autoitscript.com/forum/index.php?showtopic=97662' class='bbc_url' title=''>http://www.autoitscript.com/forum/index.php?showtopic=97662</a>
;~ Param
;~ $hControl - the control handle from which you want the ClassNN
;~ Returns
;~ the ClassNN of the given control; ===============================================================================
[/autoit] [autoit][/autoit] [autoit]
Func _ControlGetClassnameNN($hControl)
If Not IsHWnd($hControl) Then Return SetError(1, 0, "")
Local Const $hParent = _WinAPI_GetAncestor($appHandle, $GA_ROOT) ; get the Window handle, this is set in GetHoveredHwnd()
If Not $hParent Then Return SetError(2, 0, "")Local Const $sList = WinGetClassList($hParent) ; list of every class in the Window
[/autoit] [autoit][/autoit] [autoit]
Local $aList = StringSplit(StringTrimRight($sList, 1), @LF, 2)
_ArraySort($aList) ; improves speed
Local $nInstance, $sLastClass, $sCompositeFor $i = 0 To UBound($aList) - 1
[/autoit] [autoit][/autoit] [autoit]
If $sLastClass <> $aList[$i] Then ; set up the first occurrence of a unique classname
$sLastClass = $aList[$i]
$nInstance = 1
EndIf
$sComposite = $sLastClass & $nInstance ;build the ClassNN for testing with ControlGetHandle. ClassNN = Class & ClassCount
;if ControlGetHandle(ClassNN) matches the given control return else look at the next instance of the classname
If ControlGetHandle($hParent, "", $sComposite) = $hControl Then
Return $sComposite
EndIf
$nInstance += 1 ; count the number of times the class name appears in the list
Next
Return SetError(3, 0, "")EndFunc ;==>_ControlGetClassnameNN
[/autoit] [autoit][/autoit] [autoit]Func DoDropFiles($wnd, $Files)
[/autoit] [autoit][/autoit] [autoit]
Local $tagStruct1, $dummy, $hGlobal, $pDropFiles, $DropFiles, $Size
;$wnd is the handle of the control we are dropping onto
;$Files is the list of files separated by "|"
$tagStruct1 = "int offset;int px;int py;wchar fNC;wchar fWide"
$dummy = DllStructCreate($tagStruct1);grab some memory
[/autoit] [autoit][/autoit] [autoit]
$hGlobal = _MemGlobalAlloc(DllStructGetSize($dummy) + StringLen($Files) + 2)
;DropFiles := GlobalLock(MemHandle)
;translates the memory handle to a pointer
$pDropFiles = _MemGlobalLock($hGlobal)
;create the struct in this memory
$DropFiles = DllStructCreate($tagStruct1 & ";char filelist[" & StringLen($Files) + 2 & "]", $pDropFiles)
DllStructSetData($DropFiles, "offset", DllStructGetSize($dummy))
$dummy = 0; done its job
DllStructSetData($DropFiles, "px", 0);tried setting a point inside Notepad
DllStructSetData($DropFiles, "py", 0);but it makes no difference
DllStructSetData($DropFiles, "fwide", 0)
DllStructSetData($DropFiles, "fNC", 0)
DllStructSetData($DropFiles, "filelist", $Files)
;set the nulls in place of the separaters
$Size = 0;
$Files = StringSplit($Files, "|")
For $I = 1 To $Files[0];// number of characters per string (as ANSI) plus one #0 terminator
[/autoit] [autoit][/autoit] [autoit]
;Inc(Size, Length(Files[I]) + 1);
$Size += StringLen($Files[$I]) + 1
DllStructSetData($DropFiles, "filelist", 0, $Size)
Next
;ConsoleWrite(DllStructGetData($DropFiles, "filelist") & @CRLF)
;now add the extra null to terminate the list of strings
DllStructSetData($DropFiles, "filelist", 0, $Size + 1)
_MemGlobalUnlock($hGlobal)
_WinAPI_PostMessage($wnd, $WM_DROPFILES, $hGlobal, 0);
;// ... and finally release the memory_MemGlobalFree($hGlobal)
[/autoit] [autoit][/autoit] [autoit]
EndFunc ;==>DoDropFilesFunc _WinInfoFromPoint($nX, $nY);by Saio
[/autoit] [autoit][/autoit] [autoit]
Local $tStrBuff, $pStrBuff, $aRet, $hWnd, $hOwnerWnd, $sClassName, $sOwnerClass, $sWinText
$tStrBuff = DllStructCreate("char[100]")
$pStrBuff = DllStructGetPtr($tStrBuff)
$aRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", $nX, "uint", $nY)
$hWnd = $aRet[0]
$aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100)
$sClassName = DllStructGetData($tStrBuff, 1)
DllStructSetData($tStrBuff, 1, "")
DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100)
;~ DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "uint", $WM_GETTEXT, "uint", 100, "ptr", $pStrBuff)
$sWinText = DllStructGetData($tStrBuff, 1)
DllStructSetData($tStrBuff, 1, "")
$aRet = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hWnd, "uint", 2);$GA_ROOT = 2
$hOwnerWnd = $aRet[0]
$aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hOwnerWnd, "ptr", $pStrBuff, "int", 100)
$sOwnerClass = DllStructGetData($tStrBuff, 1)
DllStructSetData($tStrBuff, 1, "")Local $Array[5] = [$sWinText, $sClassName, $hWnd, $sOwnerClass, $hOwnerWnd]
[/autoit] [autoit][/autoit] [autoit];Window Text: $sWinText | $Array[0]
[/autoit] [autoit][/autoit] [autoit]
;ClassName: $sClassName | $Array[1]
;Window Handle: $hWnd | $Array[2]
;Owner ClassName: $sOwnerClass | $Array[3]
;Owner Handle: $hOwnerWnd | $Array[4]
#cs
ConsoleWrite(@CRLF & "{ WinInfo }" & @CRLF)
ConsoleWrite("Window Text: " & $sWinText & @CRLF)
ConsoleWrite("ClassName: " & $sClassName & @CRLF)
ConsoleWrite("Window Handle: " & $hWnd & @CRLF)
ConsoleWrite("Owner ClassName: " & $sOwnerClass & @CRLF)
ConsoleWrite("Owner Handle: " & $hOwnerWnd & @CRLF)
ConsoleWrite("{ WinInfo }" & @CRLF & @CRLF)
#ce
Return $ArrayEndFunc ;==>_WinInfoFromPoint
[/autoit]Eingebunden wird dabei die "MouseOnEvent.au3":
Spoiler anzeigen
[autoit]#Region Header
[/autoit] [autoit][/autoit] [autoit]#CS
[/autoit] [autoit][/autoit] [autoit]Title: MouseOnEvent UDF
[/autoit] [autoit][/autoit] [autoit]
Filename: MouseOnEvent.au3
Description: Set an events handler (a hook) for Mouse device.
Author: G.Sandler a.k.a (Mr)CreatoR (CreatoR's Lab - http://creator-lab.ucoz.ru, http://autoit-script.ru)
Version: 1.9
Requirements: AutoIt v3.3.6.1 +, Developed/Tested on Windows XP (rus) Service Pack 2/3, Win 7, with standard 3-buttons mouse device
Uses: WindowsConstants.au3, WinAPI.au3, Timers.au3
Forum Link: http://www.autoitscript.com/forum/index.php?showtopic=64738
Notes:
1) The original events-messages (such as $WM_MOUSEMOVE) can be used as well.
2) Blocking $sFuncName function with commands such as "Msgbox()" can lead to unexpected behavior,
the return to the system should be as fast as possible!
3) When $MOUSE_PRIMARYDOWN_EVENT and $MOUSE_SECONDARYDOWN_EVENT are set,
the $MOUSE_PRIMARYDBLCLK_EVENT and $MOUSE_SECONDARYDBLCLK_EVENT events are also set by force,
to unset these events use _MouseSetOnEvent($MOUSE_PRIMARYDBLCLK_EVENT or $MOUSE_SECONDARYDBLCLK_EVENT).
4) When using obfuscator, make sure to add event functions to ignore list (#Obfuscator_Ignore_Funcs).
ChangLog:
v1.9 [22.07.2012]
* Script breaking version!
* Dropped AutoIt 3.3.0.0 support.
* Instead of $sParam1 and $sParam2, now $vParam used as last parameter.
* Event function ($sFuncName) now called with $iEvent as first parameter, and $vParam as second (both optional).
* Now $iBlockDefProc is set to -1 by default (event function can define whether to block event process or not, simply by returning 1 or 0).
* Fixed not working $MOUSE_PRIMARYDBLCLK_EVENT and $MOUSE_SECONDARYDBLCLK_EVENT,
now handled manually because windows does not always receive these events (depending on CS_DBLCLKS style).
(not tested properly, so these events will have "experimental" label for now).
* Fixed error related to "Subscript used with non-Array variable", caused when window with handle of $hTargetWnd parameter is not found (window closed).
* Examples updated.
v1.8 [02.06.2010]
* Fixed an issue with wrong handling when $MOUSE_XBUTTONUP/DOWN_EVENT and few other events are set.
* Fixed an issue when user attempts to set other function for the event that already have been set.
Now the function and other parameters are replaced for the current event.
* UDF file renamed (removed "Set" in the middle and "_UDF" at the end of the name).
* Cosmetic changes in the UDF code.
* Docs updated.
v1.7 [14.10.2009]
* Stability fixes. Thanks again to wraithdu.
v1.6 [13.10.2009]
* Fixed an issue with releasing the resources of mouse hook. Thanks to wraithdu.
v1.5 [09.10.2009]
+ Added wheel button up/down *scrolling* event recognition.
Thanks to JRowe (http://www.autoitscript.com/forum/index.php?showtopic=103362).
* Fixed an issue with returning value from __MouseSetOnEvent_MainHandler - should call _WinAPI_CallNextHookEx before return.
* Constants starting with MOUSE_EXTRABUTTON* renamed to MOUSE_XBUTTON*, as it should be in the first place.
* Few examples updated.
v1.4 [30.09.2009]
+ Added UDF header to the function.
+ Now the original events-messages (such as $WM_MOUSEMOVE) can be used as well.
+ Added missing events (althought i am not sure if they are still supported)
$MOUSE_PRIMARYDBLCLK_EVENT - Primary mouse button double click.
$MOUSE_SECONDARYDBLCLK_EVENT - Secondary mouse button double click.
$MOUSE_WHEELDBLCLK_EVENT - Wheel mouse button double click.
$MOUSE_EXTRABUTTONDBLCLK_EVENT - Side mouse button double click.
* Changed global vars and internal functions names to be more unique.
* Fixed variables declaration and misspelling.
v1.3 [27.10.2008]
* Added optional parameter $iBlockDefProc - Define wether the Mouse events handler will block the default processing or not (Default is 1, block).
If this is -1, then user can Return from the event function to set processing operation (see the attached example «AutoDrag Window.au3»).
v1.2 [05.04.2008]
* Added: [Optional] parameter $hTargetWnd, if set, the OnEvent function will be called only on $hTargetWnd window, otherwise will be standard Event processing.
Note: Can be a little(?) buggy when you mix different events.
v1.1 [22.03.2008]
* Fixed: Incorrect ReDim when remove event from the array, it was causing UDF to crash script with error.
* Spell/Grammar corrections
* Added: An example of _BlockMouseClicksInput().
v1.0 [21.02.2008]
* First public release.
#CE#include-once
[/autoit] [autoit][/autoit] [autoit]
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Timers.au3>OnAutoItExitRegister('__MouseSetOnEvent_OnExitFunc')
[/autoit] [autoit][/autoit] [autoit]#EndRegion Header
[/autoit] [autoit][/autoit] [autoit]#Region Global Constants and Variables
[/autoit] [autoit][/autoit] [autoit]Global $a__MSOE_Events[1][1]
[/autoit] [autoit][/autoit] [autoit]
Global $h__MSOE_MouseProc = -1
Global $h__MSOE_MouseHook = -1
Global $i__MSOE_EventReturn = 1
Global $h__MSOE_Hook_Timer = 0
Global $h__MSOE_PrmDblClk_Timer = 0
Global $h__MSOE_ScnDblClk_Timer = 0
Global $i__MSOE_PrmDblClk_Timer = 0
Global $i__MSOE_ScnDblClk_Timer = 0
Global $a__MSOE_PrmDblClk_LastMPos[2]
Global $a__MSOE_ScnDblClk_LastMPos[2]
Global $a__MSOE_DblClk_Data = __MouseSetOnEvent_GetDoubleClickData()#EndRegion Global Constants and Variables
[/autoit] [autoit][/autoit] [autoit]#Region Public Constants
[/autoit] [autoit][/autoit] [autoit]Global Const $MOUSE_MOVE_EVENT = 0x200 ;512 (WM_MOUSEMOVE) ; ==> Mouse moving.
[/autoit] [autoit][/autoit] [autoit]
Global Const $MOUSE_PRIMARYDOWN_EVENT = 0x201 ;513 (WM_LBUTTONDOWN) ; ==> Primary mouse button down.
Global Const $MOUSE_PRIMARYUP_EVENT = 0x202 ;514 (WM_LBUTTONUP) ; ==> Primary mouse button up.
Global Const $MOUSE_PRIMARYDBLCLK_EVENT = 0x203 ;515 (WM_LBUTTONDBLCLK) ; ==> Primary mouse button double click.
Global Const $MOUSE_SECONDARYDOWN_EVENT = 0x204 ;516 (WM_RBUTTONDOWN) ; ==> Secondary mouse button down.
Global Const $MOUSE_SECONDARYUP_EVENT = 0x205 ;517 (WM_RBUTTONUP) ; ==> Secondary mouse button up.
Global Const $MOUSE_SECONDARYDBLCLK_EVENT = 0x206 ;518 (WM_RBUTTONDBLCLK) ; ==> Secondary mouse button double click.
Global Const $MOUSE_WHEELDOWN_EVENT = 0x207 ;519 (WM_MBUTTONDOWN) ; ==> Wheel mouse button pressed down.
Global Const $MOUSE_WHEELUP_EVENT = 0x208 ;520 (WM_MBUTTONUP) ; ==> Wheel mouse button up.
Global Const $MOUSE_WHEELDBLCLK_EVENT = 0x209 ;521 (WM_MBUTTONDBLCLK) ; ==> Wheel mouse button double click.
Global Const $MOUSE_WHEELSCROLL_EVENT = 0x20A ;522 (WM_MOUSEWHEEL) ; ==> Wheel mouse scroll.
Global Const $MOUSE_WHEELSCROLLDOWN_EVENT = 0x20A + 8 ;530 (WM_MOUSEWHEEL +; ==> Wheel mouse scroll Down.
Global Const $MOUSE_WHEELSCROLLUP_EVENT = 0x20A + 16 ;538 (WM_MOUSEWHEEL + 16) ; ==> Wheel mouse scroll Up.
Global Const $MOUSE_XBUTTONDOWN_EVENT = 0x20B ;523 (WM_XBUTTONDOWN) ; ==> Side mouse button down (usually navigating next/back buttons).
Global Const $MOUSE_XBUTTONUP_EVENT = 0x20C ;524 (WM_XBUTTONUP) ; ==> Side mouse button up.
Global Const $MOUSE_XBUTTONDBLCLK_EVENT = 0x20D ;525 (WM_XBUTTONDBLCLK) ; ==> Side mouse button double click.#EndRegion Public Constants
[/autoit] [autoit][/autoit] [autoit]#Region Public Functions
[/autoit] [autoit][/autoit] [autoit]; #FUNCTION# ====================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: _MouseSetOnEvent
; Description....: Set an events handler (a hook) for Mouse device.
; Syntax.........: _MouseSetOnEvent($iEvent, $sFuncName = "", $hTargetWnd = 0, $iBlockDefProc = -1, $vParam = "")
; Parameters.....: $iEvent - The event to set, here is the list of supported events:
; $MOUSE_MOVE_EVENT - Mouse moving.
; $MOUSE_PRIMARYDOWN_EVENT - Primary mouse button down.
; $MOUSE_PRIMARYUP_EVENT - Primary mouse button up.
; $MOUSE_PRIMARYDBLCLK_EVENT - Primary mouse button double click.
; $MOUSE_SECONDARYDOWN_EVENT - Secondary mouse button down.
; $MOUSE_SECONDARYUP_EVENT - Secondary mouse button up.
; $MOUSE_SECONDARYDBLCLK_EVENT - Secondary mouse button double click.
; $MOUSE_WHEELDOWN_EVENT - Wheel mouse button pressed down.
; $MOUSE_WHEELUP_EVENT - Wheel mouse button up.
; $MOUSE_WHEELDBLCLK_EVENT - Wheel mouse button double click.
; $MOUSE_WHEELSCROLL_EVENT - Wheel mouse scroll.
; $MOUSE_WHEELSCROLLDOWN_EVENT - Wheel mouse scroll *Down*.
; $MOUSE_WHEELSCROLLUP_EVENT - Wheel mouse scroll *Up*.
; $MOUSE_XBUTTONDOWN_EVENT - Side mouse button down (usualy navigating next/back buttons).
; $MOUSE_XBUTTONUP_EVENT - Side mouse button up.
; $MOUSE_XBUTTONDBLCLK_EVENT - Side mouse button double click.
;
; $sFuncName - [Optional] Function name to call when the event is triggered.
; If this parameter is empty string ("") or omited, the function will *unset* the $iEvent.
; $hTargetWnd - [Optional] Window handle to set the event for, e.g the event is set only for this window.
; $iBlockDefProc - [Optional] Defines if the event should be blocked (actualy block the mouse action).
; If this parameter = -1 (default), then event function can define whether to block event process or not, simply by returning 1 or 0.
; $vParam - [Optional] Parameter to pass to the event function ($sFuncName).
;
; Return values..: Success - If the event is set in the first time, or when the event is unset properly, the return is 1,
; if it's set on existing event, the return is 2.
; Failure - Returns 0 on UnSet event mode when there is no set events yet.
; Author.........: G.Sandler ((Mr)CreatoR, CreatoR's Lab - http://creator-lab.ucoz.ru, http://autoit-script.ru)
; Modified.......:
; Remarks........: 1) The original events-messages (such as $WM_MOUSEMOVE) can be used as well.
; 2) Blocking of $sFuncName function by window messages with commands
; such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible!
; Related........:
; Link...........: http://www.autoitscript.com/forum/index.php?showtopic=64738
; Example........: Yes.
; ===============================================================================================================
Func _MouseSetOnEvent($iEvent, $sFuncName = "", $hTargetWnd = 0, $iBlockDefProc = -1, $vParam = "")
If $sFuncName = "" Then ;Unset Event
If $a__MSOE_Events[0][0] < 1 Then
Return 0
EndIf
Local $aTmp_Mouse_Events[1][1] = [[0]]
For $i = 1 To $a__MSOE_Events[0][0]
If $a__MSOE_Events[$i][0] <> $iEvent Then
$aTmp_Mouse_Events[0][0] += 1
ReDim $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]+1][5]
$aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][0] = $a__MSOE_Events[$i][0]
$aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][1] = $a__MSOE_Events[$i][1]
$aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][2] = $a__MSOE_Events[$i][2]
$aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][3] = $a__MSOE_Events[$i][3]
$aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][4] = $a__MSOE_Events[$i][4]
EndIf
Next
$a__MSOE_Events = $aTmp_Mouse_Events
If $a__MSOE_Events[0][0] < 1 Then
If $i__MSOE_EventReturn = 1 Then
__MouseSetOnEvent_OnExitFunc()
ElseIf $i__MSOE_EventReturn = 0 Then
$h__MSOE_Hook_Timer = _Timer_SetTimer(0, 10, "__MouseSetOnEvent_WaitHookReturn")
EndIf
EndIf
Return 1
EndIf
;First event
If $a__MSOE_Events[0][0] < 1 Then
$h__MSOE_MouseProc = DllCallbackRegister("__MouseSetOnEvent_MainHandler", "int", "int;ptr;ptr")
$h__MSOE_MouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($h__MSOE_MouseProc), _WinAPI_GetModuleHandle(0), 0)
EndIf
;Search thru events, and if the event already set, we just (re)set the new function and other parameters
For $i = 1 To $a__MSOE_Events[0][0]
If $a__MSOE_Events[$i][0] = $iEvent Then
$a__MSOE_Events[$i][0] = $iEvent
$a__MSOE_Events[$i][1] = $sFuncName
$a__MSOE_Events[$i][2] = $hTargetWnd
$a__MSOE_Events[$i][3] = $iBlockDefProc
$a__MSOE_Events[$i][4] = $vParam
Return 2
EndIf
Next
$a__MSOE_Events[0][0] += 1
ReDim $a__MSOE_Events[$a__MSOE_Events[0][0]+1][5]
$a__MSOE_Events[$a__MSOE_Events[0][0]][0] = $iEvent
$a__MSOE_Events[$a__MSOE_Events[0][0]][1] = $sFuncName
$a__MSOE_Events[$a__MSOE_Events[0][0]][2] = $hTargetWnd
$a__MSOE_Events[$a__MSOE_Events[0][0]][3] = $iBlockDefProc
$a__MSOE_Events[$a__MSOE_Events[0][0]][4] = $vParam
;Add primary/secondary double click event, if needed can be disabled later
If $iEvent = $MOUSE_PRIMARYDOWN_EVENT Then
_MouseSetOnEvent($MOUSE_PRIMARYDBLCLK_EVENT, $sFuncName, $hTargetWnd, $iBlockDefProc, $vParam)
EndIf
If $iEvent = $MOUSE_SECONDARYDOWN_EVENT Then
_MouseSetOnEvent($MOUSE_SECONDARYDBLCLK_EVENT, $sFuncName, $hTargetWnd, $iBlockDefProc, $vParam)
EndIf
Return 1
EndFunc#EndRegion Public Functions
[/autoit] [autoit][/autoit] [autoit]#Region Internal Functions
[/autoit] [autoit][/autoit] [autoit]Func __MouseSetOnEvent_MainHandler($nCode, $wParam, $lParam)
[/autoit] [autoit][/autoit] [autoit]
If $nCode < 0 Then
Return _WinAPI_CallNextHookEx($h__MSOE_MouseHook, $nCode, $wParam, $lParam) ;Continue processing
EndIf
Local $iEvent = _WinAPI_LoWord($wParam)
Local $iRet
Local $iBlockDefProc_Ret
Local $iWScrollDirection = 0
If $a__MSOE_Events[0][0] < 1 Then
Return 0
EndIf
Switch $iEvent
Case $MOUSE_WHEELSCROLL_EVENT
Local Const $stMSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo"
Local $tWheel_Struct = DllStructCreate($stMSLLHOOKSTRUCT, $lParam)
$iWScrollDirection = _WinAPI_HiWord(DllStructGetData($tWheel_Struct, 3))
Case $MOUSE_PRIMARYDOWN_EVENT
If $i__MSOE_PrmDblClk_Timer = 0 Then
$i__MSOE_PrmDblClk_Timer = TimerInit()
$a__MSOE_PrmDblClk_LastMPos = MouseGetPos()
$h__MSOE_PrmDblClk_Timer = _Timer_SetTimer(0, $a__MSOE_DblClk_Data[0] + 50, '__MouseSetOnEvent_DoubleClickExpire')
ElseIf $i__MSOE_PrmDblClk_Timer > 0 Then
If TimerDiff($i__MSOE_PrmDblClk_Timer) <= $a__MSOE_DblClk_Data[0] Then
Local $aCurrentMPos = MouseGetPos()
Local $iDC_Width = $aCurrentMPos[0] - $a__MSOE_PrmDblClk_LastMPos[0]
If $a__MSOE_PrmDblClk_LastMPos[0] > $aCurrentMPos[0] Then $iDC_Width = $a__MSOE_PrmDblClk_LastMPos[0] - $aCurrentMPos[0]
Local $iDC_Height = $aCurrentMPos[1] - $a__MSOE_PrmDblClk_LastMPos[1]
If $a__MSOE_PrmDblClk_LastMPos[1] > $aCurrentMPos[1] Then $iDC_Height = $a__MSOE_PrmDblClk_LastMPos[1] - $aCurrentMPos[1]
If $iDC_Width <= $a__MSOE_DblClk_Data[1] And $iDC_Height <= $a__MSOE_DblClk_Data[2] Then
$iEvent = $MOUSE_PRIMARYDBLCLK_EVENT
EndIf
EndIf
$i__MSOE_PrmDblClk_Timer = 0
EndIf
Case $MOUSE_SECONDARYDOWN_EVENT
If $i__MSOE_ScnDblClk_Timer = 0 Then
$i__MSOE_ScnDblClk_Timer = TimerInit()
$a__MSOE_ScnDblClk_LastMPos = MouseGetPos()
$h__MSOE_ScnDblClk_Timer = _Timer_SetTimer(0, $a__MSOE_DblClk_Data[0] + 50, '__MouseSetOnEvent_DoubleClickExpire')
ElseIf $i__MSOE_ScnDblClk_Timer > 0 Then
If TimerDiff($i__MSOE_ScnDblClk_Timer) <= $a__MSOE_DblClk_Data[0] Then
Local $aCurrentMPos = MouseGetPos()
Local $iDC_Width = $aCurrentMPos[0] - $a__MSOE_ScnDblClk_LastMPos[0]
If $a__MSOE_ScnDblClk_LastMPos[0] > $aCurrentMPos[0] Then $iDC_Width = $a__MSOE_ScnDblClk_LastMPos[0] - $aCurrentMPos[0]
Local $iDC_Height = $aCurrentMPos[1] - $a__MSOE_ScnDblClk_LastMPos[1]
If $a__MSOE_ScnDblClk_LastMPos[1] > $aCurrentMPos[1] Then $iDC_Height = $a__MSOE_ScnDblClk_LastMPos[1] - $aCurrentMPos[1]
If $iDC_Width <= $a__MSOE_DblClk_Data[1] And $iDC_Height <= $a__MSOE_DblClk_Data[2] Then
$iEvent = $MOUSE_SECONDARYDBLCLK_EVENT
EndIf
EndIf
$i__MSOE_ScnDblClk_Timer = 0
EndIf
EndSwitch
For $i = 1 To $a__MSOE_Events[0][0]
If $a__MSOE_Events[$i][0] = $iEvent Or $iWScrollDirection <> 0 Then
;Handle wheel scroll up/down
If $iEvent = $MOUSE_WHEELSCROLL_EVENT And ($a__MSOE_Events[$i][0] = $MOUSE_WHEELSCROLL_EVENT Or $a__MSOE_Events[$i][0] = $MOUSE_WHEELSCROLLUP_EVENT Or $a__MSOE_Events[$i][0] = $MOUSE_WHEELSCROLLDOWN_EVENT) Then
If $iWScrollDirection > 0 And $a__MSOE_Events[$i][0] = $MOUSE_WHEELSCROLLUP_EVENT Then
$iEvent = $MOUSE_WHEELSCROLLUP_EVENT
ElseIf $iWScrollDirection < 0 And $a__MSOE_Events[$i][0] = $MOUSE_WHEELSCROLLDOWN_EVENT Then
$iEvent = $MOUSE_WHEELSCROLLDOWN_EVENT
ElseIf $a__MSOE_Events[$i][0] = $MOUSE_WHEELSCROLLUP_EVENT Or $a__MSOE_Events[$i][0] = $MOUSE_WHEELSCROLLDOWN_EVENT Then
ContinueLoop
EndIf
ElseIf $iWScrollDirection <> 0 Then
ContinueLoop
EndIf
If $a__MSOE_Events[$i][2] <> 0 And Not __MouseSetOnEvent_IsHoveredWnd($a__MSOE_Events[$i][2]) Then
Return 0 ;Allow default processing
EndIf
$i__MSOE_EventReturn = 0
$iBlockDefProc_Ret = $a__MSOE_Events[$i][3]
$iRet = Call($a__MSOE_Events[$i][1], $iEvent, $a__MSOE_Events[$i][4])
If @error Then
$iRet = Call($a__MSOE_Events[$i][1], $iEvent)
If @error Then
$iRet = Call($a__MSOE_Events[$i][1])
EndIf
EndIf
$i__MSOE_EventReturn = 1
If $iBlockDefProc_Ret = -1 Then
$iBlockDefProc_Ret = $iRet
EndIf
Return $iBlockDefProc_Ret ;Block default processing (or not :))
EndIf
Next
Return _WinAPI_CallNextHookEx($h__MSOE_MouseHook, $nCode, $wParam, $lParam) ;Continue processing
EndFuncFunc __MouseSetOnEvent_WaitHookReturn($hWnd, $iMsg, $iIDTimer, $dwTime)
[/autoit] [autoit][/autoit] [autoit]
If $i__MSOE_EventReturn = 1 Then
_Timer_KillTimer(0, $h__MSOE_Hook_Timer)
__MouseSetOnEvent_OnExitFunc()
EndIf
EndFuncFunc __MouseSetOnEvent_IsHoveredWnd($hWnd)
[/autoit] [autoit][/autoit] [autoit]
;~ Local $iRet = False
;~
;~ Local $aWin_Pos = WinGetPos($hWnd)
;~ Local $aMouse_Pos = MouseGetPos()
;~
;~ If Not IsArray($aWin_Pos) Then
;~ Return SetError(1, 0, False)
;~ EndIf
;~
;~ If $aMouse_Pos[0] >= $aWin_Pos[0] And $aMouse_Pos[0] <= ($aWin_Pos[0] + $aWin_Pos[2]) And _
;~ $aMouse_Pos[1] >= $aWin_Pos[1] And $aMouse_Pos[1] <= ($aWin_Pos[1] + $aWin_Pos[3]) Then
;~ $iRet = True
;~ EndIf
;~
;~ Local $aRet = DllCall("User32.dll", "hwnd", "WindowFromPoint", "long", $aMouse_Pos[0], "long", $aMouse_Pos[1])
;~
;~ If HWnd($aRet[0]) <> $hWnd And Not $iRet Then
;~ $iRet = False
;~ EndIf
Local $tPoint = _WinAPI_GetMousePos()
Return _WinAPI_GetAncestor(_WinAPI_WindowFromPoint($tPoint), $GA_ROOT) = $hWnd
EndFuncFunc __MouseSetOnEvent_DoubleClickExpire($hWnd, $iMsg, $iIDTimer, $dwTime)
[/autoit] [autoit][/autoit] [autoit]
If TimerDiff($i__MSOE_PrmDblClk_Timer) > $a__MSOE_DblClk_Data[0] Then
_Timer_KillTimer(0, $h__MSOE_PrmDblClk_Timer)
$h__MSOE_PrmDblClk_Timer = 0
$i__MSOE_PrmDblClk_Timer = 0
EndIf
If TimerDiff($i__MSOE_ScnDblClk_Timer) > $a__MSOE_DblClk_Data[0] Then
_Timer_KillTimer(0, $h__MSOE_ScnDblClk_Timer)
$h__MSOE_ScnDblClk_Timer = 0
$i__MSOE_ScnDblClk_Timer = 0
EndIf
EndFuncFunc __MouseSetOnEvent_GetDoubleClickData()
[/autoit] [autoit][/autoit] [autoit]
Local $aRet[3] = _
[ _
RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickSpeed'), _
RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickWidth'), _
RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickHeight') _
]
Local $aGDCT = DllCall('User32.dll', 'uint', 'GetDoubleClickTime')
If Not @error And $aGDCT[0] > 0 Then
$aRet[0] = $aGDCT[0]
EndIf
Return $aRet
EndFuncFunc __MouseSetOnEvent_OnExitFunc()
[/autoit] [autoit][/autoit] [autoit]
If $h__MSOE_MouseHook <> -1 Then
_WinAPI_UnhookWindowsHookEx($h__MSOE_MouseHook)
$h__MSOE_MouseHook = -1
EndIf
If $h__MSOE_MouseProc <> -1 Then
DllCallbackFree($h__MSOE_MouseProc)
$h__MSOE_MouseProc = -1
EndIf
EndFunc#EndRegion Internal Functions
[/autoit]
Mfg Kana -
Übergeben wird der Windows-handle, sowie die ControlID von der _Mouse_Control_GetInfoAdlib(), welche du gepostet hast, sowie unter $Files einen Pfad als String (z.B.: C:\test\test.epub)
Spoiler anzeigen
[autoit]Func DoDropFiles($wnd, $Files,$cID)
[/autoit] [autoit][/autoit] [autoit]
if _GUICtrlListView_GetSelectionMark (GUICtrlGetHandle($MainGui_MainListView))<>-1 then
;msgbox(48,"",$wnd&"|:|"&$Files&"|:|"&$cID)
;$wnd is the handle of the control we are dropping onto
;$Files is the list of files separated by "|"
$tagStruct1 = "int offset;int px;int py;byte fNC;byte fWide";grab some memory
[/autoit] [autoit][/autoit] [autoit]
$hGlobal = _MemGlobalAlloc(14 + StringLen($Files) + 2)
;DropFiles := GlobalLock(MemHandle)
;translates the memory handle to a pointer
$pDropFiles = _MemGlobalLock($hGlobal)
;create the struct in this memory
$DropFiles = DllStructCreate($tagStruct1 & ";char filelist[" & StringLen($Files) + 2 & "]", $pDropFiles)
DllStructSetData($DropFiles, "offset", 14);14 = int+int+int+byte+byte
$dummy = 0; done its job
DllStructSetData($DropFiles, "px", 0);tried setting a point inside Notepad
DllStructSetData($DropFiles, "py", 0);but it makes no difference
DllStructSetData($DropFiles, "fwide", 0)
DllStructSetData($DropFiles, "fNC", 0)
DllStructSetData($DropFiles, "filelist", $Files)
;set the nulls in place of the separaters
$Size = 0;
$Files = StringSplit($Files, "|")
For $I = 1 To $Files[0];// number of characters per string (as ANSI) plus one #0 terminator
[/autoit] [autoit][/autoit] [autoit]
;Inc(Size, Length(Files[I]) + 1);
$Size += StringLen($Files[$I]) + 1
DllStructSetData($DropFiles, "filelist", 0, $Size)
Next
;ConsoleWrite(DllStructGetData($DropFiles, "filelist") & @CRLF)
;now add the extra null to terminate the list of strings
DllStructSetData($DropFiles, "filelist", 0, $Size + 1)
_MemGlobalUnlock($hGlobal)
;_WinAPI_PostMessage($wnd, $WM_DROPFILES, $hGlobal, 0);
_WinAPI_PostMessage($wnd, $WM_DROPFILES, $hGlobal, $cID)
;// ... and finally release the memory_MemGlobalFree($hGlobal)
[/autoit]
EndIF
EndFunc;==>DoDropFilesPS: Ich bezweifle, dass du dich durch meine ~1500 Zeilen Code durchwurschteln möchtest. Ich bin mit Kommentaren sehr "zurückhaltend"
PPS: Sry, dass ich die Übergabeparameter nicht gleich dabei hatte... Ich hatte den Post vorm Abschicken nochmal neu geschrieben und das dann vergessen -
Mittlerweile klappt das Verschieben, aufgrund deiner guten Tipps, beim SciTe-Editor oder Notepad.
[autoit]
Jetzt weiß ich nur nicht, wie ich es hinbekomme, dass auch andere Programme das annehmen, denn nichtmal mein eigenes kleines Testscript:#include <GUIConstantsEx.au3>
[/autoit][autoit][/autoit][autoit]
#include <StaticConstants.au3>
#include <WindowsConstants.au3>$form1=GUICreate("",620,100,-1,-1,-1,$WS_EX_ACCEPTFILES)
[/autoit]
$input1=GUICtrlCreateInput("",10,10,600,30)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUISetState(@SW_SHOW)
while 1
sleep(100)
WEnd
akzeptiert, was ich übergebe... -
Danke für den Tipp, misterspeed.
[autoit]
Hab das gleich mal umgesetzt. Jetzt habe ich allerdings das Problem, dass das
[/autoit]
GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC')
nur bei Drag and Drops von einem Externen Programm IN meine GUI auslöst. Nicht, wenn ich in eine andere Gui verschiebe.
In der Hilfe finde ich keine andere Möglichkeit. Hätte da noch jemand eine Idee?(Oder mach ich was bei der Erzeugung des Listviews was falsch? Ich kann nämlich nirgendwo hinziehen. Es erscheint nur das +-Symbol an der Maus (grau)?)
Spoiler anzeigen
[autoit]$MainGui = GUICreate("Bücherverwaltung", $guiInfo[2], $guiInfo[3]-25, $guiInfo[0], $guiInfo[1],$WS_CAPTION +$WS_SYSMENU+ $WS_SIZEBOX +$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX,$WS_EX_ACCEPTFILES)
[/autoit][autoit]$MainGui_MainListView = GUICtrlCreateListView("", 200, 40, $MainGui_size[0]-500, $MainGui_size[1]-85)
[/autoit]
GUICtrlSetResizing ( -1, 102 )
GUICtrlSetState(-1,$GUI_DROPACCEPTED) -
Auf das doDropFile bin ich schon gestoßen, ich wollte das ganze aber eher allgemein halten, nicht auf ein bestimmtes Fenster bezogen.
Beim Drag and Drop gibt ja der Explorer den Pfad der Dateien mit. Das kann dann weiterverarbeitet werden. Ich möchte diesen Pfad praktisch manuell eintragen, sodass es wäre, als wenn ich die Datei vom Explorer in das externe Fenster ziehe, Nur, dass das von meiner Listview gezogen wird. Wohin ich ziehe ist dabei also egal. Wichtig ist nur, was/wie gedroppt wird.Könnte man theoretisch Abfragen, welches Fenster unter der Maus ist, und davon dann den handle ermitteln?
-
Hi Leute.
Ich habe Daten in einer Listview. Ich möchte nun per Drag and Drop einen Listview Eintrag nach Filezilla (als Beispiel) zeihen. Dabei soll nachgesehen, welche id zu dem Eintrag gehört und der entsprechende Pfad aus einer Datenbank abgefragt werden. Dieser Pfad müsste dann als Drag and Drop an FileZilla gegeben werden.
Es ist ja nicht schwer, abzufragen, welcher eintrag markiert ist und welche id dazugehört. An den Pfad komme ich also ohne Probleme, doch wie bestimme ich, was beim Drag and Drop an FileZilla weitergegeben wird?Ich hoffe, ihr könnt mir helfen!
Mfg Kana
-
Hmpf. Hab herausgefunden, dass der Internet Explorer das Bild auch nicht anzeigt. Es liegt also nicht an meinem Script :D. Ich werd jetzt mal gucken, ob ne neuinstallation hilft. Sonst würd ich sagen: Schade, dass das Bild nicht angezeigt wird.
Ne andere Frage: Was machen diejenigen, die den Internetexplorer nicht installiert haben? -
Für den Anfang wäre das denk ich mal ganz gut. Müsste dann entsprechend noch weitergeführt werden. (Reg-Eintrag hab ich aus Zeitgründen mal weggelassen)
[autoit]$Form=GUICreate("Alles installiert?",800,600)
[/autoit][autoit][/autoit][autoit]
$ListView_Progs=GUICtrlCreateListView("Programm|Status",10,30,385,565)
$ListView_Regs=GUICtrlCreateListView("Eintrag|Status",405,30,385,565)
GUISetState(@SW_SHOW)akt()
[/autoit][autoit][/autoit][autoit]while 1
[/autoit][autoit][/autoit][autoit]
sleep(100)
WEndFunc akt()
[/autoit][autoit][/autoit][autoit]
$inifilepath="testini.ini"
if FileExists($inifilepath) then
$ProgsCount=IniRead($inifilepath,"Progs","Pfad0",0)
for $i=1 to $ProgsCount step 1
$data=IniRead($inifilepath,"Progs","Pfad"&$i,"error")
if FileExists($data) then
GUICtrlCreateListViewItem(IniRead($inifilepath,"Progs","Name"&$i,"error")&"|"&"Installiert",$ListView_Progs)
else
GUICtrlCreateListViewItem(IniRead($inifilepath,"Progs","Name"&$i,"error")&"|"&"Fehlt",$ListView_Progs)
endif
next
$RegsCount=IniRead($inifilepath,"Regs","Entry0",0)
for $i=1 to $RegsCount step 1
$data=IniRead($inifilepath,"Regs","Entry"&$i,"error")
if RegRead("","") then;abfrage für reg eintrag. Eventuell key und value mit | trennen und über stringsplit()[1] und stringsplit()[2] auslesen
GUICtrlCreateListViewItem(IniRead($inifilepath,"Regs","Name"&$i,"error")&"|"&"Eingetragen"&"|"&$data,$ListView_Regs)
else
GUICtrlCreateListViewItem(IniRead($inifilepath,"Regs","Name"&$i,"error")&"|"&"Fehlt"&"|"&$data,$ListView_Regs)
endif
next
else
FileOpen($inifilepath)
IniWriteSection($inifilepath,"Progs","Pfad0=0"&@LF&"Name0=0"&@LF)
IniWriteSection($inifilepath,"Regs","Entry0=0"&@LF&"Name0=0"&@LF)
endif
EndFunc#cs
[/autoit]
Beispielhafter Aufbau der Ini:
[Progs]
Pfad0=3
Pfad1=C:\Program Files (x86)\AutoIt3\AutoIt3.exe
Pfad2=C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe
Pfad3=C:\Program Files (x86)\AutoIt3\SciTE\SciTE1.exe
Name0=2
Name1=Autoit
Name2=SciTE
Name3=SciTE1
[Regs]
Entry0=0
Entry1=0
Entry2=0
Name0=0
Name1=0
Name2=0
#ceViel Glück noch!
-
Ich sähe da mehrere Möglichkeiten.
1.:
FileReadToArray ( "filehandle/filename" )
-> Du machst dann ne For-Schleife und fügst alles mit _GUICtrlEdit_AppendText() Zeile für Zeile an, oder sammelst alles in einem String und setzt dann den Inhalt der EditBox mit guictrlsetstate(). Dabei lässt du dann die ersten 4-Array Elemente aus.
2.:
$ar=Stringsplit( FileRead()
,@crlf,1)
und dann das gleiche mit der For-Schleife wie oben.Das wären jetzt die Möglichkeiten, die ich genommen hätte.
Viel Glück noch, Kana.