Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/18/2021 in all areas

  1. #include <ColorConstants.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> Global $hGui Example() Func Example() $hGui = GUICreate("My GUI get time", 200, 200, 800, 200, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) ToggleColour() GUICtrlCreateGroup("Time", 8, 72, 153, 73) GUICtrlCreateLabel("Start:", 16, 94, 32, 17) GUICtrlCreateLabel("Stop:", 16, 118, 29, 17) Global $idTimeStart = GUICtrlCreateDate("", 56, 88, 89, 21, $DTS_TIMEFORMAT) Global $idTimeStop = GUICtrlCreateDate("", 56, 115, 89, 21, $DTS_TIMEFORMAT) GUISetState(@SW_SHOW) AdlibRegister(ToggleColour, 1000) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example Func ToggleColour() Local Static $bActive = False GUISetBkColor($bActive ? $COLOR_GREEN : $COLOR_RED) _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN) $bActive = Not $bActive EndFunc
    3 points
  2. I'm feeling a bit of Deja Vu... I thought it worked great? What's changed?
    1 point
  3. Thank you very much, I will look at the code and see if it works for me. I haven't put the DLL documentation, because it doesn't really say much more than what I put. But anyway, here is the documentation that appears in the header file: Greetings
    1 point
  4. You have the wrong ssl setting. This worked for me on my O365 account: Jos
    1 point
  5. I was hasty to think that i could somehow cause SRER to loop and create a string like if using _StringRepeat, Even if it was possible, it could not be an elegant one liner ,So on the same notion i will dismiss this idea for now Thanks
    1 point
  6. Musashi

    Organization of script?

    You surely refer to the system-scan-report-tool made by @spudw2k , that I mentioned. It is true, that the tool throws various messages during compilation, such as : ! Obfuscator support has been discontinued and is replaced by Au3Stripper using "#Au3Stripper_" directives. This can be easily prevented by commenting out or removing the compiler directives regarding the deprecated obfuscator. [...] #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/cs=0 /cn=0 /cf=0 /cv=0 /sf=1 /sv=1 [...] The tool itself works without problems on my system (Win7 SP1 64-bit). Since the last revision was on April 8, 2019, it should also work on Win10. I'm sure, everything is fine with the WMI Classes (and this will remain so in the future). Here is an interesting thread that probably sheds some light on the darkness : wmi-diagnosis-tool-no-more-available (the additional links are also worth reading). I hope these Infos are helpful to you (and other users) .
    1 point
  7. mLipok

    Organization of script?

    Yes. It is used when you press CTRL+F5 but also when you use F5 or even F7 But you must use SciTE4AutoIt3
    1 point
  8. Gianni

    One liner add from array

    ?? #include <Array.au3> Local $array[0][4], $b = "," _ArrayAdd($array, "soda,pop,cola", 0, $b) ; the usual way i'd do it _ArrayAdd($array, $array[0][0] & $b & $array[0][1] & $b & $array[0][2] & $b & "Added", 0, $b) _ArrayDisplay($array) ;One liner $AddToCols = "0-2" ;~ .. ; ?? Local $iPeekRow = 0 _ArrayAdd($array, _ArrayToString($array, $b, $iPeekRow, $iPeekRow, '', 0, 2) & $b & "Added2", 0, $b) _ArrayDisplay($array)
    1 point
  9. Just use _DebugArrayDisplay instead of _ArrayDisplay, you'll find 2 copy buttons that will copy the results in the Clipboard * Results are whole columns if no row is selected. * If you select some lines, then only the selected lines are copied * If your display retrieved for example 10 columns and you want to copy only columns 0-1, then use the array range param. (3rd param) to display only 2 columns _DebugArrayDisplay($w, "Title", "|0:1") * If you don't want the "Row column" to appear, just add the correct 4th param. _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) This will do it : #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> $s = FileRead("2.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w) ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) Edit: While I was writing this, DanP2 just said it too
    1 point
  10. Take a look at _DebugArrayDisplay
    1 point
  11. $iControlId = ControlGetHandle($sWindowTitle, "", "[NAME:actionBox]")
    1 point
  12. Maybe this helps: ; Script Function: ; Display for GUI #include <GDIPlus.au3> #include <Date.au3> #include <File.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <ColorConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> ; Global Variables ************************************************************************************************************************************** Global $font = "Arial" Global $gui Global $aButton Global $day Global $progname = "Test" Global $agree = 0 ; Global Variables ************************************************************************************************************************************** $sImage = @ScriptDir & "\test_556x625.jpg" FileInstall('C:\Temp\test_556x625.jpg', $sImage,1);Prompt Graphic _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sImage) $aDim = _GDIPlus_ImageGetDimension($hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() If WinExists("Notification") Then Exit EndIf #Region ### START GUI section and File Install### $gui = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP)) GUISetState (@SW_LOCK) GUISetBkColor(0xffffff) ;Main Logo Picture $gMainLogo = GUICtrlCreatePic($sImage,(556-$aDim[0])/2,(625-$aDim[1])/2,$aDim[0],$aDim[1]) GUICtrlSetState(-1, $GUI_DISABLE) ;Agree Button $ClientSize = WinGetClientSize($gui) $agree = GUICtrlCreateButton("Acknowledge",180, 580, 185, 35) GUICtrlSetFont ($agree,10,1000,"",$font) #EndRegion ### END GUI section ### GUISetState(@SW_ENABLE) GUISetState(@SW_SHOW) WinActivate($gui) While 1 $msg = GUIGetMsg() Select Case $msg = $agree Sleep(1000) GUIDelete() Sleep(1000) $agree=1 MsgBox (0,"Notification","Thank You! Your response has been recorded.",5) Exit (5000) EndSelect WEnd
    1 point
  13. Not me, YOU, will have to create a copy button. This addition to your code will write the required output which you can then open in notepad or import into excel. Or, you can insert it into your clipboard buffer using ClipPut(). $sOut = "" For $i = 0 To UBound($w) - 1 $sOut = $sOut & $w[$i][0] & @TAB & $w[$i][1] & @CRLF Next FileWrite("2out.txt", $sOut)
    1 point
  14. Let's check which function hangs your script: #include <OutlookEx\OutlookEX.au3> $fileName = "c:\temp\nobles\test.msg" Global $oOutlook = _OL_Open() if @error then ConsoleWriteLine ("_OL_Open ERROR: " & @error&" " &@extended) ConsoleWriteLine ("Creating the mail item") $oItem = _OL_Itemcreate($oOutlook, $olMailItem, "", $fileName) if @error then ConsoleWriteLine ("_OL_Itemcreate ERROR: " & @error&" " &@extended) ConsoleWriteLine ("Done") ConsoleWriteLine ("Saving the item") _OL_ItemSave($oOutlook, $oItem, Default,"c:\temp",$olHTML,2+16) if @error then ConsoleWriteLine ("_OL_ItemSave ERROR: " & @error&" " &@extended) ConsoleWriteLine("Done") $oItem.Close(1) func ConsoleWriteLine($text) ConsoleWrite($text&@CRLF) EndFunc BTW: _OL_ItemSave($oOutlook, $oItem, Default,"c:\temp",$olHTML,2+16) needs to be (note the trailing backslash for the path): _OL_ItemSave($oOutlook, $oItem, Default,"c:\temp\",$olHTML,2+16)
    1 point
  15. UEZ

    GDI+ color reduction

    Check out _GDIPlus_BitmapLockBits in the help file.
    1 point
  16. Danyfirex

    libZPlay UDF

    Hi all. some time without share something. today I made this UDF because I really like this library so I wanted to share with all you. libZPlay (Win32) Version 2.02 06. May, 2010. This is multimedia library for playing mp3, mp2, mp1, ogg, flac, ac3, aac, oga, wav and pcm files and streams. New: version 2.02 can also record sound from soundcard and encode into disk file with mp3, ogg, flac, aac or wav encoder. For more information look into the LibzPlay Page.txt file into the zip file. About the libZPlay UDF supports playing mp3, ogg, AAC, AC-3, flac, wav, pcmUNICODE support for functions using strings ( filename, error messages, ID3 info, ... ) REVERSE PLAYING (you can play song backward in real time, "real" backward playing without predecoding in PCM) built in echo and reverb sound processor internal volume control (without affecting wave out device volume) pulling VU meter data (you can simply create VU meter) built in FFT spectrum graph, library will draw complete spectrum graph on your window ibzPlayExample.au3 Capture: LibzPlayAU3.zip File contents libZPlay.au3libzPlayExample.au3libZPlayform.kxf LibzPlay Page.txt License.txt- From the libZPlay SDKReadme.txt - From the libZPlay SDKChangeLog.txt - From the libZPlay SDKlibzplay.dll - From the libZPlay SDKlibzplay.chm - From the libZPlay SDKlibzplay.chw - From the libZPlay SDK Download: LibzPlayAU3.zip Saludos
    1 point
  17. You should initially declare $sData as binary and then use _WinHttpReadData() in binary mode ;... $sData = Binary("") ;... $sChunk = _WinHttpReadData($hRequest, 2) ;... ...or use _WinHttpSimpleBinaryConcat() But why not simply: #include "WinHttp.au3" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, "www.mysite.com") ; SimpleSSL-request it... $vReturned = _WinHttpSimpleSSLRequest($hConnect, Default, "/folder/?user=kiki", "http://www.mysite.com/", Default, "Authorization: xxxxxxxxxxxxxxxxxxxx") ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) $hFile = FileOpen(@ScriptDir & "\files.zip", 18) FileWrite($hFile, $vReturned) FileClose($hFile)
    1 point
  18. That depends on the OS version, current system settings and even language packs. #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Array.au3> $hGUI = GUICreate("Example") $c_Edit = GUICtrlCreateEdit("Test", 10, 10, 200, 20) GUISetState(@SW_SHOW, $hGUI) _ArrayDisplay(_GUICtrlGetFont($c_Edit)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) ; #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/ms969909(loband).aspx ; =============================================================================================================================== ; http://www.autoitscript.com/forum/topic/124526-guictrlgetfont Func _GUICtrlGetFont($hWnd = -1) Local $aReturn[5], $hObjOrg If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1, 0, $aReturn) Local $hFont = _SendMessage($hWnd, $WM_GETFONT) If Not $hFont Then Return SetError(2, 0, $aReturn) 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 ; 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 $aReturn[0] = Round((-1 * DllStructGetData($tFONT, 'Height')) * 72 / _WinAPI_GetDeviceCaps($hDC, 90), 1) ; $LOGPIXELSY = 90 => DPI aware ; ConsoleWrite("- " & _WinAPI_GetDeviceCaps($hDC, 90) & @crlf) _WinAPI_SelectObject($hDC, $hObjOrg) _WinAPI_ReleaseDC($hWnd, $hDC) $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') Return $aReturn EndFunc ;==>_GUICtrlGetFont
    1 point
  19. Yashied

    WinAPIEx UDF

    LAST VERSION - 3.8 03-Jul-12 This library contains the WinAPI functions are not included for unknown reasons to the native AutoIt WinAPI library. I use this UDF in nearly all of my programs, and decided to share it with the AutoIt community. I agree that over time some of these functions will be part of the native AutoIt library, but still... The library includes some undocumented, but useful functions (eg _WinAPI_GetFontResourceInfo()). The library also contains all the necessary constants to work with the appropriate functions. Most functions from this UDF intended for experienced users, but beginners will find the same lot of useful information for yourself. I will be to periodically add new functions to the library. The archive contains WinAPIEx library, and as usual an excellent examples from me. Some examples I took from this forum and to simplify them for better understanding. For those who use SciTE (full version) I have prepared the au3.userudfs.properties and au3.user.calltips.api files to highlight functions from this UDF in your scripts. Just copy this files to ...SciTEProperties and ...SciTEAPI, respectively. I hope this UDF will be useful for many as for me. I look forward to any feedback and suggestions. Maybe somebody wants to add new WinAPI functions? Credits Available functions Files to download WinAPIEx UDF v3.8 for AutoIt 3.3.6.1 Previous downloads: 27953 WinAPIEx UDF v3.8 for AutoIt 3.3.8.x Previous downloads: 14850
    1 point
  20. Danyfirex

    Guitar Tab Tester

    Hi all, last night I was playing with >MIDI UDF by Ascend4nt, and thought about making a game to learn the notes on the fretboard of the guitar (in the final I did not the game) but I made a guitar tablature tester. (Maybe I I add the game later.) Functions. Play notes. Play notes. while MouseDown+MouseMove Play Tabs. Change Speed. Highlight Note. Note: The tab file are into the tabs folder (see the file format if you want add more tabs) It does not supports sound effects as (slide,bend,pull off) Only clean notes. Update Version 0.1.3 (02/03/2014) Latest version! Version 0.1.3 (02/03/2014) Changed: _PlayTab Funcion rewritten Added: Play/Stop while Tab is sounding Added: Change Timing while Tab is sounding Added: Number Fret marks Added: Some tabs Guitar Tab Tester 0.1.3.rar Update Version 0.1.2 (18/02/2014) Older version! Version 0.1.2 (18/02/2014) Fixed: Notes up 9 fret Doesn't Sound Fixed: Notes Highlighting Added: English Notation Added: Some tabs Changed: GUI Look Changed: Code Structure Guitar Tab Tester 0.1.2.rar Capture: Well I hope You understand it was a hard fight vs Google traslate. (sorry for my English) suggestions, criticism, comments, help are wellcome. Saludos
    1 point
  21. KaFu

    _GUICtrlGetFont()

    Hiho Forum , I wanted to implement Melba23s excellent into SMF, but noticed on a XP system that the font's he used did not match the default font exactly. On the German AutoIt.de board I found a solution by ProgAndy which was a very good start but not the final solution I was seeking for (ProgAndy, thanks for this input!). After reading many more postings on this topic from all over the net and after throughly studying MSDN I came to the conclusion the the values used for the font definition can not be reversed easily. The problem is a mechanism in Windows called "font mapper". The font mapper interprets the input values and selects a font setting which comes closed in matching to the request. The FontSize returned by the function 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. This means if you used 8.5 as the fontsize for the original control the function might return 8.67, but using the value for GuiCtrlSetFont() will result in the same font. Another interesting observation I made is that the font mapper even selects between different fonts, if the fontname is not explicitly set. There is a commented consolewrite() in the function, uncomment it and point the function to different GuiSetFont() settings without a fontname like GuiSetFont($cID, 8). The example provided below is using functions from Yashieds excellent the function itself only needs the two includes at top of the example. As I said, the result is an approximation... I tested the function on XP-32 and Win7-64 and could not find a non-matching approximation... but you'll never know. Tell me if you find differences with specific settings / fonts. Enjoy ... #include <WinAPI.au3> #include <WindowsConstants.au3> ; #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/ms969909(loband).aspx ; =============================================================================================================================== Func _GUICtrlGetFont($hWnd = -1) Local $aReturn[5], $hObjOrg If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1, 0, $aReturn) Local $hFONT = _SendMessage($hWnd, $WM_GETFONT) If Not $hFONT Then Return SetError(2, 0, $aReturn) 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 ; 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 $aReturn[0] = Round((-1 * DllStructGetData($tFONT, 'Height')) * 72 / _WinAPI_GetDeviceCaps($hDC, 90), 1) ; $LOGPIXELSY = 90 => DPI aware _WinAPI_SelectObject($hDC, $hObjOrg) _WinAPI_ReleaseDC($hWnd, $hDC) $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') Return $aReturn EndFunc ;==>_GUICtrlGetFont ;----------------------------------------------------------------- #region _GUICtrlGetFont - Test GUI #include <Array.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> Global $FileList = _FileListToArray(_WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS), '*.ttf', 1) Global $FontList[UBound($FileList) - 1][2] For $i = 1 To $FileList[0] $FontList[$i - 1][0] = $FileList[$i] $FontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($FileList[$i], 1) Next Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) $hGUI = GUICreate("_GUICtrlGetFont", 1000, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $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) GUISetState() $sErrors = "" 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) WinSetTitle($hGUI, "", "_GUICtrlGetFont - " & $sFontfile & " - " & $sFontname & " - " & $iFontSize & " - " & $iFontWeight & " - " & $aFontAttributtes[$iFontAttributte] & " - " & $sFontname & " - " & $iFontQuality) 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]) $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 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 Func _Exit() Exit EndFunc ;==>_Exit #endregion _GUICtrlGetFont - Test GUI
    1 point
×
×
  • Create New...