Leaderboard
Popular Content
Showing content with the highest reputation on 05/02/2024 in all areas
-
Include file with regional special characters with UTF-8
argumentum reacted to mLipok for a topic
Vacation mode. Till monday trying to be offline.1 point -
This code provides a simple graphical interface for a calculator, allowing operations such as copy, paste, and automatic calculation. However, it lacks comments to explain the different sections and functions. Additionally, user input validation is missing, which could lead to errors if non-numeric data is entered. Better code organization with explanatory comments and the addition of validation mechanisms would enhance its readability and robustness.1 point
-
Bug Fix Made a correction to the word replacement when a user selected the new word. I accidentally broke it in the last release. Sorry.1 point
-
Sort a 2D array on using strings and characters
benners reacted to AspirinJunkie for a topic
You won't find the answer in the UDF code either. There is just a normal array sorting function (with an exchangeable comparison function). The interesting part is in the __comp_benners() function. Sorting is in most cases based on a size comparison of 2 elements. The sorting function goes through the array in a certain pattern - depending on the sorting algorithm - and must always decide which of the two elements it is currently holding is larger than the other. This means that the comparison function is responsible for what the result of a sort looks like. The sorting algorithm itself is only responsible for how to get there. So how do you decide for your case whether an entry in your array is larger (i.e. should be inserted after the smaller element)? In my approach, I take the entries and split them first (regex_split) so that “3 Pasti>Promax>861 & 862” becomes an array with the following content: |3|Pasti|Promax|861 & 862|. The same applies to the comparison value. For example, “3 Pasti>Returns>51” becomes |3|Pasti|Returns|51|. Now the two arrays are compared element by element: 3 = 3 - so nothing is returned yet Pasti = Pasti - so return nothing yet Promax < Returns - so return -1 (means A<B) This is how you work your way through your hierarchy levels. Now comes your special case: If the array sizes are different (because one is a menu and another is a submenu), then this comparison is only carried out up to the second last element. If A has one more element than B, it is returned -1 so that it is sorted before B. As I said, the UDF is not so important - what is important is a suitable comparison function.1 point -
After answering some clipboard questions in the help forum, I found myself writing a couple of helper funcs so I thought I'd share. I don't think I added any headers, I'm probably assuming (maybe to much?) that most will get it (yep, to lazy). Example code: #include "ClipBoardMisc.au3" #include <Array.au3> #cs Example 1 collect all the text/unicode/binary data in an array from clip #ce Global $gaArgs = _cbTest_GetAllData() _ArrayDisplay($gaArgs, Default, Default, Default, Default, _ "Format Type|Data TEXT|Data Unicode|Data Byte|Data ByteStr") Func _cbTest_GetAllData() Local $aClipFormats = _ClipBoard_GetCurrentFormatArray() If @error Then Return SetError(1, 0, Null) Local $aRet[UBound($aClipFormats)][5] ; [n][3] is memory address For $i = 0 To UBound($aClipFormats) - 1 ; Using all CBRT_ globals because I'm to lazy to go through all the CFSTR and do ; exhausting test functions to test what type of strings they are ; See: https://geekdude.io/static/ahk/Constants.W32.ini if you want to get a long list of CFSTR_ options $aRet[$i][0] = $aClipFormats[$i][2] $aRet[$i][1] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_TEXT) $aRet[$i][2] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_UNICODE) $aRet[$i][3] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_BYTE) $aRet[$i][4] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_BYTESTR) Next Return $aRet EndFunc Example 2: Get specific format id types array #include "ClipBoardMisc.au3" #include <Array.au3> ;~ #cs Example 2 ; Make sure you use "copy" on a file to test this ; Func: _ClipBoard_GetTypeArray($sType, $hOwner = 0) ; ; $sType: 1. String to be split by "|" separator char ; 2. Return type to be added similar as a struct ; example: $sType = "Text;str|FileNameW;wstr" ; Separates 2 types of arrays internally ; 1. Type array: [n] = "Text" ; [n] = "FileNameW" ; 2. Return type: [n] = "str" ; [n] = "wstr" ; Valid Format Return Strying types: ; "str" or "chr" ; "wstr" or "wchr" or "unicode" ; "byte" ; "bytestr" ; Return: Success: 2D array ; [n][0] = Found Type ; [n][1] = Found Value ; ; Note: It will not validate if the memory address is valid for your return type Global $ga_Test = _ClipBoard_GetTypeArray("filename;str|filenameW;wstr") If @error Then MsgBox(16, "Error", "Error: " & @error & " :: Extended: " & @extended) Else _ArrayDisplay($ga_Test) EndIf ;~ #ce ; updated zip ClipBoardMisc.zip1 point
-
#include <GUIToolTip.au3> #include <WinAPITheme.au3> #include <WinAPIGdiInternals.au3> HotKeySet("{ESC}", _Exit) Global $hFont = _WinAPI_CreateFont(40, 0) Example() Func Example() ToolTip("Tooltip Test", Default, Default, Default, 0, 1) Local $hWnd = WinWait("Tooltip Test") _WinAPI_SetWindowTheme($hWnd, "", "") _GUIToolTip_SetTipTextColor($hWnd, 0xFFFFFF) _GUIToolTip_SetTipBkColor($hWnd,0x000000) _WinAPI_SetFont(WinGetHandle('Tooltip Test'), $hFont) ToolTip("Tooltip Test", Default, Default, Default, 0, 1) While Sleep(50) $pos = MouseGetPos(0) $pos2 = MouseGetPos(1) WinMove($hWnd, "", $pos, $pos2+20) WEnd EndFunc ;==>Example Func _Exit() _WinAPI_DeleteObject($hFont) Exit EndFunc I figured out how to do. Thank you all. JSON.au3 translate.au31 point
-
There is a way to change the font of the tooltip, size/weight/font etc. I found a function that was written back in 2007 that will work. Here's a demonstration of how to do it, using the example script from the help file, modified with the additional function. #include <GUIConstantsEx.au3> #include <GUIToolTip.au3> #include <WinAPI.au3> #include <FontConstants.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGUI = GUICreate(StringTrimRight(@ScriptName, 4), 350, 200) Local $iAdd = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28) Local $hAdd = GUICtrlGetHandle($iAdd) ; Create a tooltip control Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON) ; If using a Windows theme setting, this will disable that for the tooltip displayed, so you can color it ; it has to be placed before you try to actually set the colors, doing it after will reset the colors. DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hToolTip, "wstr", 0, "wstr", 0) ; The color value used in the _GUIToolTip_SetTipBkColor function is an RGB value _GUIToolTip_SetTipBkColor($hToolTip, 0x395A00) ; The color value used in the _GUIToolTip_SetTipTextColor function is an BGR value _GUIToolTip_SetTipTextColor($hToolTip, 0x1EBFFF) ; add a tool to the tooltip control _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hAdd) _SetFont_hWnd($hToolTip, 20) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop WEnd ; Destroy the tooltip control _GUIToolTip_Destroy($hToolTip) GUIDelete($hGUI) EndFunc ;==>Example ;~ http://www.autoitscript.com/forum/topic/57419-deleting-listviewitem-leaves-a-black-space/?p=441871 Func _SetFont_hWnd($hwnd, $size = 8.5, $weight = 400, $attr = 0, $fontname = "") Local $_tagfont = DllStructCreate($tagLOGFONT) Local $hDC = _WinAPI_GetDC($hwnd) ; lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72) Local $lf_height = -($size * _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY)) / 72 _WinAPI_ReleaseDC($hwnd, $hDC) DllStructSetData($_tagfont, 'Height', $lf_height); DllStructSetData($_tagfont, 'Width', 0); DllStructSetData($_tagfont, 'Escapement', 0); DllStructSetData($_tagfont, 'Orientation', 0); DllStructSetData($_tagfont, 'Weight', $weight); DllStructSetData($_tagfont, 'Italic', BitAND($attr, 0x2)) DllStructSetData($_tagfont, 'Underline', BitAND($attr, 0x4)) DllStructSetData($_tagfont, 'StrikeOut', BitAND($attr, 0x8)) DllStructSetData($_tagfont, 'CharSet', 0); 0 = ANSI_CHARSET DllStructSetData($_tagfont, 'OutPrecision', 0); 0 = OUT_DEFAULT_PRECIS DllStructSetData($_tagfont, 'ClipPrecision', 0); 0 = CLIP_DEFAULT_PRECIS DllStructSetData($_tagfont, 'Quality', 0); 0 = DEFAULT_QUALITY ; 0 = DEFAULT_PITCH, 1 = FIXED_PITCH, 2 = VARIABLE_PITCH ; $FF_DONTCARE = 0 (FF_ROMAN = 16, FF_SWISS = 32, FF_MODERN = 48, FF_SCRIPT = 64, FF_DECORATIVE = 80) DllStructSetData($_tagfont, 'PitchAndFamily', BitOR(0, $FF_DONTCARE)) DllStructSetData($_tagfont, 'FaceName', $fontname); Local $h_font = _WinAPI_CreateFontIndirect($_tagfont) _SendMessage($hwnd, $WM_SETFONT, $h_font, True) EndFunc ;==>_SetFont_hWnd Not 100% sure what it's all doing, but it does work.1 point
-
You might be able to do something similar to this. It's just an example but if it gives you an idea. I use this to recognize when the save bar pops up at the bottom of the screen. Another user helped me with it here a long time ago. Do If WinActive("[Class:IEFrame]") Then Local $hIE = WinGetHandle("[Class:IEFrame]") Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]") Local $aPos = ControlGetPos($hIE, "", $hCtrl) Local $aWinPos = WinGetPos($hIE) If ControlCommand($hIE, "", $hCtrl, "IsVisible") AND $aPos[1] > .75 * $aWinPos[3] Then ; Check if the control is in the bottom 25% of the page. ControlClick($hIE, "", $hCtrl, "primary", 1, $aPos[2] - 160, $aPos[3] - 30) Sleep(500) ControlSend($hIE, "", $hCtrl, "{down}{down}{enter}") EndIf EndIf sleep(100) Until WinExists("Save As")1 point