Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/20/2014 in all areas

  1. [BUGFIX VERSION] - 25 Jun 13 Fixed: A bug in AutoIt v3.3.6.1 could crash the UDF under certain circumstances - other releases do not show the same error. Small code change to prevent error in any release. Thanks to DatMCEyeBall for finding it. New UDF below and in zip. Previous versions: A recent topic dealt with the problem of the dotted focus lines which appear around controls - the most obvious ones are around sliders - and how to get rid of them. A bit of experimentation showed that these focus lines do not always appear. If there is a button in the GUI, they do not seem to appear until the TAB key has been used to change focus in the GUI - if you only use the mouse, they usually remain hidden. However, if there is no button, they appear immediately. I posted some code in the topic to show this. The only solution to permanently remove these lines appeared to be subclassing the controls to bypass the WM_SETFOCUS message, but the necessary code seemed a little daunting to coders less well-versed in the dark side of Autoit (in which category I firmly place myself! ). So once I had understood what was going on in the subclassing process, I thought I might try and make a UDF which would simplify the whole thing for us average Autoit users. A number of other forum members have offered suggestions and code snippets - and here you have the resulting UDF, which prevents focus lines from ruining the visual appearance of buttons, radios, checkboxes and sliders: [NEW] The NoFocusLines.au3 include file: #include-once ; #INDEX# ============================================================================================================ ; Title .........: NoFocusLines ; AutoIt Version : 3.3.4.0 + ; Language ......: English ; Description ...: Prevents dotted focus lines on GUI controls of button and slider classes ; Remarks .......: Once the _Set function has been used to prevent focus lines, the specified controls should be reset ; with the _Clear function before deletion. Note all such controls can be reset in ; one call to the _Clear function without having to specify each individual control. ; The _Global_Set function prevents focus lines on ANY subsequently created button or slider class ; control. However, CAUTION is advised when using the _Global_Set function as even though the use of ; the _Global_Exit function on exit deletes all such controls and frees the memory used by the UDF, ; full clean up relies on internal AutoIt procedures. ; Note ..........: Button class controls include buttons, radios and checkboxes ; Author(s) .....: Melba23, based on code from Siao, aec, martin, Yashied and rover ; ==================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <WinAPI.au3> OnAutoItExitRegister("_NoFocusLines_AutoExit") ; #GLOBAL VARIABLES# ================================================================================================= Global $hNoFocusLines_Proc = 0, $pOrg_SliderProc = 0, $pOrg_ButtonProc = 0, $aHandle_Proc[1][2] = [[0, ""]] ; #CURRENT# ========================================================================================================== ; _NoFocusLines_Set: Prevents dotted focus lines on specified button and slider class controls ; _NoFocusLines_Clear: Resets normal focus lines on specified controls. ; _NoFocusLines_Exit: Used on script exit to reset all subclassed controls and free UDF WndProc memory ; _NoFocusLines_Global_Set: Prevents dotted focus lines on all subsequently created button and slider class controls ; _NoFocusLines_Global_Exit: Used on script exit to delete all subclassed controls and free UDF WndProc memory ; ==================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; _NoFocusLines_SubClass: Sets WndProc for specified control ; _NoFocusLines_Proc: New WndProc to prevent focus lines on specified button and slider class controls ; _NoFocusLines_Global_Proc: New WndProc to prevent focus lines on all subsequently created button and slider controls ; _NoFocusLines_AutoExit: Automatically deletes all controls and frees the memory used on exit ; ==================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _NoFocusLines_Set ; Description ...: Prevents the dotted focus lines on specified button and slider class controls ; Syntax.........: _NoFocusLines_Set($vCID) ; Parameters ....: $vCID - ControlIDs of controls - multiple ControlIDs must be passed as a 0-based array ; Requirement(s).: v3.3 + ; Return values .: Success: Returns number of controls currently subclassed ; Failure: Sets @error as follows: ; 1 = Global function already run ; 2 = Invalid controlID ; Author ........: Melba23, based on code from Siao, aec, martin and Yashied ; Remarks .......: Any controls on which focus lines have been prevented by using the _SET function should be reset via ; the _CLEAR function if deleted prior to exit ; Example........: Yes ;===================================================================================================================== Func _NoFocusLines_Set($vCID) Local $aCID[1] ; Check if Global function already used If $aHandle_Proc[0][1] = "Global" Then Return SetError(1, 0, 0) ; Check parameters are button or slider class controls If Not IsArray($vCID) Then Switch _WinAPI_GetClassName(GUICtrlGetHandle($vCID)) Case "Button", "msctls_trackbar32" $aCID[0] = $vCID Case Else Return SetError(2, 0, 0) EndSwitch Else For $i = 0 To UBound($vCID) - 1 Switch _WinAPI_GetClassName(GUICtrlGetHandle($vCID[$i])) Case "Button", "msctls_trackbar32" ; ContinueLoop Case Else Return SetError(2, 0, 0) EndSwitch Next $aCID = $vCID EndIf ; Check if _NoFocusLines_Proc has been registered If $hNoFocusLines_Proc = 0 Then ; Register callback function and obtain handle to _NoFocusLines_Proc $hNoFocusLines_Proc = DllCallbackRegister("_NoFocusLines_Proc", "int", "hwnd;uint;wparam;lparam") EndIf ; Get pointer to _NoFocusLines_Proc Local $pNoFocusLines_Proc = DllCallbackGetPtr($hNoFocusLines_Proc) ; Work through CIDs For $i = 0 To UBound($aCID) - 1 ; Get handle for control Local $hHandle = GUICtrlGetHandle($aCID[$i]) ; Check if control is already subclassed For $j = 1 To $aHandle_Proc[0][0] ; Skip if so If $hHandle = $aHandle_Proc[$j][0] Then ContinueLoop 2 EndIf Next ; Increase control count $aHandle_Proc[0][0] += 1 ; Double array size if too small (fewer ReDim needed) If UBound($aHandle_Proc) <= $aHandle_Proc[0][0] Then ReDim $aHandle_Proc[UBound($aHandle_Proc) * 2][2] ; Store control handle $aHandle_Proc[$aHandle_Proc[0][0]][0] = $hHandle ; Subclass control and store pointer to original WindowProc $aHandle_Proc[$aHandle_Proc[0][0]][1] = _NoFocusLines_SubClass($hHandle, $pNoFocusLines_Proc) ; If error in subclassing then remove this control from the array If $aHandle_Proc[$aHandle_Proc[0][0]][1] = 0 Then $aHandle_Proc[0][0] -= 1 Next ; Remove any empty elements after a ReDim ReDim $aHandle_Proc[$aHandle_Proc[0][0] + 1][2] ; Check if subclassing was successful If $aHandle_Proc[0][0] > 0 Then $aHandle_Proc[0][1] = "Local" Else ; Free WndProc memory DllCallbackFree($hNoFocusLines_Proc) $hNoFocusLines_Proc = 0 EndIf Return $aHandle_Proc[0][0] EndFunc ;==>_NoFocusLines_Set ; #FUNCTION# ========================================================================================================= ; Name...........: _NoFocusLines_Clear ; Description ...: Repermits the dotted focus lines on controls if previously prevented by _NoFocusLines_Set ; Syntax.........: _NoFocusLines_Clear($vCID) ; Parameters ....: $vCID - ControlIDs of control(s) - multiple ControlIDs must be passed as a 0-based array ; If no parameter passed, all previously set controls are reset ; Requirement(s).: v3.3 + ; Return values .: Success: Returns number of controls currently subclassed ; Failure: Sets @error as follows: ; 1 = Global function already run ; 2 = Invalid controlID ; Author ........: Melba23, based on code from Siao, aec, martin and Yashied ; Remarks .......: If controls which have had focus lines removed by the _SET function are deleted before the script ; exits, it is advisable to use this function on them BEFORE deletion. ; Example........: Yes ;===================================================================================================================== Func _NoFocusLines_Clear($vCID = "") Local $aCID[1] ; Check if Global function already used If $aHandle_Proc[0][1] = "Global" Then Return SetError(1, 0, 0) If $vCID = "" Then ; Reset all controls to original WndProc For $i = 1 To $aHandle_Proc[0][0] _NoFocusLines_SubClass($aHandle_Proc[$i][0], $aHandle_Proc[$i][1]) Next ; Reset array Dim $aHandle_Proc[1][2] = [[0, "Local"]] Else ; Check parameters are valid If Not IsArray($vCID) Then If Not IsHWnd(GUICtrlGetHandle($vCID)) Then Return SetError(2, 0, 0) $aCID[0] = $vCID Else For $i = 0 To UBound($vCID) - 1 If Not IsHWnd(GUICtrlGetHandle($vCID[$i])) Then Return SetError(2, 0, 0) Next $aCID = $vCID EndIf ; For each specified control For $j = 0 To UBound($aCID) - 1 ; Run through array to see if control has been subclassed For $i = 1 To $aHandle_Proc[0][0] ; Control found If $aHandle_Proc[$i][0] = GUICtrlGetHandle($aCID[$j]) Then ; Unsubclass the control _NoFocusLines_SubClass($aHandle_Proc[$i][0], $aHandle_Proc[$i][1]) ; Remove control handle and orginal WindowProc from array $aHandle_Proc[$i][0] = 0 $aHandle_Proc[$i][1] = 0 EndIf Next Next ; Remove zeroed elements of array For $i = $aHandle_Proc[0][0] To 1 Step -1 If $aHandle_Proc[$i][0] = 0 Then ; Reduce control count $aHandle_Proc[0][0] -= 1 ; Move up all following elements For $j = $i To $aHandle_Proc[0][0] $aHandle_Proc[$j][0] = $aHandle_Proc[$j + 1][0] $aHandle_Proc[$j][1] = $aHandle_Proc[$j + 1][1] Next EndIf Next ReDim $aHandle_Proc[$aHandle_Proc[0][0] + 1][2] EndIf Return $aHandle_Proc[0][0] EndFunc ;==>_NoFocusLines_Clear ; #FUNCTION# ==================================================================================================================== ; Name...........: _NoFocusLines_Exit ; Description ...: Resets any remaining subclassed controls and frees the memory used by the UDF created WndProc ; Syntax.........: _NoFocusLines_Exit() ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Melba23 ; Remarks .......: This function should be called on exit to avoid reliance on internal AutoIt procedures for memory clean up ; Example........: Yes ;================================================================================================================================ Func _NoFocusLines_Exit() ; Check if _Set function used If $aHandle_Proc[0][1] <> "Local" Then Return SetError(1, 0, 0) ; First unsubclass any remaining subclassed controls _NoFocusLines_Clear() ; Now free UDF created WndProc DllCallbackFree($hNoFocusLines_Proc) Return 1 EndFunc ;==>_NoFocusLines_Exit ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _NoFocusLines_Proc ; Description ...: Replacement WindowProc to prevent focus lines appearing on button and slider class controls ; Author ........: Melba23, based on code from Siao, aec, martin and Yashied ; Modified.......: ; Remarks .......: This function is used internally by _NoFocus_Set ; =============================================================================================================================== Func _NoFocusLines_Proc($hWnd, $iMsg, $wParam, $lParam) ; Ignore SETFOCUS message from all subclassed controls If $iMsg = 0x0007 Then Return 0 ; $WM_SETFOCUS ; Locate control handle in array For $i = 1 To $aHandle_Proc[0][0] ; And pass other messages to original WindowProc If $hWnd = $aHandle_Proc[$i][0] Then Return _WinAPI_CallWindowProc($aHandle_Proc[$i][1], $hWnd, $iMsg, $wParam, $lParam) Next EndFunc ;==>_NoFocusLines_Proc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _NoFocusLines_SubClass ; Description ...: Sets new WindowProc for controls ; Syntax ........: _NoFocusLines_SubClass($hWnd, $pNew_WindowProc) ; Parameters ....: $hWnd - Handle of control to subclass ; $pNew_WindowProc - Pointer to new WindowProc ; Author ........: Melba23, based on code from Siao, aec and martin ; Modified.......: ; Remarks .......: This function is used internally by _NoFocusLines_Set and _NoFocusLines_Clear ; =============================================================================================================================== Func _NoFocusLines_SubClass($hWnd, $pNew_WindowProc) Local $iRes = _WinAPI_SetWindowLong($hWnd, -4, $pNew_WindowProc) If @error Then Return SetError(1, 0, 0) If $iRes = 0 Then Return SetError(1, 0, 0) Return $iRes EndFunc ;==>_NoFocusLines_SubClass ; #FUNCTION# ==================================================================================================================== ; Name...........: _NoFocusLines_Global_Set ; Description ...: Prevents the dotted focus lines on ALL subsequently created button and slider class controls ; Syntax.........: _NoFocusLines_Global_Set() ; Requirement(s).: v3.3 + ; Return values .: Success: 1 ; Failure: 0 and sets @error as follows: ; 1 = Specific function already run ; Author ........: rover ; Remarks .......: The _Global Exit function should be called on script exit ; Note ..........; CAUTION is advised when using the _Global_Set function as even though the use of the _Global_Exit function on ; exit deletes all such controls and frees the memory used by the UDF, full clean up relies on internal AutoIt ; procedures. ; Example........: Yes ;================================================================================================================================ Func _NoFocusLines_Global_Set() ; Run once check If $aHandle_Proc[0][1] <> "" Then Return SetError(1, 0, 0) ; Create callback $hNoFocusLines_Proc = DllCallbackRegister("_NoFocusLines_Global_Proc", "int", "hwnd;uint;wparam;lparam") Local $pCallbackPtr = DllCallbackGetPtr($hNoFocusLines_Proc) ; Create temp gui with button and slider Local $hGUITemp = GUICreate("", 1, 1, -10, -10) Local $hButtonTemp = GUICtrlGetHandle(GUICtrlCreateButton("", -10, -10, 1, 1)) Local $hSliderTemp = GUICtrlGetHandle(GUICtrlCreateSlider(-10, -10, 1, 1)) ; Globally subclass Button class (includes buttons, radios and checkboxes) $pOrg_ButtonProc = DllCall("User32.dll", "dword", "SetClassLongW", "hwnd", $hButtonTemp, "int", -24, "ptr", $pCallbackPtr) $pOrg_ButtonProc = $pOrg_ButtonProc[0] ; Globally subclass Slider(Trackbar) class $pOrg_SliderProc = DllCall("User32.dll", "dword", "SetClassLongW", "hwnd", $hSliderTemp, "int", -24, "ptr", $pCallbackPtr) $pOrg_SliderProc = $pOrg_SliderProc[0] GUIDelete($hGUITemp) $aHandle_Proc[0][1] = "Global" Return SetError(0, 0, 1) EndFunc ;==>_NoFocusLines_Global_Set ; #FUNCTION# ==================================================================================================================== ; Name...........: _NoFocusLines_Global_Exit ; Description ...: Deletes all controls and frees the memory used by the UDF created WndProc ; Syntax.........: _NoFocusLines_Global_Exit() ; Requirement(s).: v3.3 + ; Return values .: None ; Author ........: Melba23 ; Remarks .......: This function should be called on script exit if the _Global_Set function has been used ; Note ..........; CAUTION is advised as even though the use of the _Global_Exit function on exit deletes all controls and frees ; the memory used by the UDF, full clean up relies on internal AutoIt procedures. ; Example........: Yes ;================================================================================================================================ Func _NoFocusLines_Global_Exit() ; Check if _Set function used If $aHandle_Proc[0][1] <> "Global" Then Return SetError(1, 0, 0) ; First delete all controls - any subclassed controls are now deleted For $i = 3 To 65532 GUICtrlDelete($i) Next ; Now free UDF created WndProc DllCallbackFree($hNoFocusLines_Proc) Return 1 EndFunc ;==>_NoFocusLines_Global_Exit ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _NoFocusLines_AutoExit ; Description ...: Automatically deletes all controls and frees the memory used by the UDF created WndProc on exit ; Author ........: M23 ; Modified.......: ; Remarks .......: This function is used internally by NoFocusLines ; =============================================================================================================================== Func _NoFocusLines_AutoExit() Switch $aHandle_Proc[0][1] Case "Global" _NoFocusLines_Global_Exit() Case "Local" _NoFocusLines_Exit() EndSwitch EndFunc ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _NoFocusLines_Global_Proc ; Description ...: Replacement WindowProc to prevent focus lines appearing on button and slider class controls ; Author ........: rover ; Modified.......: ; Remarks .......: This function is used internally by _NoFocusLines_Global_Set ; =============================================================================================================================== Func _NoFocusLines_Global_Proc($hWnd, $iMsg, $wParam, $lParam) If $iMsg = 0x0007 Then Return 0 ; $WM_SETFOCUS Switch _WinAPI_GetClassName($hWnd) Case "Button" ; pass the unhandled messages to default ButtonProc Return _WinAPI_CallWindowProc($pOrg_ButtonProc, $hWnd, $iMsg, $wParam, $lParam) Case "msctls_trackbar32" ; pass the unhandled messages to default SliderProc Return _WinAPI_CallWindowProc($pOrg_SliderProc, $hWnd, $iMsg, $wParam, $lParam) Case Else Return 0 EndSwitch EndFunc ;==>_NoFocusLines_Global_Proc [NEW] And an example script to show it working - and to show it does not affect other aspects of the control behaviour. It assumes the include is in the same folder. #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include "NoFocusLines.au3" Global $aCID[1] $iPos_1 = 0 $iPos_2 = 0 $fGlobal = False $hGUI = GUICreate("Choose Method", 200, 140) $sMsg = "Choose how you want the focus lines to be removed:" & @CRLF & @CRLF & _ "Global" & @TAB & "= All controls permanently" & @CRLF & _ "Specific" & @TAB & "= By choice" GUICtrlCreateLabel($sMsg, 10, 10, 180, 70) $hRadio_1 = GUICtrlCreateRadio("Global", 10, 90, 90, 20) $hRadio_2 = GUICtrlCreateRadio("Specific", 10, 110, 90, 20) GUICtrlSetState(-1, $GUI_CHECKED) $hButton_OK = GUICtrlCreateButton("OK", 110, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_OK ExitLoop EndSwitch WEnd ; If required remove focus lines from all controls If GUICtrlRead($hRadio_1) = $GUI_CHECKED Then If _NoFocusLines_Global_Set() = 1 Then $fGlobal = True ConsoleWrite("Global: " & @error & @CRLF) EndIf GUIDelete($hGUI) $hGUI = GUICreate("Subclassed Controls without Focus Lines", 500, 210) $hLabel_S1 = GUICtrlCreateLabel("Slider 1: " & $iPos_1, 20, 15, 100) $hLabel_S2 = GUICtrlCreateLabel("Slider 2: " & $iPos_2, 20, 115, 100) $hSlider_1 = GUICtrlCreateSlider(20, 50, 160, 30) $hSlider_2 = GUICtrlCreateSlider(20, 150, 160, 30) $hLabel_B1 = GUICtrlCreateLabel("", 200, 15, 80, 20) $hLabel_B2 = GUICtrlCreateLabel("", 200, 115, 80, 20) $hButton_1 = GUICtrlCreateButton("Button 1", 200, 50, 90, 30) $hButton_2 = GUICtrlCreateButton("Button 2", 200, 150, 90, 30) $hLabel_R1 = GUICtrlCreateLabel("", 300, 15, 80, 20) $hLabel_R2 = GUICtrlCreateLabel("", 300, 115, 80, 20) $hRadio_1 = GUICtrlCreateRadio("Radio 1", 300, 35, 90, 20) $hRadio_2 = GUICtrlCreateRadio("Radio 2", 300, 135, 90, 20) $hLabel_C1 = GUICtrlCreateLabel("", 300, 65, 80, 20) $hLabel_C2 = GUICtrlCreateLabel("", 300, 165, 80, 20) $hCheck_1 = GUICtrlCreateCheckbox("Check 1", 300, 85, 90, 20) $hCheck_2 = GUICtrlCreateCheckbox("Check 2", 300, 185, 90, 20) $hButton_Action = GUICtrlCreateButton("Hide upper control focus lines", 400, 45, 80, 50, $BS_MULTILINE) $hButton_Tab = GUICtrlCreateButton("Show all control focus lines", 400, 145, 80, 50, $BS_MULTILINE) $hLabel_Global = GUICtrlCreateLabel("Global = " & $fGlobal, 400, 15, 100) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE #cs If $fGlobal = true Then _NoFocusLines_Global_Exit() Else _NoFocusLines_Exit() EndIf #ce Exit Case $hButton_1 GUICtrlSetData($hLabel_B1, "Button pressed") Sleep(500) GUICtrlSetData($hLabel_B1, "") Case $hButton_2 GUICtrlSetData($hLabel_B2, "Button pressed") Sleep(500) GUICtrlSetData($hLabel_B2, "") Case $hRadio_1 If GUICtrlRead($hRadio_1) = $GUI_CHECKED Then GUICtrlSetData($hLabel_R1, "Selected") GUICtrlSetData($hLabel_R2, "") Else GUICtrlSetData($hLabel_R2, "Selected") GUICtrlSetData($hLabel_R1, "") EndIf Case $hRadio_2 If GUICtrlRead($hRadio_2) = $GUI_CHECKED Then GUICtrlSetData($hLabel_R2, "Selected") GUICtrlSetData($hLabel_R1, "") Else GUICtrlSetData($hLabel_R1, "Selected") GUICtrlSetData($hLabel_R2, "") EndIf Case $hCheck_1 If GUICtrlRead($hCheck_1) = $GUI_CHECKED Then GUICtrlSetData($hLabel_C1, "Selected") Else GUICtrlSetData($hLabel_C1, "") EndIf Case $hCheck_2 If GUICtrlRead($hCheck_2) = $GUI_CHECKED Then GUICtrlSetData($hLabel_C2, "Selected") Else GUICtrlSetData($hLabel_C2, "") EndIf Case $hButton_Action ; Remove focus lines from slider_1 _NoFocusLines_Set($hSlider_1) ConsoleWrite("Slider: " & @error & @CRLF) ; Remove focus lines from top button, radio and checkbox Dim $aCID[4] = [$hButton_1, $hRadio_1, $hCheck_1, $hButton_Action] ; Place multiple ControlIDs in an array _NoFocusLines_Set($aCID) ConsoleWrite("Button: " & @error & @CRLF) ; Shows it will not work if used with other control type _NoFocusLines_Set($hLabel_B1) ConsoleWrite("Label: " & @error & @CRLF) ; Show Global function will not work after Specific, or previous Global, call _NoFocusLines_Global_Set() ConsoleWrite("Global: " & @error & @CRLF) Case $hButton_Tab ; Force focus lines to appear Send("{TAB}") ; Allow lines to appear Dim $aCID[5] = [$hSlider_1, $hButton_1, $hRadio_1, $hCheck_1, $hButton_Action] _NoFocusLines_Clear($aCID) ConsoleWrite("Clear: " & @error & @CRLF) EndSwitch If GUICtrlRead($hSlider_1) <> $iPos_1 Then $iPos_1 = GUICtrlRead($hSlider_1) GUICtrlSetData($hLabel_S1, "Slider 1: " & $iPos_1) EndIf If GUICtrlRead($hSlider_2) <> $iPos_2 Then $iPos_2 = GUICtrlRead($hSlider_2) GUICtrlSetData($hLabel_S2, "Slider 2: " & $iPos_2) EndIf WEnd On running the example script you are asked to choose either "Global" or "Specific" mode: "Global" mode permanently prevents focus lines on all controls - there is no easy way to reallow the lines (or at least one I am prepared to develop!). "Specific" mode allows you to prevent/allow the focus lines on specified controls. At first, as long as you only use the mouse to change focus you should find no focus lines on the controls - because a button is present. Pressing the "Show all focus lines" button, or pressing TAB yourself to change focus, will allow the lines become visible when the control has focus - remember you still have to select the sliders with the mouse, they have no TABSTOP property. Pressing the "Hide upper" button will, not surprisingly, prevent the lines from appearing on the top set of controls (if one of these controls has focus at that time, the lines will remain until the focus is changed - obviously we cannot intercept a previous message!). Repressing the "Show all focus lines" button will reallow focus lines on the upper controls. You can toggle the lines on and off as often as you wish. The 2 modes are obviously mutually exclusive - but the UDF will automatically detect the first mode used and prevent the other from running. This can be seen as the example script runs and the various errorlevels from the UDF calls made are printed in the SciTE console. A few points: 1. As previously stated, the _NoFocusLines_Global function can only be called once - BEFORE any controls are created. The _NoFocusLines_Set and _NoFocusLines_Clear functions can be called as and when required - but only AFTER the specified controls have been created. 2. When you want to delete controls which have been subclassed by _NoFocusLines_Set before the script exits, you should use _NoFocusLines_Clear before deleting - just in case Windows reallocates the handle. [NEW] Calling _NoFocusLines_Clear with no parameter resets all currently subclassed controls without having to specify the ControlIDs. 3. [NEW] In either mode, on finally exiting the script, AutoIt will run the cleanup script to delete all subclassed controls and free the memory used by the UDF created WndProc. 4. The "Specific" mode functions require the ControlIDs in array format if there is more than one. I accept that this means having to declare an array just to use the function, but I could not think of any other way to get an undefined number of parameters into the function. 5. The code uses _WinAPI_SetWindowLong, which according to MSDN means that it will not work on x64 systems. If anyone wants to modify the code for x64, please do so. [NEW] Here are the 2 files in zip form: NoFocusLines.zip Just to reiterate my thanks to Siao, aec and martin, whose basic code I plundered without pity; Yashied, whose "hint" made the whole UDF much better; rover for the "Global" mode code; and Valik for advice on the exit strategy. "Standing on the shoulders of giants", as Newton once put it, always makes life easier! As always, happy to hear comments and suggestions. M23
    1 point
  2. Nariwan

    AutoIT Game

    Hello all, here's a little game I made. First it was just messing around and learning with AutoIT. But it got more than I thought. Does it has cool graphics and such? No, it's mostly just text and words. It's a everytime randomly generated encounter based RPG. But Shop items are everytime randomly generated, the items you may get...and so on. Four classes are available. Controls: Upper Arrowkey = Move X = Attack ( Or leave shop ) C = Healing ( And leave chest ) V = Potion B = Shop ( if available ) ESC = Exit If you find any bugs or so just let me know. ( Because there are some and may are more.. ) The same with any improvements or so. Wanrpg.zip
    1 point
  3. guinness

    IsNumber()

    Use StringIsDigit() OR StringIsFloat().
    1 point
  4. Melba23

    _ArrayUniq() Problem

    Ahmed97, Thanks for changing your nick. You can get just the multiple entries like this: #include <Array.au3> Global $x[1] ; Dim is deprecated For $i = 1 To 15 _ArrayAdd($x, $i) ; These are numeric values Next _ArrayAdd($x, 12) ; As are these when used without the "" _ArrayAdd($x, 10) _ArrayAdd($x, 7) ; Get the unique entries $xUNQ = _ArrayUnique($x) ; Now loop through the main array For $i = UBound($x) - 1 To 0 Step -1 ; Can we find the match in the unique array? $iMatch = _ArraySearch($xUNQ, $x[$i], 1) If $iMatch <> - 1 Then ; If so then dlete from both arrays ConsoleWrite("Deleting: " & $x[$i] & @CRLF) _ArrayDelete($x, $i) _ArrayDelete($xUNQ, $iMatch) EndIf Next ; And we should end up with just the multiple entries _ArrayDisplay($x, "Multiple", Default, 8) All clear? M23
    1 point
  5. VIP, A grain of common sense please. mLipok explicitely told us that: and LCID 0415 is ... Polish, unsurprisingly since the OP is Polish.
    1 point
  6. Melba23

    _ArrayUniq() Problem

    AhmedVirus, The code you posted will not function as you think it will as you are adding numeric values in the loop and string values subsequently. AutoIt sees these as different values and so will return both 7 and "7" as "unique". The following code runs fine for me in 3.3.10.2: #include <array.au3> Global $x[1] ; Dim is deprecated For $i = 1 To 15 _ArrayAdd($x, $i) ; These are numeric values Next _ArrayAdd($x, 12) ; As are these when used without the "" _ArrayAdd($x, 10) _ArrayAdd($x, 7) _ArrayDisplay($x) $xUNQ = _ArrayUnique($x, 1) _ArrayDisplay($xUNQ) As I no longer have 3.3.8.1 on this machine I have no idea why you had the error - the code certainly runs cleanly in the current release (and with a subtle change in the latest Beta as well). M23 P.S. I would be grateful I would change your display name - we do not support malware here and your current nick is not acceptable.
    1 point
  7. trancexx

    AutoIt v3.3.11.4 Beta

    ^^ You are just showing off. Like: "hey people look, I can draw graph using arraydisplay". I like it.
    1 point
×
×
  • Create New...