Leaderboard
Popular Content
Showing content with the highest reputation on 04/24/2024 in all areas
-
WinWaitActive () does not pop-up corresponding window - (Moved)
SOLVE-SMART reacted to Jos for a topic
Yes.1 point -
Fastest Way to Delete Empty Records in 1d Array
Andreik reacted to AspirinJunkie for a topic
Ah yes - i hoped to bypass the "(?>\||\z)"-construct with StringStripWS but didn`t had your case in mind. So just add this and it should work: #include <Array.au3> Local $array[3] $array[0] = '' $array[1] = '' $array[2] = ' some data ' $array[1] = ' ' ConsoleWrite(StringLen($array[2]) & @CRLF) $array = _strip_AspirinJunkie2($array) ConsoleWrite(StringLen($array[0]) & @CRLF) _ArrayDisplay($array) Func _strip_AspirinJunkie2(ByRef $aArray) Return StringRegExp(_ArrayToString($aArray), "\s+(?>\||\z)(*SKIP)(?!)|[^|]+", 3) EndFunc1 point -
Fastest Way to Delete Empty Records in 1d Array
AspirinJunkie reacted to Andreik for a topic
@AspirinJunkie In some cases won't work: #include <Array.au3> Local $array[3] $array[0] = '' $array[1] = '' $array[2] = ' some data ' $array[1] = ' ' ConsoleWrite(StringLen($array[2]) & @CRLF) $array = _strip_AspirinJunkie2($array) ConsoleWrite(StringLen($array[0]) & @CRLF) _ArrayDisplay($array) Func _strip_AspirinJunkie2(ByRef $aArray) Return StringRegExp(StringStripWS(_ArrayToString($aArray), 2), "\s+\|(*SKIP)(?!)|[^|]+", 3) EndFunc1 point -
@Nine, I fixed that by 1) setting this In SciTeUserProperties: code.page=65001 output.code.page=65001 and using a good Unicode font: font.monospace=font:DejaVu Sans Mono,size:11 Then I use CW() instead of ConsoleWrite(): Func CW($s = "") If @Compiled Then _CUI_ConsoleWrite($s) Else _ConsoleWrite($s) EndIf EndFunc ;==>CW Func _CUI_ConsoleWrite(ByRef $s) Local Static $hDll = DllOpen("kernel32.dll") Local Static $hCon = __CUI_ConsoleInit($hDll) DllCall($hDll, "bool", "WriteConsoleW", "handle", $hCon, "wstr", $s & @LF, "dword", StringLen($s) + 1, "dword*", 0, "ptr", 0) Return EndFunc ;==>_CUI_ConsoleWrite ; internal use only Func __CUI_ConsoleInit(ByRef $hDll) DllCall($hDll, "bool", "AllocConsole") ;~ The following 2 lines don't work for compiled scripts due to a MS bug ;~ see last post in thread https://developercommunity.visualstudio.com/t/setconsoleoutputcpcp-utf8-results-in-code-page-850/413190 ;~ where MS support acknowledges it's a (still unfixed) bug in Windows itself ;~ So you can only display current locale codepage using current console font in a console when your script is compiled ;~ When running your script from SciTE, the UTF8 setting of SciTE overrides this bug and Unicode can be displayed ;~ DllCall("Kernel32.dll", "bool", "SetConsoleCP", "uint", 65001) ;~ DllCall("Kernel32.dll", "bool", "SetConsoleOutputCP", "uint", 65001) Return DllCall($hDll, "handle", "GetStdHandle", "int", -11)[0] EndFunc ;==>__CUI_ConsoleInit ; Unicode-aware ConsoleWrite Func _ConsoleWrite(ByRef $s) ConsoleWrite(BinaryToString(StringToBinary($s & @LF, 4), 1)) EndFunc ;==>_ConsoleWrite1 point
-
@TexWiller asked in Help & Support how to use _WinAPI_ExtractIconEx instead of GUICtrlSetImage This is his reproducer script for displaying his issue I cleaned it up and made it work for _WinAPI_ExtractIconEx ;============================================================================================================ ;Program Options ;============================================================================================================ Opt("MustDeclareVars", 1) ;Variables must be pre-declared. Opt("TrayMenuMode", 3) ;The default tray menu items will not be shown, items are not checked when selected. ;============================================================================================================ ;Libraries Inclusions ;============================================================================================================ #include <ColorConstants.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <GuiConstantsEx.au3> #include <Array.au3> #include <GuiButton.au3> #include <StaticConstants.au3> ;============================================================================================================ ;Global Vars ;============================================================================================================ Global $hMainGUI Global $nMsg Global $IdTrayMenuMain Global $IdTrayMenuExit Main() Func Main() ;------------------------------------------------------------------------------------------------------------ ;Create Main Window ;------------------------------------------------------------------------------------------------------------ $hMainGUI = GUICreate("Sample", 1024, 700, 50, 50, BitOR($WS_SYSMENU, $WS_CAPTION, $DS_SETFOREGROUND)) GUISetFont(8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $hMainGUI, $CLEARTYPE_QUALITY) GUISetBkColor(0xDDDDDD, $hMainGUI) GUISetState(@SW_SHOW, $hMainGUI) WinWaitActive($hMainGUI) ;============================================================================================================ ;Create Traymenu ;============================================================================================================ ;Create a Traymenu. $IdTrayMenuMain = TrayCreateItem("Sample", -1, 0) ;Create a Separator line. TrayCreateItem("", -1, -1) ;Create a Menuitem. $IdTrayMenuExit = TrayCreateItem("Exit", -1, -1) ;Show the Traymenu. TraySetState($TRAY_ICONSTATE_SHOW) ;------------------------------------------------------------------------------------------------------------ ;Sample ;------------------------------------------------------------------------------------------------------------ Local $aIconButtons[0] ;Array to manage Buttons Local $aIconBLabels[0] ;Array to manage Buttons Local $iButtonPosLeft = 10 ;Inserting Position X Local $iButtonPosTop = 10 ;Inserting Position Y Local $iButtonCount Local $iIcnPosOffset = 0 Local $iIconCt = _WinAPI_ExtractIconEx("shell32.dll", -1, 0, 0, 0) ;retrieve count of Icons ConsoleWrite("Icons: " & $iIconCt & @CRLF) Local $iIconIdx = 0 ;The Icon Index to begin extracting at Local $tIconsLg = DllStructCreate("HANDLE[" & $iIconCt & "]") Local $pIconsLg = DllStructGetPtr($tIconsLg) Local $tIconsSm = DllStructCreate("HANDLE[" & $iIconCt & "]") Local $pIconsSm = DllStructGetPtr($tIconsSm) $iIconCt = _WinAPI_ExtractIconEx("shell32.dll", $iIconIdx, $pIconsLg, $pIconsSm, $iIconCt) ;Get Large/ Small Icon Handles into arrays ConsoleWrite("Icons Extracted: " & $iIconCt & @CRLF) ; ;; PS Don't Forget _WinAPI_DestroyIcon() For $iButtonCount = 1 To 200 If BitAND($iButtonCount, 1) Then _ArrayAdd($aIconButtons, GUICtrlCreateButton("", $iButtonPosLeft, $iButtonPosTop, 45, 45, $BS_ICON)) ;Icon Only Else _ArrayAdd($aIconButtons, GUICtrlCreateButton($iButtonCount, $iButtonPosLeft, $iButtonPosTop, 45, 45)) ;Icon and Text EndIf _ArrayAdd($aIconBLabels, GUICtrlCreateLabel(1 * ($iButtonCount + $iIcnPosOffset), $iButtonPosLeft, $iButtonPosTop + 45, 45, 15)) GUICtrlSetStyle($aIconBLabels[$iButtonCount - 1], BitOR($SS_CENTER, $SS_CENTERIMAGE)) $iButtonPosLeft = $iButtonPosLeft + 50 If Mod($iButtonCount, 20) = 0 Then $iButtonPosTop = $iButtonPosTop + 70 $iButtonPosLeft = 10 EndIf ;retrieving Icons by positive position ;***************************************************************************************** ;$MessageTemp = GUICtrlSetImage($aIconButtons[$iButtonCount - 1], "shell32.dll", 1 * ($iButtonCount + $iIcnPosOffset) , 1) ;***************************************************************************************** If $iButtonCount < $iIconCt Then If BitAND($iButtonCount, 1) Then GUICtrlSendMsg($aIconButtons[$iButtonCount - 1], $BM_SETIMAGE, $IMAGE_ICON, DllStructGetData($tIconsLg, 1, $iButtonCount)) Else GUICtrlSendMsg($aIconButtons[$iButtonCount - 1], $BM_SETIMAGE, $IMAGE_ICON, DllStructGetData($tIconsSm, 1, $iButtonCount)) EndIf EndIf Next ;Destroy all the extracted icons ConsoleWrite("Destroying Icons" & @CRLF) For $i = 1 To $iIconCt _WinAPI_DestroyIcon(DllStructGetData($tIconsLg, 1, $i)) _WinAPI_DestroyIcon(DllStructGetData($tIconsSm, 1, $i)) Next ;============================================================================================================ ;GUI Loop ;============================================================================================================ While True ;------------------------------------------------------------------------------------------------------------ ;Get GUI-Messages ;------------------------------------------------------------------------------------------------------------ $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then ExitLoop ;------------------------------------------------------------------------------------------------------------ ;Get Traymenu Messages ;------------------------------------------------------------------------------------------------------------ Switch TrayGetMsg() Case $IdTrayMenuExit ;Exit. ExitLoop EndSwitch ;------------------------------------------------------------------------------------------------------------ WEnd EndFunc ;==>Main1 point