Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/03/2022 in all areas

  1. Nine

    GIF Animation (cached)

    I had this GIF animation script, but it was kind of slow when multiple GIFs were displayed. And then Bilgus posted a framework of how to use GDI+ Cached Bitmaps. I transformed my script and was very happy of the result. Hope you like it too. I enclosed the GIF, the UDF and the example into the zip file. ps. Hope KaFu won't mind as I used his avatar in the example Version 2023-08-15 * Added support for SetOnEvent GUI, while deletion of controls happens frequently * Optimized some minor code parts * Solved a possible stack overflow issue Version 2022-12-06 * Added support to transparent GIF over window background. The type of GIF that necessitate erasure between frames. Version 2022-04-07 * Added double buffering for all GIF * Added ability to erase each frame before repainting, thru a new optional parameter. This is required when the frames do not cover the whole area, leaving a trace of the previous frame. * Added support for the usage of the Default keyword for optional parameters Version 2020-12-20 * Changed frame delays from 0 to a minimum delay to prevent CPU overload Version 2020-12-02 * Reuse empty slots left by the deletion of GIF controls * Corrected bugs Version 2020-12-01 * Added support to delete a GIF control Version 2020-11-29 * Corrected bug on unregister adlib function (thanks to PixelSearch) Included in the zip file 2 examples. One with multiple GIF. Second with transparent GIF over a window background. Cached GIF Animation.zip
    1 point
  2. GuiFlatButton is a UDF to easily create regular buttons with different colors for background, foreground, border, hover, focus, etc.. This started as an effort to change the background color of a button and eventually grew into a full UDF. If you've looked around forums for changing button background colors, you have probably noticed that each proposed workaround has its own set of issues/side-effects. The answers usually circle back to 'use ownerdrawn buttons' and 'not worth it'. Well, now it is possible for anyone to easily create ownerdrawn buttons - totally worth it! Some issues with other workarounds such as drawing with GDI+ or using a colored label as a 'button': Not 'real' buttons so you lose built-in functionality that windows gives to buttons Messy / inefficient code in the main while loop to check for mouse position Slow to respond to click, paint, etc... Having to deal with GUIRegisterMsg messages Not straight-forward to implement GuiFlatButton is not a workaround; it is a technique to respond to Windows' built-in owner-drawn button events. With minimal effort, we can now create true simple colored buttons. The idea is to create an owner-drawn button using GUICtrlCreateButton then subclass the GUI and controls to handle the button-specific events to paint it however we want. This UDF magically does all of this for us! No need to worry about event handling or main while loop logic. How to use It couldn't be any easier! Simply create a new button using the familiar syntax. This creates an ownerdrawn button with default colors. $mybutton1 = GuiFlatButton_Create("Button 1", 78, 20, 120, 40) If you want to change the background and text colors: GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) Advanced Usage Set background/text/border all at once GuiFlatButton_SetColors(-1, 0x0000FF, 0xFFFFFF, 0x9999FF) Set ALL colors for ALL button states! (normal, focus, hover, selected) Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetColorsEx(-1, $aColorsEx) Set default colors to apply to any future buttons ;set colors GuiFlatButton_SetDefaultColors(0x0000FF, 0xFFFFFF, 0x9999FF) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Set ALL color defaults ;set colors Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Available Functions Simple Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;GUI with one button Func Example() Local $hGUI, $mybutton1 $hGUI = GUICreate("GuiFlatButton Ex0", 275, 120) GUISetBkColor(0x333333) Local $idLabel = GUICtrlCreateLabel("Click the button", 10, 100, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) ;create new button then set the background and foreground colors $mybutton1 = GuiFlatButton_Create("Button 1" & @CRLF & "Line 2", 78, 20, 120, 40, $BS_MULTILINE) GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $mybutton1 $i += 1 GUICtrlSetData($idLabel, $i) ConsoleWrite($i & @CRLF) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Menu/Toolbar Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;Example GUI with toolbar Func Example() Local $hGUI, $idLabel, $aButtons, $iTbSize $hGUI = GUICreate("GuiFlatButton Ex2", 300, 200) GUISetBkColor(0x444444) $idLabel = GUICtrlCreateLabel("Click a button", 10, 180, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) $aButtons = createToolbar() $iTbSize = UBound($aButtons) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aButtons[0] To $aButtons[$iTbSize - 1] ConsoleWrite("1") GUICtrlSetData($idLabel, GuiFlatButton_Read($iMsg)) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Func createToolbar() Local $aButtons[6] Local $bkColor = 0x777777 Local $textColor = 0xFFFFFF Local $borderColor = 0x999999 Local $aBtnClrs[12] = [0x777777, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x888888, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x999999, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x666666, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT] For $i = 0 To UBound($aButtons) - 1 $aButtons[$i] = GuiFlatButton_Create("B" & $i, $i * 50, 0, 50, 17) GuiFlatButton_SetColorsEx($aButtons[$i], $aBtnClrs) Next Return $aButtons EndFunc ;==>createToolbar Icon Example You can even easily add icons to your buttons -- just create a new button and send it an icon! #include <GDIPlus.au3> #include "GuiFlatButton.au3" Example() ;buttons with Icon images Func Example() ;get images for demonstration _GDIPlus_Startup() ;initialize GDI+ Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 258, 24, 24) ;extract the 'Save' icon Local $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) ;Create Bitmap from Icon (for demonstration) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;Create HBitmap from Bitmap _GDIPlus_BitmapDispose($hBitmap) ;dispose the bitmap _GDIPlus_Shutdown() ;done with GDI+ Local $hGUI = GUICreate("GuiFlatButton Ex5", 255, 400) GUISetBkColor(0xEEEEEE) ;set default colors of future buttons Local $aColorsEx = _ [0xE2E5E8, 0X000000, 0x888888, _ ; normal : Background, Text, Border 0xE2E5E8, 0X000000, 0x333333, _ ; focus : Background, Text, Border 0xE8E8E8, 0X000000, 0x666666, _ ; hover : Background, Text, Border 0xDDDDDD, 0X000000, 0xAAAAAA] ; selected : Background, Text, Border GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;normal button with icon $label1 = GUICtrlCreateLabel( "$BS_TOOLBUTTON -->", 5, 10) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Local $mybutton1 = GuiFlatButton_Create("Save", 130, 5, 50, 48, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybutton1), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top Local $mybuttonT = GuiFlatButton_Create("Top", 5, 65, 120, 55, $BS_TOP) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonT), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-left Local $mybuttonTL = GuiFlatButton_Create("Top-Left", 5, 125, 120, 55, BITOR($BS_TOP, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-right Local $mybuttonTR = GuiFlatButton_Create("Top-Right", 5, 185, 120, 55, BITOR($BS_TOP, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align left Local $mybuttonL = GuiFlatButton_Create("Left", 5, 245, 120, 55, $BS_LEFT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom Local $mybuttonB = GuiFlatButton_Create("Bottom", 130, 65, 120, 55, $BS_BOTTOM) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonB), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-left Local $mybuttonBL = GuiFlatButton_Create("Bottom-Left", 130, 125, 120, 55, BITOR($BS_BOTTOM, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-right Local $mybuttonBR = GuiFlatButton_Create("Bottom-Right", 130, 185, 120, 55, BITOR($BS_BOTTOM, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align right Local $mybuttonR = GuiFlatButton_Create("Right", 130, 245, 120, 55, $BS_RIGHT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) GuiFlatButton_SetState($mybuttonR, $GUI_DISABLE ) ;disabled Local $mybuttonDisable = GuiFlatButton_Create("Disabled", 130, 310, 120, 55, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonDisable), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GuiFlatButton_SetState($mybuttonDisable, $GUI_DISABLE ) ;clean up! _WinAPI_DestroyIcon( $hIcon ) _WinAPI_DeleteObject( $hHBitmap ) GUISetState(@SW_SHOW, $hGUI) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example I'm sure there are some use-cases I've forgotten, so feedback is welcome! Download the latest UDF and several more examples: GuiFlatButton_20220919.zip (1,121) Update 2022-09-19 Added update from 05/25 back in after it was accidentally removed Update 2022-09-01 Added $BS_MULTILINE button style Added ellipses when text is longer than the button Fixed compatibility with Opt("MustDeclareVars", 1) Update 2022-05-25 Fixed issue, buttons disappear when a GUI containing a child window with WS_EX_MDICHILD extended style is moved Update 2022-05-24 Fixed issue releasing subclassing when GUI is deleted but program is not closed Fixed occasional white background flicker Added function GuiFlatButton_GetPos Update 2021-01-02 Fixed bug, not drawing correctly after deleting GUI with GUIDelete() Fixed bug, changing default colors changed all buttons, even previously created buttons Made some internal functions more efficient Update 2019-04-14 Fixed bug, not showing pressed down state when clicking rapidly Added Icon/Bitmap support! Added function GuiFlatButton_SetPos to change the position and/or size of a button Update 2019-02-09 Added 2 new functions to set the button colors globally for all future buttons. GuiFlatButton_SetDefaultColors GuiFlatButton_SetDefaultColorsEx Credits to: Melba23 (UDF template) LarsJ (general subclassing code) 4ggr35510n (TrackMouseEvent example) binhnx (disable dragging with $WS_EX_CONTROLPARENT) GUIRegisterMsg in AutoIt Help (owner-draw button example) funkey (_WinAPI_DrawState example)
    1 point
  3. [New Version] - 16 Apr 2022 Added: A new function _GUIExtender_Hidden_Control which allows you to specify which controls should not be automatically reshown when it redraws the GUI. You no longer need to hide/show the control within the script - this function does that as well as telling the UDF whether or not to show it on redraw. New UDF and an additional example in the zip below. Previous changes: Changelog.txt ........................................................................... The GUIExtender UDF allows you to have multiple sections within your GUIs which can be either static or extendable. The extendable sections can be extended and retracted either by UDF created buttons or programmatically by other controls or HotKeys. The controls on the sections are fully functional and there is no overlap problem when retracted (see the details section if you want to know how). The UDF can be used in both MessageLoop and OnEvent modes and with both native and UDF created controls, as well as embedded objects and child GUIs. -------------------------------------------------------------- Note: This is a new recoded and (I hope) simplified version of my earlier UDF of the same name. If you move to this new version there are several script-breaking changes, so please look carefully at the included example scripts to see where things have changed. Here is a quick guide to how the UDF function list has been altered: Old function New function Comment _Init _Init Unchanged _Clear _Clear Unchanged _Section_Start _Section_Create New default parameters for position and size _Section_End Deprecated _Section_Create used to end all section creation _Section_Action _Section_Activate Simple rename _Action _EventMonitor Simple rename _Section_Extend _Section_Action Simple rename, but now uses integer parameter for required state _Section_State _Section_State Unchanged _Restore Deprecated Now automatic _ActionCheck Deprecated Now automatic _HandleCheck Deprecated Now automatic _Obj_Data _Obj_Data Unchanged - _Handle_Data Single call on creation replaces multiple _HandleCheck calls Note: The _EventMonitor function must be added to the idle loop for the automatic actions above to occur -------------------------------------------------------------- Details of how the UDF works for those who are interested: The UDF and plenty of commented examples are in the attached zip: GUIExtender.zip M23
    1 point
  4. water

    OutlookEX

    Version 1.7.0.1

    10,047 downloads

    Extensive library to control and manipulate Microsoft Outlook. This UDF holds the functions to automate items (folders, mails, contacts ...) in the background. Can be seen like an API. There are other UDFs available to automate Outlook: OutlookEX_GUI: This UDF holds the functions to automate the Outlook GUI. OutlookTools: Allows to import/export contacts and events to VCF/ICS files and much more. Threads: Development - General Help & Support - Example Scripts - Wiki BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2020-02-09) None
    1 point
  5. Musashi

    Show text to inputbox

    Try : <code removed> EDIT : @Giggo : Here is a better version : #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("show list", 380, 350, 199, 410) $i_inp1 = GUICtrlCreateInput("", 14, 10, 350, 250) $b_save = GUICtrlCreateButton("Save", 16, 290, 120, 30) $b_show = GUICtrlCreateButton("Show File .txt", 147, 290, 120, 30) Local $sFilePath = @ScriptDir & '\list.txt' Local $hFileOpen, $sDataRead, $sDataWrite GUISetState(@SW_SHOW) While True $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $b_show $sDataRead = FileRead($sFilePath) If @error Then MsgBox(BitOr(4096,16), "Error : ", $sFilePath & @CRLF & @CRLF & _ "File not found or empty" & @CRLF) Else GUICtrlSetData($i_inp1, $sDataRead) EndIf Case $b_save FileDelete($sFilePath) $sDataWrite = GUICtrlRead($i_inp1) If $sDataWrite <> "" Then $hFileOpen = FileOpen($sFilePath, 128 + 1) FileWrite($hFileOpen, $sDataWrite & @CR) FileWrite($hFileOpen, "" & @CRLF) FileClose($hFileOpen) EndIf EndSwitch WEnd
    1 point
  6. @senatin #include <Misc.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> GUIRegisterMsg($WM_TIMER, "PlayAnim") Opt('TrayAutoPause', 0) Local $hTimer = DllCallbackRegister('PlayAnim', 'none', 'hwnd;uint;uint_ptr;dword') Global $pre_timer, $_state = Number("1"), $_state_1 = Number("1"), $timer_id Do SetWM_Timer(3000) Sleep(9000) SetWM_Timer(1000) Sleep(9000) Until _IsPressed('1B') Func PlayAnim($hWnd, $iMsg, $iTimerID, $iTime) #forceref $hWnd, $iMsg, $iTimerID, $iTime consolewrite("TickTime" & @CRLF) EndFunc ;==>PlayAnim Func SetWM_Timer($timer) if $_state = Number("1") Then if $_state_1 = Number("1") Then _WinAPI_KillTimer(0, $timer_id) DllCallbackFree($hTimer) Local $hTimer = DllCallbackRegister('PlayAnim', 'none', 'hwnd;uint;uint_ptr;dword') $timer_id = _WinAPI_SetTimer(0, 0, $timer, DllCallbackGetPtr($hTimer)) EndIf $pre_timer = $timer $_state_1 = Number("0") $_state = Number("0") EndIf if $timer <> $pre_timer Then _WinAPI_KillTimer(0, $timer_id) DllCallbackFree($hTimer) Local $hTimer = DllCallbackRegister('PlayAnim', 'none', 'hwnd;uint;uint_ptr;dword') $timer_id = _WinAPI_SetTimer(0, 0, $timer, DllCallbackGetPtr($hTimer)) $_state = Number("1") $_state_1 = Number("1") EndIf EndFunc ;==>SetWM_Timer
    1 point
  7. You could use AdlibRegister function. It would make your life easier. You can also use _Timer UDF. But if you insist, you could use this : #include <GUIConstants.au3> #include <Constants.au3> #include <WinAPISysWin.au3> Global Const $nID = 50 Global $hGUI = GUICreate("Timer") GUISetState() GUIRegisterMsg($WM_TIMER, WM_TIMER) Global $hTimer = _WinAPI_SetTimer($hGUI, $nID, 3000, 0) If Not $hTimer Then Exit MsgBox($MB_SYSTEMMODAL, "", "Failed") Sleep(9000) Global $hTimer = _WinAPI_SetTimer($hGUI, $nID, 1000, 0) If Not $hTimer Then Exit MsgBox($MB_SYSTEMMODAL, "", "Failed") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_KillTimer($hGUI, $nID) Func WM_TIMER($hWndGUI, $MsgID, $WParam, $LParam) ConsoleWrite("hWndGUI: " & $hWndGUI & " MsgID: " & $MsgID & " wParam: " & $WParam & " lParam: " & $LParam & @CRLF) EndFunc ;==>WM_TIMER
    1 point
  8. Are you using a Active Directory for the PC? That is where you can set HOMEDRIVE & HOMEPATH to different values.
    1 point
  9. jugador

    Sort question in C++

    (optimized Jscript code) Console output: $g_iRows = 100 $g_iCols = 6 JScript: sorted in = 14 ms $g_iRows = 1000 $g_iCols = 6 JScript: sorted in = 64 ms $g_iRows = 10000 $g_iCols = 6 JScript: sorted in = 457 ms $g_iRows = 100000 $g_iCols = 6 JScript: sorted in = 5548 ms $g_iRows = 200000 $g_iCols = 6 JScript: sorted in = 11805 ms Thanks @pixelsearch
    1 point
  10. Did anyone had success, updating the integrated libcurl 7.42.1 to a newer version?
    1 point
  11. pixelsearch

    Sort question in C++

    @jugador: I optimized the Jscript code, now it's much faster. These are the timers applied to your computer : * 10.000 elements should take less than 1s to be sorted on your computer. * 100.000 elements should take less than 10s, you'll tell us ok ? Here is the reworked code : #cs #include <Array.au3> Opt("MustDeclareVars", 1) __Example1() Func __Example1() Local $arry[] = [6, 4, 1, 5, 3, 2] _ArrayDisplay($arry, "UNsorted") Local $x_Result = __ArraySortJs($arry, 0, True, True) ; col 0, numeric (True), ascending (True) _ArrayDisplay($x_Result, "sorted") Local $arry[] = ['D0','F0','A0','E0','C0','B0'] _ArrayDisplay($arry, "UNsorted") $x_Result = __ArraySortJs($arry, 0, False, False) ; col 0, string, descending _ArrayDisplay($x_Result, "sorted") Local $arry[][] = [['D0',6,'DD2'],['F0',4,'FF2'],['A0',1,'A2'],['E0',5,'E2'],['C0',3,'C2'],['B0',2,'B2']] Local $iCol_Sort = 2 _ArrayDisplay($arry, "UNsorted (col " & $iCol_Sort & ")") Local $x_Result = __ArraySortJs($arry, $iCol_Sort, False, True) ; col $iCol_Sort, string, ascending _ArrayDisplay($x_Result, "sorted (col " & $iCol_Sort & ")") EndFunc #ce #include <Array.au3> #include "RandomArray.au3" ; LarsJ Opt("MustDeclareVars", 1) Global $g_iRows = 10000, $g_iCols = 6, $g_aArray __Example2() Func __Example2() _Generate_All($g_aArray) _ArrayDisplay($g_aArray, "UNsorted", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*") Local $hTimer2 = TimerInit() Local $iCol_Sort = 0 Local $x_Result2 = __ArraySortJs($g_aArray, $iCol_Sort, False, True) ; col $iCol_Sort, numeric (True), ascending (True) If @error Then Exit Msgbox(0, "__ArraySortJs", "error " & @error) ConsoleWrite("JScript: sorted in = " & Int(TimerDiff($htimer2)) & " ms" & @crlf) _ArrayDisplay($x_Result2, "sorted (col " & $iCol_Sort & ")", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*") EndFunc ;=========================================== Func _Generate_All(ByRef $g_aArray) ; LarsJ ConsoleWrite("$g_iRows = " & $g_iRows & " $g_iCols = " & $g_iCols & @CRLF) $g_aArray = FAS_Random2DArrayAu3($g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz") EndFunc ;==>_Generate_All ; #FUNCTION# ============================================================================= ; Name...........: __ArraySortJs ; ======================================================================================== Func __ArraySortJs($o_array, $o_Column = 0, $o_Numeric = True, $o_ascending = True) ;==== If Not IsArray($o_array) Then Return SetError(1, 0, -1) Local $iNb_Cols = Ubound($o_array, 2) If ($iNb_Cols = 1) And ($o_Column > 0) Then Return SetError(1, 0, -1) If ($iNb_Cols > 1) And ($o_Column > $iNb_Cols - 1) Then Return SetError(1, 0, -1) ;==== ;==== Local $o_CBlock = _ 'function GetArray(arr){' & @CRLF & _ 'var oArray = new VBArray(arr)' & @CRLF & _ 'return oArray.toArray()' & @CRLF & _ '}' & @CRLF & _ 'function NumSort1D(a, b){' & @CRLF & _ 'return a - b' & @CRLF & _ '}' & @CRLF & _ 'function NumSort2D(a, b){' & @CRLF & _ 'return a[0] - b[0]' & @CRLF & _ ; always [0] +++ '}' & @CRLF & _ 'function StringSort1D(a, b){' & @CRLF & _ 'if (a === b) {' & @CRLF & _ 'return 0' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return (a < b) ? -1 : 1' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function StringSort2D(a, b){' & @CRLF & _ 'if (a[0] === b[0]) {' & @CRLF & _ ; always [0] +++ 'return 0' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return (a[0] < b[0]) ? -1 : 1' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function ArraySorting1D(arr, oNumeric, oascending){' & @CRLF & _ 'var JsArray = GetArray(arr)' & @CRLF & _ 'if (oNumeric) {' & @CRLF & _ 'JsArray.sort(NumSort1D)' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'JsArray.sort(StringSort1D)' & @CRLF & _ '}' & @CRLF & _ 'if (oascending) {' & @CRLF & _ 'return JsArray.toString()' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return JsArray.reverse().toString()' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function ArraySorting2D(arr, oNumeric, oascending){' & @CRLF & _ 'var JsArray = GetArray(arr)' & @CRLF & _ 'var JsArr2 = []' & @CRLF & _ 'for (var i=0; i<JsArray.length; i++) {' & @CRLF & _ 'JsArr2[i] = []' & @CRLF & _ 'JsArr2[i][0] = JsArray[i]' & @CRLF & _ 'JsArr2[i][1] = i' & @CRLF & _ '}' & @CRLF & _ 'if (oNumeric) {' & @CRLF & _ 'JsArr2.sort(NumSort2D)' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'JsArr2.sort(StringSort2D)' & @CRLF & _ '}' & @CRLF & _ 'if (oascending) {' & @CRLF & _ 'return JsArr2.toString()' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return JsArr2.reverse().toString()' & @CRLF & _ '}' & @CRLF & _ '}' ;==== ;==== Local $ObjErr = ObjEvent("AutoIt.Error", "_ErrorHandler") Local $o_Obj = 0 $o_Obj = ObjCreate("ScriptControl") $o_Obj.Language = "JScript" $o_Obj.AddCode($o_CBlock) ;==== ;==== If $iNb_Cols = 0 Then ; when original array is 1D Local $o_SortData = $o_Obj.run("ArraySorting1D", $o_array, $o_Numeric, $o_ascending) $o_Obj = 0 Local $o_SortArry = StringSplit($o_SortData, ',', 2) ; comma delim. from JsArray.toString() Return $o_SortArry EndIf ;==== ; original array is 2D from now on ;==== Local $o_ExtColmn[UBound($o_array)] ; 1D array of UNsorted elements For $i = 0 To UBound($o_array) - 1 $o_ExtColmn[$i] = $o_array[$i][$o_Column] Next Local $o_SortData = $o_Obj.run("ArraySorting2D", $o_ExtColmn, $o_Numeric, $o_ascending) $o_Obj = 0 ; ConsoleWrite("$o_SortData = " & $o_SortData & @lf) ;==== ;==== Local $o_SortArry = StringSplit($o_SortData, ',', 2) ; 1D array of sorted elements (+ indexes b4 sort) ; _ArrayDisplay($o_SortArry, "$o_SortArry") Local $o_Index[Ubound($o_array)][$iNb_Cols] ; empty 2D array to be filled Local $iRow = -1 For $i = 0 To Ubound($o_SortArry) - 1 Step 2 $iRow += 1 For $j = 0 To $iNb_Cols - 1 $o_Index[$iRow][$j] = $o_array[$o_SortArry[$i + 1]][$j] Next Next Return $o_Index ;==== EndFunc Func _ErrorHandler($oError) EndFunc A little explanation : The pic in the middle shows the "links" between the unsorted column 2 and the sorted column 2 For example the cell "A2" WAS placed on the 2nd row before it was sorted, so now it's easy to "grab" all the other columns concerning "A2" after it's sorted, then fill the new empty matrix. Same for "B2" (which was on 5th row) etc... Hope it helps.
    1 point
  12. Jtssi, That was a lot more trouble than I thought it might be - but my perseverance has paid off and i have a working example to show you. You will need all of the attached files to get it to run - please let me know if it does what you require. Comments from anyone else also welcome of course. M23 GUIExtender_Ex_Test.au3 GUIExtender_Ex_Test_Example.au3 GUIExtender_Test.au3 GUIScrollbars_Size.au3
    1 point
  13. This small library includes only one function, which allows to set resizing for elements created with UDF (_GUICtrl*_Create). It works just the same as standard GUICtrlSetResizing. Also this function compatible/works with standard controls. Example: #include <GUIRichEdit.au3> #include <GUIComboBox.au3> #include 'GUICtrlSetResizingEx.au3' $hForm = GUICreate('GUICtrlSetResizingEx Example 1', 380, 330, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP), $WS_EX_COMPOSITED) $hRichEdit = _GUICtrlRichEdit_Create($hForm, 'Edit1', 5, 5, 250, 250) _GUICtrlSetResizingEx($hRichEdit, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKTOP)) $hCombo = _GUICtrlComboBox_Create($hForm, 'Item', 5, 280, 250, 50, $CBS_DROPDOWNLIST) _GUICtrlComboBox_SetCurSel($hCombo, 0) _GUICtrlSetResizingEx($hCombo, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKBOTTOM)) $iButton = GUICtrlCreateButton('Native Button', 270, 5, 100, 25) _GUICtrlSetResizingEx(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hForm) Exit EndSwitch WEnd GUICtrlSetResizingEx_1.3.zip
    1 point
  14. Post the modifyed script Send("Username") Send("{TAB}");<= to change to some other field Send("Password") Some other way is using ControlSend(), with using autoit window info tool to get control ID
    1 point
×
×
  • Create New...