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. KaFu

Beiträge von KaFu

  • SMF - Search My Files [2011-Feb-13]

    • KaFu
    • 13. Februar 2011 um 21:57
    Zitat von UEZ


    Ist es möglich in der Haupt GUI nur eine Level im Baum zu selektieren? Z.B. will ich nur auf C:\ Root suchen (im Prinzip nicht rekursiv). Klicke ich auf C: dann wird alles selektiert.


    Indirekt, einfach über dem Treeview die "scan depth" auf 1 setzen. Edit: Ah, I see, fast, aber nicht ganz genau was du meinst... quasi scan depth auf 1 UND die sub-folder nicht automatisch aktiveren... da muss ich mir was überlegen :).

    Edit2: Zuviele Features *seufz*, einfach die Checkbox vor dem "Recursive directory scan..." deaktivieren ;) (scan depth kann auf 999 stehen bleiben, intern wird die checkbox dann wie scan depth = 0 behandelt). Wenn der Folder aufgeklappt ist, werden zwar alle Sub-Dirs mit ge-checkt, aber vor der eigentlichen Suchen werden die selektierten Dirs konsolidiert, d.h. wenn alle Sub-Dirs gecheckt sind, wird nur die Parent-Dir durchsucht... und mit der oben erwähnten Checkbox sollte das dann das gewünschte Ergebnis bringen... ist einfach ein Darstellungsproblem durch die Kombi Checkbox <> Treeview (könnte / sollte ich von der Anzeige her auch noch verschränken...).

    Zitat von UEZ


    Während des Suchens kann ich im Suchfenster verschiedene Buttons anklicken (Search, Progress, Results, etc.), aber da passiert nichts, die GUI wird nur "refreshed"!


    Das ist Absicht so, damit die Suchparameter während der eigentlichen Suche nicht veränderbar sind. Ich sperre den User quasi auf dem Fortschrittstab ein. Da wären sonst echt noch zu viele zusätzliche x-checks die ich noch einbauen müsste, wenn der User während der Suche an den Einstellungen rumspielen könnte :whistling: ...

    Zitat von progandy

    Das schreit wohl nach einer neuen Klickkombination mit Strg, Shift oder Alt ;)


    Ich glaub noch nicht :whistling:
    Edit: Oder doch :rolleyes: ...
    Edit2: Oder doch noch nicht :rock: ...
    Edit3: Checkbox <> Treeview Verschränkung ist auf die ToDo Liste genommen :)...

  • SMF - Search My Files [2011-Feb-13]

    • KaFu
    • 13. Februar 2011 um 16:33

    Hallo Forum,

    SMF v1.5 ist endlich fertig :), hab das erste Posting geupdated.

    Gruß
    KaFu

  • Bitmapschrift zum Blitten :P

    • KaFu
    • 11. Februar 2011 um 00:18

    Sehr schönes Beispiel :thumbup:, danke! Geht gleich in den Snippet-Folder und kommt bestimmt eines Tages mal zum Einsatz :)...

  • Label Größe dynamisch anpassen

    • KaFu
    • 9. Februar 2011 um 08:45

    Bin zwar kein Experte in GDI (und kann daher auf die schnelle keinen Code posten :) ), aber wie wäre es mit DoubleBuffering und das Zoomen dann per WM_SIZING zu triggern?

  • FileListToArray im gesamten Verzeichnisbaum aber nicht rekursiv

    • KaFu
    • 1. Februar 2011 um 23:31
    Zitat von AspirinJunkie

    Interessante Theorie - nur - es ist genau umgekehrt - die rekursive ist schneller als die iterative.
    Nach deiner Theorie sollte der limitierende Faktor dann also der sein das einen Pfad an einen String anfügen und einen Teilstring abschneiden länger dauert als der Overhead eines extra Funktionsaufrufes...


    Tjaaaa, vielleicht sollten wir mal ein Testscript dazu schreiben, welches nicht auf die Festplatte zugreift, sondern nur die beiden Aufrufarten miteinander vergleicht :)? Ist gut möglich das die Stringoperationen langsamer werden als die Iterationen... ich hatte mal was davon gelesen, dass bei Stringoperationen der String im Speicher gedoppelt wird, bei sehr langen Strings natürlich sehr zeitintensiv. Vielleicht ist deshalb die Rekursion schneller? Sie belegt zwar auch immer neuen Speicher, verdoppelt aber nicht immer den gesamten Return. Ich überleg mir mal was :)...

  • FileListToArray im gesamten Verzeichnisbaum aber nicht rekursiv

    • KaFu
    • 1. Februar 2011 um 22:58
    Zitat von AspirinJunkie

    Also sollte die Hardware darunter eigentlich keinen Unterschied hervorrufen.


    Theorie
    Bei der iterative Funktion werden weniger Resourcen genutzt, die rekursive Funktion muss ja immer neue Speicherbereiche für die Unterfunktionen eröffnen.

    Bei einer normalen HDD ist die Antwortgeschwindigkeit der Hardware so langsam, dass sie selber der limitierende Faktor bei der Gesamtgeschwindigkeit der Funktion ist.

    Bei einer SSD ist die Antwortgeschwindigkeit hingegen soviel höher, dass der Funktionsaufruf selber zum limitierenden Faktor bei der Gesamtgeschwindigkeit der Funktion wird.

  • FileListToArray im gesamten Verzeichnisbaum aber nicht rekursiv

    • KaFu
    • 1. Februar 2011 um 11:39

    Dazu musst du der Funktion StringRegExp() sagen, dass sie case-insensitve matchen soll ("(?i)" voranstelllen). Hab das Beispiel mal angepasst. Interessant ist vor allem die Nutzung des Objects, war mir neu :).

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>

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

    $Array = _FL2Arr(@ScriptDir, '*.jpg', 1)
    _ArrayDisplay($Array)

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _FL2Arr
    ; Description ...: Gibt ein Array mit Dateien bzw. Unterordnern im gesamten Verzeichnisbaum zurück
    ; Syntax.........: _FL2Arr($sStDir, [$sPat = '*', [$iFlag = 0]])
    ; Parameters ....: $sStDir - Startverzeichnis
    ; $sPat - Optional: Pattern zur Filterung (Stichwort: "WildCards")
    ; $iFlag - Optional: Flag ob nur Dateien, Ordner oder beides gesucht werden sollen
    ; |$iFlag=0(Default) Gibt beides zurück
    ; |$iFlag=1 Gibt nur Dateien zurück
    ; |$iFlag=2 Gibt nur Ordner zurück
    ; Return values .: @Error - 1 = Fehler beim erstellen der Queue
    ; |2 = Startverzeichnis existiert nicht.
    ; |3 = ungültiger Wert für $iFlag
    ; Author ........: AspirinJunkie
    ; Modified.......:
    ; Remarks .......: Benötigt .Net
    ; Related .......:
    ; Link ..........:
    ; Example .......: No
    ; Note ..........:
    ; ===============================================================================================================================
    Func _FL2Arr($sStDir, $sPat = '*', $iFlag = 0,$iCaseSensitive = 0)
    Local $cSQueue = ObjCreate("System.Collections.Queue")
    If @error Then Return SetError(1, 1, -1)
    Local $cRetQu = ObjCreate("System.Collections.Queue")
    If @error Then Return SetError(1, 2, -1)
    Local $FFFF, $FFNF, $sDir

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

    $sPat = StringReplace($sPat, "\", "\\")
    $sPat = StringReplace($sPat, ".", "\.")
    $sPat = StringReplace($sPat, "*", ".*")
    Switch $iCaseSensitive
    Case True
    $sPat = '^' & $sPat & '$'
    Case False
    $sPat = '^(?i)' & $sPat & '$'
    EndSwitch

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

    If StringRight($sStDir, 1) = '\' Then $sStDir = StringTrimRight($sStDir, 1)
    If Not FileExists($sStDir) Then Return SetError(2, 0, "")
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 0, "")

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

    $cSQueue.Enqueue($sStDir)

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

    While $cSQueue.Count > 0
    $sDir = $cSQueue.Dequeue
    $FFFF = FileFindFirstFile($sDir & '\*')
    If $FFFF <> -1 Then
    Do
    $FFNF = FileFindNextFile($FFFF)
    If @error Then ExitLoop
    If @extended Then
    $cSQueue.Enqueue($sDir & '\' & $FFNF)
    If $iFlag <> 1 And StringRegExp($FFNF, $sPat) Then $cRetQu.Enqueue($sDir & '\' & $FFNF)
    Else
    If $iFlag < 2 And StringRegExp($FFNF, $sPat) Then $cRetQu.Enqueue($sDir & '\' & $FFNF)
    EndIf
    Until 0
    EndIf
    WEnd

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

    If $cRetQu.Count > 0 Then
    Return $cRetQu.ToArray
    Else
    Local $Ret[1] = [0]
    Return $Ret
    EndIf
    EndFunc ;==>_FL2Arr

    [/autoit]
  • SMF - Search My Files [2011-Feb-13]

    • KaFu
    • 1. Februar 2011 um 08:36
    Zitat von monkey

    Mach weiter so :)


    Vielen Dank 8o , ich schau mir jetzt nochmal das eine oder andere Flackern der GUI an, und dann solls das auch erstmal wieder gewesen sein für das nächste halbe Jahr :)...
    Gruß

  • Bei GUICtrlCreateListView Spalten verschieden Makieren (zB 1.Spalte links, 5.Spalte rechts)

    • KaFu
    • 31. Januar 2011 um 20:38

    Wenn die Listview Ownerdrawn ist, dann ist prinzipiell bei der Markierung alles möglich :)... mir ist nur noch immer nicht ganz klar, was markiert werden soll ;( ... bemühe doch mal Paint.

  • SMF - Search My Files [2011-Feb-13]

    • KaFu
    • 31. Januar 2011 um 19:50
    Zitat von UEZ

    Super Arbeit KaFu! :thumbup:
    Da steckt viel Arbeit drinnen und sonst auch schönes Look & Feel.


    Vielen Dank, so ein Feedback hört man natürlich gerne :). Na, ich denke einen reellen Stundenlohn angesetzt... wäre das Programm kaum zu bezahlen :whistling:...

    Zitat von UEZ

    Nichtsdestotrotz freue ich mich schon den Code zu sehen! Da kann man sich bestimmt eine Menge Sachen anschauen und lernen!


    Ein paar Tage warte ich noch, dann poste ich auch den. Mat hatte im int. Forum noch einige gute Design-Anmerkungen gemacht, und trancexx hat mich auf einen schweren DEP Fehler :cursing: aufmerksam gemacht (das DEP "Feature war bei mir deaktiviert). Erste Posting ist mit dem aktuellen Link geupdated.

    Gruß

  • SMF - Search My Files [2011-Feb-13]

    • KaFu
    • 30. Januar 2011 um 20:19

    Hallo Forum :),

    ich möchte euch gerne die Version 1.5 von "SMF - Search my Files" vorstellen. Executable und Source stehen auf meiner Homepage zum Download zur Verfügung.


    http://funk.eu/

    SMF ist wie der Name schon sagt ein Tool zum Suchen von Dateien und Ordnern, und dass nach jedem nur erdenklichem Kriterium (wenn euch noch was einfällt, sagt gerne Bescheid!). Der Report ist in einen zweiten separaten Prozess ausgelagert und kann schon parallel zur eigentlichen Suche ausgewertet werden. Dank ProgAndy enthält dieser jetzt auch schöne Shell-Preview Bilder (imho das absolute Killerfeature!). Die einzelnen Funktionalitäten lassen sich am besten aus der GUI selber ablesen, daher hier ein paar Screenshots als Teaser.

    [Blockierte Grafik: http://funk.eu/wp-content/uploads/110213_smf_search_my_files_1.jpg]

    [Blockierte Grafik: http://funk.eu/wp-content/uploads/110213_smf_search_my_files_2.jpg]

    [Blockierte Grafik: http://funk.eu/wp-content/uploads/110213_smf_search_my_files_3.jpg]

    [Blockierte Grafik: http://funk.eu/wp-content/uploads/110213_smf_search_my_files_7.jpg]

    [Blockierte Grafik: http://funk.eu/wp-content/uploads/110213_smf_search_my_files_4.jpg]

    [Blockierte Grafik: http://funk.eu/wp-content/uploads/110213_smf_search_my_files_5.jpg]

    Gruß
    KaFu

  • Schriftart von Labels bekommen

    • KaFu
    • 23. Januar 2011 um 22:36

    Hmm, merkwürdig :huh:, kann das mit den sich wechselnden Fonts auch gerade nicht nachstellen. Ich probiers morgen nochmal auf meinem Englischen XP Notebook. Ansonsten nettes Update, danke dir :thumbup: ...

  • Programm mit Administratorberechtigung ausführen

    • KaFu
    • 23. Januar 2011 um 20:17

    Wie ProgAndy sagte, per TaskScheduler geht das... und in ein paar Tagen (naja, zwei drei Wochen?) werde ich zufälligerweise ein entsprechende Programm releasen :)...

    P.S.: Hier nochmal eine Anleitung für die manuelle Methode.

  • TaskScheduler / Aufgabenplaner mittels ObjCreate("Schedule.Service") ansteuern

    • KaFu
    • 23. Januar 2011 um 13:49

    Danke für die Antwort Shadow :).

    Habs hinbekommen, die oben angehängte Source funktioniert grundsätzlich, ich hatte nur ein paar Parameter so gegensätzlich gesetzt, dass der Taskscheduler den Task nicht akzeptiert hatte. Anfrage ist somit gelöst... stay tuned for a full-blown app on this :)...

  • TaskScheduler / Aufgabenplaner mittels ObjCreate("Schedule.Service") ansteuern

    • KaFu
    • 22. Januar 2011 um 20:07

    Hiho Forum,

    hat hier vielleicht jemand Erfahrung mit dem scripten des TaskSchedulers / Aufgabenplaners? Ich bekomme meine Tasks einfach nicht registriert. In untem angehängten Code sind massig Links auf die relevanten Seiten bei MSDN eingefügt.

    Gruß

    Spoiler anzeigen
    [autoit]

    #region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
    #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

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

    ; schtasks.exe /run /I /TN “Test_KaFu”

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

    ConsoleWrite("IsAdmin() " & IsAdmin() & @CRLF)

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

    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    Global Const $NORMAL_PRIORITY_CLASS = 5

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

    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    Global Const $TASK_LOGON_INTERACTIVE_TOKEN = 3 ; User must already be logged on. The task will be run only in an existing interactive session.

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

    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    Global Const $TASK_RUNLEVEL_HIGHEST = 1 ; Tasks will be run with the highest privileges.

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

    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    Global Const $TASK_TRIGGER_EVENT = 0 ; Triggers the task when a specific event occurs.

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

    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    Global Const $TASK_ACTION_EXEC = 0 ; The action performs a command-line operation.

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

    ; http://taskscheduler.codeplex.com/
    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx

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

    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Initialize a COM error handler

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

    ; Create the TaskService object.
    $oService = ObjCreate("Schedule.Service")
    ConsoleWrite("IsObj($oTaskSchedule) " & IsObj($oService) & @CRLF)
    ConsoleWrite("$oTaskSchedule.service.Connect() " & $oService.Connect() & @CRLF)

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

    ; Get a folder to create a task definition in.
    $oFolder = $oService.GetFolder("\")
    ConsoleWrite("rootFolder " & IsObj($oFolder) & @CRLF)

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

    ; The taskDefinition variable is the TaskDefinition object.
    ; The flags parameter is 0 because it is not supported.
    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    $oTaskDefinition = $oService.NewTask(0) ; This parameter is reserved for future use and must be set to 0.
    ConsoleWrite("taskDefinition " & IsObj($oTaskDefinition) & @CRLF)

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

    ; Define information about the task.
    ; Set the registration info for the task by creating the RegistrationInfo object.
    $oRegistrationInfo = $oTaskDefinition.RegistrationInfo()
    ConsoleWrite("oRegistrationInfo " & IsObj($oRegistrationInfo) & @CRLF)
    ;$oRegistrationInfo.Date() = "2011-01-19T08:59:10.4124457"
    $oRegistrationInfo.Author() = @LogonDomain & "\\" & @UserName
    $oRegistrationInfo.Description() = "Beschreibung eines TestTasks"

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

    ; Set the task setting info for the Task Scheduler by creating a TaskSettings object.
    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    $oSettings = $oTaskDefinition.Settings()
    ConsoleWrite("settings " & IsObj($oSettings) & @CRLF)
    ;$oSettings.MultipleInstances() = 0 ; Starts a new instance while an existing instance of the task is running.
    ;$oSettings.DisallowStartIfOnBatteries() = False
    ;$oSettings.StopIfGoingOnBatteries() = False
    ;$oSettings.AllowHardTerminate() = True
    $oSettings.StartWhenAvailable() = False
    ;$oSettings.RunOnlyIfNetworkAvailable() = False
    ;$IdleSettings = $settings.IdleSettings()
    ;$IdleSettings.StopOnIdleEnd() = True
    ;$IdleSettings.RestartOnIdle() = False
    ;$oSettings.AllowDemandStart() = True ; True ; For scripting, gets or sets a Boolean value that indicates that the task can be started by using either the Run command or the Context menu.
    $oSettings.Enabled() = True; True ; The task can be performed only when this setting is True.
    $oSettings.Hidden() = False; False
    ;$oSettings.RunOnlyIfIdle() = False; False
    ; <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    ; <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
    ;$oSettings.WakeToRun() = False; False
    ;$oSettings.ExecutionTimeLimit() = "P3D" ; When this parameter is set to Nothing, the execution time limit is infinite.
    $oSettings.Priority() = $NORMAL_PRIORITY_CLASS

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

    ; Create triggers
    $oColTriggers = $oTaskDefinition.Triggers()
    ConsoleWrite("triggers " & IsObj($oColTriggers) & @CRLF)
    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    ; A maximum of 500 tasks with event subscriptions can be created.

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

    $oTrigger = $oColTriggers.Create($TASK_TRIGGER_EVENT)
    ConsoleWrite("trigger " & IsObj($oTrigger) & @CRLF)
    $oTrigger.Id() = "TestTrigger" ; The identifier for the trigger. This identifier is used by the Task Scheduler for logging purposes.
    $oTrigger.Enabled() = True
    $oTrigger.Subscription() = "";'&lt;QueryList&gt;&lt;Query Id="0" Path="Application"&gt;&lt;Select Path="Application"&gt;*[System[Provider[@Name='Application']]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;'

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

    ; Set the principal for the task
    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    $oPrincipal = $oTaskDefinition.Principal()
    ConsoleWrite("principal " & IsObj($oPrincipal) & @CRLF)
    $oPrincipal.Id() = "TestPrincipal"
    $oPrincipal.DisplayName() = "TestPrincipalDisplayName"
    $oPrincipal.UserId() = @LogonDomain & "\\" & @UserName ; Tasks will be run with the highest privileges.
    $oPrincipal.LogonType() = $TASK_LOGON_INTERACTIVE_TOKEN
    $oPrincipal.RunLevel() = $TASK_RUNLEVEL_HIGHEST
    ; When specifying an account, remember to properly use the double backslash in code to specify the domain and user name. For example, use DOMAIN\\UserName to specify a value for the UserId property.

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

    ; Create the action for the task to execute.
    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    $oColActions = $oTaskDefinition.Actions()
    $oColActions.Context() = "TestPrincipal" ; The identifier of the principal for the task. The identifier that is specified here must match the identifier that is specified in the Id property of the IPrincipal interface that defines the principal.
    $oAction = $oColActions.Create($TASK_ACTION_EXEC) ; TASK_ACTION_EXEC
    ConsoleWrite("Action " & IsObj($oAction) & @CRLF)
    ;$Action.Type() = 0 ; already in create(0)
    ;$oAction.ID() = "Test"
    $oAction.Path() = "C:\Windows\System32\notepad.exe"
    $oAction.WorkingDirectory() = "C:\"
    $oAction.Arguments() = ""

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

    ; Register (create) the task.
    ; http://msdn.microsoft.com/en-us/library/…28VS.85%29.aspx
    #cs
    Function RegisterTaskDefinition( _
    ByVal path, _
    ByVal definition, _
    ByVal flags, _
    ByVal userId, _
    ByVal password, _
    ByVal longonType, _
    [ ByVal sddl ], _
    ByRef task _
    )
    #ce
    ; TASK_CREATE_OR_UPDATE = 0x6

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

    Global Const $TASK_CREATE_OR_UPDATE = 6
    $sUsername = "";@LogonDomain & "\\" & @UserName
    $sPassword = ""
    $iSecurityDescriptor = ""

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

    ;Global $oRegisteredTask; = $oTaskDefinition.RegisteredTask()
    ; call rootFolder.RegisterTaskDefinition(strTaskName, taskDefinition, FlagTaskCreate, , , LogonTypeInteractive)
    Global $oRegisteredTask
    $oFolder.RegisterTaskDefinition("Test_KaFu", $oTaskDefinition, $TASK_CREATE_OR_UPDATE, "", "", $TASK_LOGON_INTERACTIVE_TOKEN, $oRegisteredTask);, $iSecurityDescriptor);, $oRegisteredTask)
    MsgBox(0, "", IsObj($oRegisteredTask))

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

    ; http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    ; ExecAction Object
    ; Scripting object that represents an action that executes a command-line operation.

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

    ; Security Contexts for Tasks
    ; http://msdn.microsoft.com/en-us/library/…v=vs.85%29.aspx

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

    ; http://msdn.microsoft.com/en-us/library/…v=vs.85%29.aspx
    ;Principal.RunLevel(1) ; Tasks will be run with the highest privileges.

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

    #cs
    $sCommand "schtasks.exe /RU " & @UserName & " /SC ONEVENT /TN TestShortcut /TR ""\"""& $sTargetFile & """\"" " & """\""" & $sCommandline & """\"" /IT

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

    /EC ChannelName

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

    schtasks /create /tn "My App Job1" /tr "\"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE\" C:\text.doc"
    /sc DAILY /st 05:00:00 /ru <username> /rp
    <password>

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

    schtasks /run /tn “TASKNAMEINQUOTES”

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

    It seems that "Run with highest privileges" option will not take precedence of the UAC. While the Admin Approval Mode for built-in Administrator account is enabled, UAC will still ask for approval
    according to the settings on the Behavior of elevation to prompt for the administrators.
    Check whether the "User Account Control: Admin Approval Mode for built-in Administrator account" is enabled. If yes, disable it or change the setting on "User Account Control:
    Behavior of elevation to prompt for the administrators" to elevate without prompting.
    - Did you try to right click the stsadm.exe and in the security tab add the backup operator account in the security with full control and try.
    #ce

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

    Func MyErrFunc()
    MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _
    "err.description is: " & @TAB & $oMyError.description & @CRLF & _
    "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
    "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _
    "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
    "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
    "err.source is: " & @TAB & $oMyError.source & @CRLF & _
    "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
    "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
    )

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

    Local $err = $oMyError.number
    If $err = 0 Then $err = -1

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

    $g_eventerror = $err ; to check for after this function returns
    EndFunc ;==>MyErrFunc

    [/autoit]
  • Schriftart von Labels bekommen

    • KaFu
    • 22. Januar 2011 um 10:41

    Hab die angehübschte Funktion hier im internationalen Forum gepostet (größerer Kundenkreis ;) ).

    Hier nochmal mein finaler Code inklusive beispielhafter Iteration aller Fonts auf eurem System (dafür wird die WinApiEx UDF von Yashied benötigt).

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlGetFont
    ; Description ...: Gets the font of a GUI Control
    ; Syntax.........: _GUICtrlGetFont( [$hWnd] )
    ; Parameters ....: $hWnd - [optional] ControlID or Handle of the control. Default is last created GUICtrl... (-1)
    ;
    ; Return values .: Success - Array[5] with options of font:
    ; [0] - FontSize (~ approximation)
    ; [1] - Font weight (400 = normal).
    ; [2] - italic:2 underlined:4 strike:8 char format (styles added together, 2+4 = italic and underlined).
    ; [3] - The name of the font to use.
    ; [4] - Font quality to select (PROOF_QUALITY=2 is default in AutoIt).
    ;
    ; Failure - Array[5] with empty fields, @error set to nonzero
    ;
    ; Author ........: KaFu, Prog@ndy
    ;
    ; Comments.......: The FontSize returned is an approximation of the actual fontsize used for the control.
    ; The height of the font returned by GetObject is the height of the font's character cell or character in logical units.
    ; The character height value (also known as the em height) is the character cell height value minus the internal-leading value.
    ; The font mapper interprets the value specified in lfHeight. The result returned by the font mapper is not easily reversible
    ; The FontSize calculated below is an approximation of the actual size used for the analyzed control, qualified enough to use
    ; in another call to the font mapper resulting in the same font size as the the original font.
    ; MSDN.. ........: Windows Font Mapping: http://msdn.microsoft.com/en-us/library/…09(loband).aspx
    ; ===============================================================================================================================
    Func _GUICtrlGetFont($hWnd = -1)
    Local $aReturn[5], $hObjOrg

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

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    If Not IsHWnd($hWnd) Then Return SetError(1, 0, $aReturn)

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

    Local $hFONT = _SendMessage($hWnd, $WM_GETFONT)
    If Not $hFONT Then Return SetError(2, 0, $aReturn)

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

    Local $hDC = _WinAPI_GetDC($hWnd)
    $hObjOrg = _WinAPI_SelectObject($hDC, $hFONT)
    Local $tFONT = DllStructCreate($tagLOGFONT)
    Local $aRet = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFONT, 'int', DllStructGetSize($tFONT), 'ptr', DllStructGetPtr($tFONT))
    If @error Or $aRet[0] = 0 Then
    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return SetError(3, 0, $aReturn)
    EndIf

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

    ; Need to extract FontFacename separately => DllStructGetData($tFONT, 'FaceName') is only valid if FontFacename has been set explicitly!
    $aRet = DllCall("gdi32.dll", "int", "GetTextFaceW", "handle", $hDC, "int", 0, "ptr", 0)
    Local $nCount = $aRet[0]
    Local $tBuffer = DllStructCreate("wchar[" & $aRet[0] & "]")
    Local $pBuffer = DllStructGetPtr($tBuffer)
    $aRet = DllCall("Gdi32.dll", "int", "GetTextFaceW", "handle", $hDC, "int", $nCount, "ptr", $pBuffer)
    If @error Then
    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return SetError(4, 0, $aReturn)
    EndIf
    $aReturn[3] = DllStructGetData($tBuffer, 1) ; FontFacename

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

    $aReturn[0] = Round(((-1 * DllStructGetData($tFONT, 'Height')) * 72 / _WinAPI_GetDeviceCaps($hDC, 90)) + 0.25, 2) ; $LOGPIXELSY = 90 => DPI aware ; 0.25 = Magic Number, don't ask...

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

    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)

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

    $aReturn[1] = DllStructGetData($tFONT, 'Weight')
    $aReturn[2] = 2 * (True = DllStructGetData($tFONT, 'Italic')) + 4 * (True = DllStructGetData($tFONT, 'Underline')) + 8 * (True = DllStructGetData($tFONT, 'StrikeOut'))
    $aReturn[4] = DllStructGetData($tFONT, 'Quality')

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

    Return $aReturn

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

    EndFunc ;==>_GUICtrlGetFont
    ;-----------------------------------------------------------------

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

    #region _GUICtrlGetFont - Test GUI

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

    #include <Array.au3>
    #include <File.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPIEx.au3>

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

    Global $FileList = _FileListToArray(_WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS), '*.ttf', 1)
    Global $FontList[UBound($FileList) - 1][2]

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

    For $i = 1 To $FileList[0]
    $FontList[$i - 1][0] = $FileList[$i]
    $FontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($FileList[$i], 1)
    Next

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

    Opt("GUIOnEventMode", 1)
    Opt("GUICloseOnESC", 0)

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

    $hGUI = GUICreate("_GUICtrlGetFont", 1000, 200)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

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

    $c_Label_Reference = GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 10, 980, 90)
    $c_Label_Clone = GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 100, 980, 90)

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

    GUISetState()

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

    $sErrors = ""

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

    Global $aFontAttributtes[8] = [0, 2, 4, 6, 8, 10, 12, 14]
    For $iFontAttributte = 0 To UBound($aFontAttributtes) - 1
    For $iFontQuality = 0 To 5
    For $iFontWeight = 100 To 800 Step 100
    For $i = 0 To UBound($FontList) - 1
    $sFontname = $FontList[$i][1]
    $sFontfile = $FontList[$i][0]
    For $iFontSize = 2 To 48 Step 0.1
    $iFontSize = Round($iFontSize, 1)

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

    WinSetTitle($hGUI, "", "_GUICtrlGetFont - " & $sFontfile & " - " & $sFontname & " - " & $iFontSize & " - " & $iFontWeight & " - " & $aFontAttributtes[$iFontAttributte] & " - " & $sFontname & " - " & $iFontQuality)

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

    GUICtrlSetFont($c_Label_Reference, $iFontSize, $iFontWeight, $aFontAttributtes[$iFontAttributte], $sFontname, $iFontQuality)
    $aFont_Get = _GUICtrlGetFont($c_Label_Reference)
    GUICtrlSetFont($c_Label_Clone, $aFont_Get[0], $aFont_Get[1], $aFont_Get[2], $aFont_Get[3], $aFont_Get[4])

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

    $iFontSize_Reference = _GUICtrlGetFont_Height_EM($c_Label_Reference)
    $iFontSize_Clone = _GUICtrlGetFont_Height_EM($c_Label_Clone)
    If $iFontSize_Reference <> $iFontSize_Clone Then
    ConsoleWrite("! " & $iFontSize_Reference & @TAB & $iFontSize_Clone & @TAB & @TAB & @TAB & $iFontSize & @TAB & $iFontWeight & @TAB & $aFontAttributtes[$iFontAttributte] & @TAB & $sFontname & @TAB & $iFontQuality & @CRLF)
    $sErrors &= $iFontSize & @TAB & $iFontWeight & @TAB & $aFontAttributtes[$iFontAttributte] & @TAB & $sFontname & @TAB & $iFontQuality & @CRLF
    ClipPut($sErrors)
    MsgBox(48 + 262144, "_GUICtrlGetFont - ERROR", $iFontSize_Reference & @CRLF & $iFontSize_Clone & @CRLF & @CRLF & $iFontSize & @CRLF & $iFontWeight & @CRLF & $aFontAttributtes[$iFontAttributte] & @CRLF & $sFontname & @CRLF & $iFontQuality, 10, $hGUI)
    Else
    ;ConsoleWrite("+ " & $iFontSize_Reference & @TAB & $iFontSize_Clone & @TAB & @TAB & @TAB & $iFontSize & @TAB & $iFontWeight & @TAB & $aFontAttributtes[$iFontAttributte] & @TAB & $sFontname & @TAB & $iFontQuality & @CRLF)
    EndIf
    Next
    Next
    Next
    Next
    Next

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

    Func _GUICtrlGetFont_Height_EM($hWnd = -1)
    Local $hFONT
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0)
    $hFONT = _SendMessage($hWnd, $WM_GETFONT)
    If Not $hFONT Then Return SetError(1, 0, 0)
    Local $tFONT = DllStructCreate($tagLOGFONT)
    Local $aReturn = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFONT, 'int', DllStructGetSize($tFONT), 'ptr', DllStructGetPtr($tFONT))
    If @error Or $aReturn[0] = 0 Then Return SetError(2, 0, 0)
    Return Abs(DllStructGetData($tFONT, 'Height'))
    EndFunc ;==>_GUICtrlGetFont_Height_EM

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

    Func _Exit()
    Exit
    EndFunc ;==>_Exit

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

    #endregion _GUICtrlGetFont - Test GUI

    [/autoit]
  • Schriftart von Labels bekommen

    • KaFu
    • 21. Januar 2011 um 20:06

    8o:rock::thumbup: War schon echt am verzweifeln! Vielen Dank fürs Testen :thumbup: ...

  • Schriftart von Labels bekommen

    • KaFu
    • 21. Januar 2011 um 19:00

    Hmmm, in der Konsole ist klar dass die unterschiedlich sind, aber auch optisch?... *seufz*, woran könnte es liegen? Magst du mal den sleep auf 250 setzen?

  • Schriftart von Labels bekommen

    • KaFu
    • 21. Januar 2011 um 18:35

    Raupi, danke fürs Checken :)! Ich denke, da war was in der Berechnung noch nicht ganz richtig. Wie gesagt, ich glaube nicht, dass man überhaupt eine Punktlandung hinlegen kann, es wird nur ein Näherungswert ermittelt. Lass dass hier doch bitte nochmal laufen, funktioniert bei mir auf meinem XP Notebook und auch auf Win7.

    Spoiler anzeigen
    [autoit]

    #include<WinAPI.au3>
    #include<WindowsConstants.au3>

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

    Global Const $tagTEXTMETRIC = "long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;" & _
    "long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;" & _
    "wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;" & _
    "byte tmPitchAndFamily;byte tmCharSet"

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlGetFont
    ; Description ...: Gets the font of a GUI Control
    ; Syntax.........: _GUICtrlGetFont( [$hWnd] )
    ; Parameters ....: $hWnd - [optional] ControlID or Handle of the control. Default is last created GUICtrl... (-1)
    ; Return values .: Success - Array with options of font:
    ; [0] - Fontsize
    ; [1] - Font weight (400 = normal).
    ; [2] - italic:2 underlined:4 strike:8 char format (styles added together, 2+4 = italic and underlined).
    ; [3] - The name of the font to use.
    ; [4] - Font quality to select (PROOF_QUALITY=2 is default in AutoIt).
    ; Failure - Array with options of font => EMPTY, @error set to nonzero
    ; Author ........: Prog@ndy
    ; Modified.......: KaFu
    ; Remarks .......:
    ; Related .......:
    ; Link ..........;
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlGetFont($hWnd = -1)
    ; Author: Prog@ndy & KaFu
    Local $aReturn[5], $hObjOrg

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

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    If Not IsHWnd($hWnd) Then Return SetError(1, 0, $aReturn)

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

    Local $hFONT = _SendMessage($hWnd, $WM_GETFONT)
    If Not $hFONT Then Return SetError(2, 0, $aReturn)

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

    Local $hDC = _WinAPI_GetDC($hWnd)
    $hObjOrg = _WinAPI_SelectObject($hDC, $hFONT)
    Local $tFONT = DllStructCreate($tagLOGFONT)
    Local $aRet = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFONT, 'int', DllStructGetSize($tFONT), 'ptr', DllStructGetPtr($tFONT))
    If @error Or $aRet[0] = 0 Then
    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return SetError(3, 0, $aReturn)
    EndIf

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

    Local $tTEXTMETRIC = _GetTextMetrics($hDC)

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

    ; Needed to extract FontFacename => DllStructGetData($tFONT, 'FaceName') is only valid if FontFacename has been set explicitly!
    $aRet = DllCall("gdi32.dll", "int", "GetTextFaceW", "handle", $hDC, "int", 0, "ptr", 0)
    Local $nCount = $aRet[0]
    Local $tBuffer = DllStructCreate("wchar[" & $aRet[0] & "]")
    Local $pBuffer = DllStructGetPtr($tBuffer)
    $aRet = DllCall("Gdi32.dll", "int", "GetTextFaceW", "handle", $hDC, "int", $nCount, "ptr", $pBuffer)
    If @error Then
    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return SetError(4, 0, $aReturn)
    EndIf
    ; FontFacename
    $aReturn[3] = DllStructGetData($tBuffer, 1)
    ConsoleWrite($aReturn[3] & @TAB & @TAB & DllStructGetData($tFONT, 'FaceName') & @CRLF)

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

    $aReturn[0] = Round(((-1 * DllStructGetData($tFONT, 'Height')) * 72 / _WinAPI_GetDeviceCaps($hDC, 90)) + 0.25, 2) ; $LOGPIXELSY = 90 => DPI aware

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

    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)

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

    $aReturn[1] = DllStructGetData($tFONT, 'Weight')
    $aReturn[2] = 2 * (True = DllStructGetData($tFONT, 'Italic')) + 4 * (True = DllStructGetData($tFONT, 'Underline')) + 8 * (True = DllStructGetData($tFONT, 'StrikeOut'))
    $aReturn[4] = DllStructGetData($tFONT, 'Quality')

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

    Return $aReturn

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

    EndFunc ;==>_GUICtrlGetFont

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

    ;-----------------------------------------------------------------

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

    Func _GetTextMetrics($hDC)
    Local $aRet, $tBuffer, $pBuffer
    $tBuffer = DllStructCreate($tagTEXTMETRIC)
    $pBuffer = DllStructGetPtr($tBuffer)
    DllCall("Gdi32.dll", "bool", "GetTextMetricsW", "handle", $hDC, "ptr", $pBuffer)
    If @error Then Return SetError(@error, @extended, 0)
    Return $tBuffer
    EndFunc ;==>_GetTextMetrics

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

    #Region TestGUI

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

    HotKeySet("{ESC}", "_Exit")
    Func _Exit()
    Exit
    EndFunc ;==>_Exit

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

    GUICreate("GetFont TestGUI", 600, 110)
    $label_ref = GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 10, 580, 50)
    $label_test = GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 60, 580, 50)
    GUISetState()

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

    $sFontname = ""
    For $iFontSize_Test = 6 To 14 Step 0.1
    GUICtrlSetFont($label_ref, $iFontSize_Test, 600, 0, $sFontname, 5)
    $font = _GUICtrlGetFont(GUICtrlGetHandle($label_ref))
    GUICtrlSetFont($label_test, $font[0], $font[1], $font[2], $font[3], $font[4])
    ConsoleWrite(Round($iFontSize_Test, 2) & @TAB & $font[0] & @CRLF)
    Sleep(50)
    Next

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

    $sFontname = "Tahoma"
    For $iFontSize_Test = 6 To 14 Step 0.1
    GUICtrlSetFont($label_ref, $iFontSize_Test, 600, 10, $sFontname, 5)
    $font = _GUICtrlGetFont(GUICtrlGetHandle($label_ref))
    GUICtrlSetFont($label_test, $font[0], $font[1], $font[2], $font[3], $font[4])
    Sleep(100)
    Next

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

    $sFontname = "Arial"
    For $iFontSize_Test = 6 To 14 Step 0.1
    GUICtrlSetFont($label_ref, $iFontSize_Test, 400, 0, $sFontname)
    $font = _GUICtrlGetFont(GUICtrlGetHandle($label_ref))
    GUICtrlSetFont($label_test, $font[0], $font[1], $font[2], $font[3], $font[4])
    Sleep(100)
    Next

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

    #EndRegion TestGUI

    [/autoit]
  • Schriftart von Labels bekommen

    • KaFu
    • 21. Januar 2011 um 13:27

    Was für ein biestiges Biest dieser Font-Mapper :pinch: ...
    Hab mal ein bisschen (sehr viel) an der Funktion von ProgAndy rumgeschraubt. Die unten angehängte Lösung "scheint" auf XP in allen Fällen zu funktionieren... mag die mal jemand durch sein Vista oder Win7 drücken?

    Edit: Ich habe nochmal ein consolewrite() in die Funktion eingebaut. Schaut euch mal an, was die GUI macht wenn der Font nicht explizit benannt wird... er sucht sich einen basierend auf der gewünschten Größe aus!... ts, ich sag nur Font-Mapper! Kein Wunder, hier steht die Beschreibung auf MSDN, schaut mal auf das Datum des Artikels...

    Tatsächlich ist die ermittelte FontSize nicht die ursprüngliche FontSize! Sondern ein Wert aus dem der Font-Mapper dann per GuiCtrlSetFont() denselben Font erzeugt wie der ausgelesene. Mir scheint es so, als wenn beim Erzeugen des Fonts der Font-Mapper intern ein paar (nicht ohne weiteres nachvollziehbare) Entscheidungen basierend auf dem Input und den Eigenschaften des gewünschten Fonts trifft und darauf basierend dann den Output generiert.

    Spoiler anzeigen
    [autoit]

    #include<WinAPI.au3>
    #include<WindowsConstants.au3>

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlGetFont
    ; Description ...: Gets the font of a GUI Control
    ; Syntax.........: _GUICtrlGetFont( [$hWnd] )
    ; Parameters ....: $hWnd - [optional] ControlID or Handle of the control. Default is last created GUICtrl... (-1)
    ; Return values .: Success - Array with options of font:
    ; [0] - Fontsize
    ; [1] - Font weight (400 = normal).
    ; [2] - italic:2 underlined:4 strike:8 char format (styles added together, 2+4 = italic and underlined).
    ; [3] - The name of the font to use.
    ; [4] - Font quality to select (PROOF_QUALITY=2 is default in AutoIt).
    ; Failure - Array with options of font => EMPTY, @error set to nonzero
    ; Author ........: Prog@ndy
    ; Modified.......: KaFu
    ; Remarks .......:
    ; Related .......:
    ; Link ..........;
    ; Example .......;
    ; ===============================================================================================================================
    Func _GUICtrlGetFont($hWnd = -1)
    ; Author: Prog@ndy & KaFu
    Local $aReturn[5], $hObjOrg

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

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    If Not IsHWnd($hWnd) Then Return SetError(1, 0, $aReturn)

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

    Local $hFONT = _SendMessage($hWnd, $WM_GETFONT)
    If Not $hFONT Then Return SetError(2, 0, $aReturn)

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

    Local $hDC = _WinAPI_GetDC($hWnd)
    $hObjOrg = _WinAPI_SelectObject($hDC, $hFONT)
    Local $tFONT = DllStructCreate($tagLOGFONT)
    Local $aRet = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFONT, 'int', DllStructGetSize($tFONT), 'ptr', DllStructGetPtr($tFONT))
    If @error Or $aRet[0] = 0 Then
    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return SetError(3, 0, $aReturn)
    EndIf

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

    ; Needed to extract FontFacename => DllStructGetData($tFONT, 'FaceName') is only valid if FontFacename has been set explicitly!
    $aRet = DllCall("gdi32.dll", "int", "GetTextFaceW", "handle", $hDC, "int", 0, "ptr", 0)
    Local $nCount = $aRet[0]
    Local $tBuffer = DllStructCreate("wchar[" & $aRet[0] & "]")
    Local $pBuffer = DllStructGetPtr($tBuffer)
    $aRet = DllCall("Gdi32.dll", "int", "GetTextFaceW", "handle", $hDC, "int", $nCount, "ptr", $pBuffer)
    If @error Then
    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return SetError(4, 0, $aReturn)
    EndIf
    ; FontFacename
    $aReturn[3] = DllStructGetData($tBuffer, 1)
    ConsoleWrite($aReturn[3] & @TAB & @TAB & DllStructGetData($tFONT, 'FaceName') & @CRLF)

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

    ; FontSize
    $aReturn[0] = Round(-1 * DllStructGetData($tFONT, 'Height') * 72 / _WinAPI_GetDeviceCaps($hDC, 90) + 0.1, 2) ; $LOGPIXELSY = 90 => DPI aware

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

    _WinAPI_SelectObject($hDC, $hObjOrg)
    _WinAPI_ReleaseDC($hWnd, $hDC)

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

    $aReturn[1] = DllStructGetData($tFONT, 'Weight')
    $aReturn[2] = 2 * (True = DllStructGetData($tFONT, 'Italic')) + 4 * (True = DllStructGetData($tFONT, 'Underline')) + 8 * (True = DllStructGetData($tFONT, 'StrikeOut'))
    $aReturn[4] = DllStructGetData($tFONT, 'Quality')

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

    Return $aReturn

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

    EndFunc ;==>_GUICtrlGetFont

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

    ;-----------------------------------------------------------------

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

    #Region TestGUI

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

    HotKeySet("{ESC}", "_Exit")
    Func _Exit()
    Exit
    EndFunc ;==>_Exit

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

    GUICreate("GetFont TestGUI", 600, 110)
    $label_ref = GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 10, 580, 50)
    $label_test = GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog", 10, 60, 580, 50)
    GUISetState()

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

    $sFontname = ""
    For $iFontSize_Test = 6 To 14 Step 0.1
    GUICtrlSetFont($label_ref, $iFontSize_Test, 600, 0, $sFontname, 5)
    $font = _GUICtrlGetFont(GUICtrlGetHandle($label_ref))
    GUICtrlSetFont($label_test, $font[0], $font[1], $font[2], $font[3], $font[4])
    ConsoleWrite(Round($iFontSize_Test, 2) & @TAB & $font[0] & @CRLF)
    Sleep(50)
    Next

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

    $sFontname = "Tahoma"
    For $iFontSize_Test = 6 To 14 Step 0.1
    GUICtrlSetFont($label_ref, $iFontSize_Test, 600, 10, $sFontname, 5)
    $font = _GUICtrlGetFont(GUICtrlGetHandle($label_ref))
    GUICtrlSetFont($label_test, $font[0], $font[1], $font[2], $font[3], $font[4])
    Sleep(100)
    Next

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

    $sFontname = "Arial"
    For $iFontSize_Test = 6 To 14 Step 0.1
    GUICtrlSetFont($label_ref, $iFontSize_Test, 400, 0, $sFontname)
    $font = _GUICtrlGetFont(GUICtrlGetHandle($label_ref))
    GUICtrlSetFont($label_test, $font[0], $font[1], $font[2], $font[3], $font[4])
    Sleep(100)
    Next

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

    #EndRegion TestGUI

    [/autoit]

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™