Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/16/2025 in all areas

  1. different approach #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WinAPIDlg.au3> _Main() Func _Main() Local $hGUI = GUICreate("Example", 250, 100) GUICtrlCreateLabel("Type name here (max 12 chars)", 20, 20) Local $idEditName = GUICtrlCreateEdit("", 20, 40, 160, 20, $ES_AUTOHSCROLL) GUICtrlSetLimit($idEditName, 12) Local $idEditResult = GUICtrlCreateEdit("", 20, 65, 160, 20, $ES_READONLY, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; Check if the active control is $idEditName If _WinAPI_GetDlgCtrlID(ControlGetHandle($hGUI, "", ControlGetFocus($hGUI))) = $idEditName Then Local $sValue = _InputLimiter($idEditName) If $sValue <> "" Then GUICtrlSetData($idEditResult, $sValue) EndIf WEnd EndFunc Func _InputLimiter($iCtrlInput, $iMaxBaseLength = 12, $sSuffix = "-PC") Local Static $sLastValue Local $sCurrentValue = GUICtrlRead($iCtrlInput) If $sCurrentValue <> $sLastValue Then $sLastValue = $sCurrentValue Return StringLeft($sCurrentValue, $iMaxBaseLength) & $sSuffix EndIf Return "" EndFunc Edit: variant with more advanced limiter Func _InputLimiter($iCtrlInput, $iMaxBaseLength = 12, $sSuffix = "-PC") Local Static $sLastValue Local $sCurrentValue = GUICtrlRead($iCtrlInput) Local $sFilteredValue = StringRegExpReplace($sCurrentValue, "[^a-zA-Z0-9]", "") If $sFilteredValue <> $sCurrentValue Then GUICtrlSetData($iCtrlInput, $sFilteredValue) Return "" EndIf If $sFilteredValue <> $sLastValue Then $sLastValue = $sFilteredValue ; Update static ConsoleWrite("$sCurrentValue=" & $sCurrentValue & @CRLF) ; For debugging Return StringLeft($sFilteredValue, $iMaxBaseLength) & $sSuffix EndIf Return "" EndFunc
    2 points
  2. funkey I couldn't adapt this command to my script. However, ioa747 helped me with this. Anyway, I appreciate your help. iao747 Thank you very much for your answer. It worked very well for me. I adapted it to use WM_COMMAND. I don't know if it's a problem, but I prefer it this way. Since I want to block special characters only when I type in the second edit, I chose to call StringRegExpReplace only for the second edit. This way, I can type "รค" in $Edit2 and "a" will appear in $Edit4. Example: Func _LimitCaracte($Caracte) $string = GUICtrlRead($Caracte) $string1 = StringRegExpReplace($string, "[ä]", "a") Return $string1 EndFunc
    1 point
  3. WildByDesign

    DwmColorBlurMica

    Good news! I've got the custom per-app / per-class functions working. So we can do custom rules with the full spectrum of options. The was the hard part. The last part that I have to do still is the easy part and that involves falling back to global coloring options (if set) for anything else that does not have custom rules or is not on the exclusion lists.
    1 point
  4. I use this to be able to write to console in any case (compiled or not): Global $CW = @Compiled ? __ConsoleWrite : _ConsoleWrite Func __ConsoleWrite(ByRef $s) Local Static $hCon = __ConsoleInit() DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hCon, "wstr", $s & @LF, "dword", StringLen($s) + 1, "dword*", 0, "ptr", 0) Return EndFunc ;==>__ConsoleWrite Func __ConsoleInit() DllCall("kernel32.dll", "bool", "AllocConsole") Return DllCall("kernel32.dll", "handle", "GetStdHandle", "int", -11)[0] EndFunc ;==>__ConsoleInit ; Unicode-aware ConsoleWrite Func _ConsoleWrite($s) ConsoleWrite(BinaryToString(StringToBinary($s & @LF, 4), 1)) EndFunc ;==>_ConsoleWrite I setup the SciTE console to Unicode, so that's why the last function is needed. Use it like that: $CW("some text" & @LF)
    1 point
  5. Jos

    Correct syntax of "If NOT"

    Are you sure about that? Strait from the helpfile: Jos
    0 points
  6. j0kky

    Correct syntax of "If NOT"

    It's because that's an implicit logical operator rule, just like +-*/ priority in math
    0 points
×
×
  • Create New...