Leaderboard
Popular Content
Showing content with the highest reputation on 06/13/2016 in all areas
-
Hello. This is a simple idea. (it does not mean that it is strictly correct.) #include <Crypt.au3> #include <Array.au3> Local $aHashes1[] = ["0x45B265C13EC41DD3272E547A837EF0604E06EF6C", _ "0x73418EE0D435F0995DE000A0CB9A895B8031D62B", _ "0x6FB325DDFA9AFCB148B815F41C94F5BBC3735E0B", _ "0xE8BC5E1676E64E9EE77A7EBD56D910D60D453A2A", _ "0xFF311E2FEC610B2E0A3169435CBC48D5B1B53A57", _ "0x728EDF8577DF247CBC69ED6F2F9EACB3BF845150", _ "0x8CABC5A4BDA856E0D0E884D0F4A335CB2457941D", _ "0xCEBB04B9099141009329E13EDBD8B5CFB14A49A5", _ "0xD7AA968FCF6AC9691F6ED801BA9291EBBBAFED71", _ "0xBBBA76A66C54D53BADE77245D9F205F1EB9CC685", _ "0x39DD14E5DB99F39F68182494C0B48CEFB5DDFDDF", _ "0x32C2A01B523D973D933FC004237CAB4B792231BF", _ "0x6AE1A10B7505DDABEECEAFD13B2EC2A8D7286587"] ;other sort Local $aHashes2[] = ["0x45B265C13EC41DD3272E547A837EF0604E06EF6C", _ "0x73418EE0D435F0995DE000A0CB9A895B8031D62B", _ "0xE8BC5E1676E64E9EE77A7EBD56D910D60D453A2A", _ "0x8CABC5A4BDA856E0D0E884D0F4A335CB2457941D", _ "0xFF311E2FEC610B2E0A3169435CBC48D5B1B53A57", _ "0x728EDF8577DF247CBC69ED6F2F9EACB3BF845150", _ "0x6FB325DDFA9AFCB148B815F41C94F5BBC3735E0B", _ "0xCEBB04B9099141009329E13EDBD8B5CFB14A49A5", _ "0x32C2A01B523D973D933FC004237CAB4B792231BF", _ "0xD7AA968FCF6AC9691F6ED801BA9291EBBBAFED71", _ "0xBBBA76A66C54D53BADE77245D9F205F1EB9CC685", _ "0x39DD14E5DB99F39F68182494C0B48CEFB5DDFDDF", _ "0x6AE1A10B7505DDABEECEAFD13B2EC2A8D7286587"] _ArrayDisplay($aHashes1) _ArrayDisplay($aHashes2) Local $sHash1 = _SumOfHashes($aHashes1) Local $sHash2 = _SumOfHashes($aHashes2) ConsoleWrite("Total Hash1: " & $sHash1 & @CRLF) ConsoleWrite("Total Hash2: " & $sHash2 & @CRLF) Func _SumOfHashes($aHashes) Local $iNumber = 0 For $i = 0 To UBound($aHashes) - 1 $iNumber += _CRC32($aHashes[$i]) Next Return _Crypt_HashData($iNumber, $CALG_SHA1) EndFunc ;==>_SumOfHashes Func _CRC32($Data, $CRC32 = -1) Local $Opcode = '0xC800040053BA2083B8EDB9000100008D41FF516A0859D1E8730231D0E2F85989848DFCFBFFFFE2E78B5D088B4D0C8B451085DB7416E3148A1330C20FB6D2C1E80833849500FCFFFF43E2ECF7D05BC9C21000' Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) Local $Ret = DllCall("user32.dll", "uint", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "uint", $CRC32, _ "int", 0) $Input = 0 $CodeBuffer = 0 Return $Ret[0] EndFunc ;==>_CRC32 Saludos2 points
-
Features: Create modern looking borderless and resizable GUIs with control buttons (Close,Maximize/Restore,Minimize, Fullscreen, Menu) True borderless, resizeable GUI with full support for aerosnap etc. Many color schemes/themes included. See MetroThemes.au3 for more details. 3 type of Windows 8/10 style buttons. Modern checkboxes, radios, toggles and progressbar. All buttons, checkboxes etc. have hover effects! Windows 10 style modern MsgBox. Windows 10/Android style menu that slides in from left. Windows 10 style right click menu Credits: @UEZ, for the function to create buttons with text using GDIPlus. @binhnx for his SSCtrlHover UDF Changelog: Download UDF with example:1 point
-
This script allows you to 'browse' an array and view it's content. It's similar to the _ArrayDisplay() command, but this one has no limit on the number of dimensions. Nested array (array of arrays) are also allowed. (I'm been inspired by this @JohnOne's Post) Since multidimensional arrays can be considered as many bidimensional arrays grouped toghether, with this script you can view any of the many 2d arrays by selecting the dimension (the sheet number) you want to see through the ComboBoxes located at the top of the viewed sheet. regarding the arrays of array, if are present, those are listed on the treeview on the left side, where you can see their locations within the tree, and easily selected to be as well browsed by a click. I'm aware that there is a wide margin of aesthetic improvement, anyway the basic functionality works quite well. I hope it can be usefull ; Func _ArrayView() ; Will display content of arrays of any dimension, and even nested arrays if any ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GUITreeView.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <ComboConstants.au3> #include <GuiStatusBar.au3> ; -- build an example array (somewhat chaotic.. just to show something) -- ; 4D array (main array) Local $aA[10][5][6][3] For $d1 = 0 To 9 For $d2 = 0 To 4 For $d3 = 0 To 5 For $d4 = 0 To 2 $aA[$d1][$d2][$d3][$d4] = $d1 & "." & $d2 & "." & $d3 & "." & $d4 Next Next Next Next ; some 1D arrays with multi nested arrays Local $aMonths1 = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] Local $aMonths2 = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", $aMonths1] Local $aMonths3 = ["Sijecanj", "veljaca", "ožujka", "travanj", "Svibanj", "lipanj", "srpanj", "kolovoz", "rujan", "listopad", "studeni", "prosinac", $aMonths2] Local $aMonths4 = ["Janvier", "Février", "Mars", "Avril", "mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre", $aMonths3] Local $aMonths5 = ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'giu', 'Luglio', 'Agosto', 'Settembre', 'ottobre', 'Novembre', 'Dicembre', $aMonths4] Local $aMonths = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", $aMonths5] ; a simple 2D array Local $aWeekdays = [['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], _ ['Lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato', 'domenica'], _ ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'], _ ['Måndag', 'tisdag', 'onsdag', 'torsdag', 'fredag', 'lördag', 'söndag'], _ ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela'], _ ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag']] ; array $aMonths goes in cell [5][3] dimension [0][0] of main array $aA[5][3][0][0] = $aMonths ; array $aWeekdays goes in cell [6][3] dimension [0][0] of main array $aA[6][3][0][0] = $aWeekdays $aWeekdays[1][1] = $aWeekdays ; self nest $aWeekdays in cell [1][1] $aA[9][4][0][1] = $aWeekdays ; new $aWeekdays goes in cel [9][4] dimension [0][1] of main array _ArrayView($aA) ; show main array ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayView ; Description ...: Allows to view content of amono or multidimensional array. Array of arrays are also allowed ; Syntax ........: _ArrayView(Byref $_aInput) ; Parameters ....: $_aInput - The array that you want to 'Browse' ; Return values .: on success returns 1 ; on faillure returns 0 and set @Error to 1 (passed argument is not an array) ; Author ........: @Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _ArrayView(ByRef $_aInput) If Not IsArray($_aInput) Then Return SetError(1, 0, 0) ; if error set @Error and return 0 Local $iGUIwidth = 900 Local $iGUIheight = 600 Local $iTreeWidth = 150 Local $iCombosZone = 60 Local $hGui = GUICreate("Array viewer", $iGUIwidth, $iGUIheight) Local $StatusBar = _GUICtrlStatusBar_Create($hGui), $iStatusBarheight = 23 Local $aSubscripts[64][4] ; It holds IDs of controls ; - creates all ComboBox in an embedded window. All controls are hidden at startup. ; - Only the necessary combo will be shown at run time. One combo for each dimension Local $hSubscriptSelectors = GUICreate('', $iGUIwidth - $iTreeWidth - 6, $iCombosZone - 2, $iTreeWidth + 4, 2, BitOR($WS_CHILD, $WS_HSCROLL), -1, $hGui) ; GUISetBkColor(0xEEFFEE) For $i = 0 To 63 ; Create the labels $aSubscripts[$i][0] = GUICtrlCreateLabel('D' & $i + 1, ($i * 60) + 8, 1) GUICtrlSetFont(-1, 10, 0, 0, "Courier new") GUICtrlSetState(-1, $GUI_HIDE) ; Labels will be hidden at startup. $aSubscripts[$i][1] = GUICtrlCreateLabel('[', ($i * 60), 18) GUICtrlSetFont(-1, 13, 800) GUICtrlSetState(-1, $GUI_HIDE) $aSubscripts[$i][3] = GUICtrlCreateLabel(']', ($i * 60) + 50, 18) GUICtrlSetFont(-1, 13, 800) GUICtrlSetState(-1, $GUI_HIDE) Next For $i = 0 To 63 ; Create the ComboBox (creates separatelly from labels so that ControlIDs of ComboBaxes has it's own sequence) GUICtrlSetState(-1, $GUI_HIDE) ; ComboBox will be hidden at startup. If $i < 2 Then ; all the content of the first 2 dimensions is already shown in the listview (no need of ComboBox) $aSubscripts[$i][2] = GUICtrlCreateCombo("---", ($i * 60) + 8, 17, 40, -1, $CBS_DROPDOWNLIST) GUICtrlSetState(-1, $GUI_DISABLE) Else $aSubscripts[$i][2] = GUICtrlCreateCombo("0", ($i * 60) + 8, 17, 40, -1, $CBS_DROPDOWNLIST) EndIf GUICtrlSetFont(-1, 8, 800) GUICtrlSetState(-1, $GUI_HIDE) ; ComboBox hidden at startup. Next GUISwitch($hGui) ; back to main window ; Create the TreeView structure $hTree = GUICtrlCreateTreeView(2, 2, $iTreeWidth - 2, $iGUIheight - 4 - $iStatusBarheight, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) Local $hRoot = _GUICtrlTreeView_Add($hTree, 0, "Root") ; first insert the root key in treeview _ArrayTraverse($_aInput, $hTree, $hRoot) ; Search for SubArrays (array in array) ; Create the ListView Local $idListview = GUICtrlCreateListView('', $iTreeWidth + 2, $iCombosZone + 2, $iGUIwidth - $iTreeWidth - 4, $iGUIheight - $iCombosZone - 4 - $iStatusBarheight, Default, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES)) ; If Array has many dimensions, and so all ComboBoxes doesn't fit in window, this allows to scroll GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") _GUIScrollBars_Init($hSubscriptSelectors, 60 * UBound($_aInput, 0), 0) GUISetState(@SW_SHOW, $hGui) GUISetState(@SW_SHOW, $hSubscriptSelectors) ; Main Loop until the user exits. ; ------------------------------- Local $sLastWholeKey, $sWholeKey, $vContent, $bRebuild While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE GUIDelete($hGui) ExitLoop Case $aSubscripts[2][2] To $aSubscripts[63][2] ; some ComboBox has changed _ArrayDisplayByLayer($vContent, $idListview, $aSubscripts, False) EndSwitch ; $sWholeKey = _GUICtrlTreeView_GetTree($hTree, _GUICtrlTreeView_GetSelection($hTree)) If $sLastWholeKey <> $sWholeKey Then ; clicked on a new KeyPath or (again) on the one already selected? GUISetCursor(15, 1) ; set cursor to "wait" ; Adapt the TreePath to the array access syntax $sElement = _TreePathParser($sWholeKey) ; address of main array or subarray to peek _GUICtrlStatusBar_SetText($StatusBar, StringReplace($sWholeKey, '|', '->') & ' --> ' & $sElement) ; show the 'address' of selected element on statusbar $vContent = Execute(_TreePathParser($sWholeKey)) _ArrayDisplayByLayer($vContent, $idListview, $aSubscripts, True) _GUICtrlTreeView_ClickItem($hTree, _GUICtrlTreeView_GetSelection($hTree)) $sLastWholeKey = $sWholeKey ; keep track of already clicked KeyPath so we will not redraw the same Array if clicked again GUISetCursor() ; cursor back to default EndIf ; WEnd Return SetError(0, 0, 1) ; if no errors return 1 EndFunc ;==>_ArrayView Func _ArrayDisplayByLayer(ByRef $_aInput, ByRef $idListview, ByRef $aSubscripts, $bRebuild = False) Opt('GUIOnEventMode', 1) ; Disable GUIGetMsg() so is not fired while redrawing ComboBoxes. Local $sTarghet = '$_aInput[$y]' Local $iDimensions = UBound($_aInput, 0) Local $iRows = UBound($_aInput, 1) Local $iColumnsCount, $iColumns = UBound($_aInput, 2) Local $sSubscripts = '' ; Clear the ListView _GUICtrlListView_DeleteAllItems($idListview) If $bRebuild Then ; (Re)Create the ListView $iColumnsCount = _GUICtrlListView_GetColumnCount($idListview) If $iColumnsCount Then For $i = $iColumnsCount To 1 Step -1 _GUICtrlListView_DeleteColumn($idListview, $i - 1) Next EndIf ; Hide and clear all ComboBox For $i = 0 To 63 GUICtrlSetState($aSubscripts[$i][0], $GUI_HIDE) ; Header GUICtrlSetState($aSubscripts[$i][1], $GUI_HIDE) ; '[' GUICtrlSetState($aSubscripts[$i][2], $GUI_HIDE) ; ComboBox Handle GUICtrlSetData($aSubscripts[$i][2], '') ; clear ComboBox items GUICtrlSetState($aSubscripts[$i][3], $GUI_HIDE) ; ']' Next ; (Re)Build the ListView's frame If $iDimensions = 1 Then $iColumns = 1 Else $iColumns = UBound($_aInput, 2) ; nr. of columns in the ListView (second dimension) $sTarghet &= '[$x]' EndIf _GUICtrlListView_AddColumn($idListview, 'Row') For $i = 1 To $iColumns _GUICtrlListView_AddColumn($idListview, 'Col ' & $i - 1, 100) Next For $i = 0 To $iDimensions - 1 ; Show only necessary ComboBox (one for each dimension) GUICtrlSetState($aSubscripts[$i][0], $GUI_SHOW) ; Header GUICtrlSetState($aSubscripts[$i][1], $GUI_SHOW) ; '[' GUICtrlSetState($aSubscripts[$i][2], $GUI_SHOW) ; ComboBox Handle GUICtrlSetState($aSubscripts[$i][3], $GUI_SHOW) ; ']' If $i > 1 Then $sTarghet &= '[0]' ; dimensions over the second all setting to 0 (begin showing first lyer) $sSubscripts = "" For $iSubscript = 0 To UBound($_aInput, $i + 1) - 1 $sSubscripts &= $iSubscript & '|' Next GUICtrlSetData($aSubscripts[$i][2], StringTrimRight($sSubscripts, 1)) ControlFocus('', '', $aSubscripts[$i][2]) ControlSend('', '', $aSubscripts[$i][2], 0) EndIf Next Else ; Just refill the listview with data from the Array dimension selected by ComboBoxes ; Create the 'dimension' string $sTarghet &= '[$x]' For $i = 2 To $iDimensions - 1 $sTarghet &= '[' & GUICtrlRead($aSubscripts[$i][2]) & ']' Next $iColumns = UBound($_aInput, 2) EndIf For $y = 0 To $iRows - 1 GUICtrlCreateListViewItem('', $idListview) _GUICtrlListView_SetItemText($idListview, $y, '[' & $y & ']', 0) ; row number For $x = 0 To $iColumns - 1 $vCellContent = Execute($sTarghet) If IsArray($vCellContent) Then _GUICtrlListView_SetItemText($idListview, $y, '{array}', $x + 1) Else _GUICtrlListView_SetItemText($idListview, $y, $vCellContent, $x + 1) EndIf Next Next Opt('GUIOnEventMode', 0) ; reenable GUIGetMsg() EndFunc ;==>_ArrayDisplayByLayer Func _ArrayTraverse(ByRef $aMyArray, ByRef $hTree, $hParent) #cs since this is a recursive Function, the same Func runs many times, self called from within itself. The variables declared as Global at the top of the script are able to be accessed from any instance of the function, whereas the variable declared (as Local) within the function may be different for each instance of the function. #ce If Not IsArray($aMyArray) Then Return SetError(1, 0, -1) ; we have to know how many nested for-next loops we need ; that is one loop for each dimension Local $iDimensions = UBound($aMyArray, 0) ; number of nested for-next loops Local $sArrayPointer = "$aMyArray", $sElement For $i = 0 To $iDimensions - 1 $sArrayPointer &= '[$aLoops[' & $i & '][2]]' Next ; ----------------------------------------------------------------------------------- ; This is a nested For-Next loops simulator with variable depth of nested loops ; pass a 2D zero based array[n][3] ; with as many records as nested loops needed ; as following: ; ; Example; For $i = start To end ; ----- --- ; [n][0] = Start value ; [n][1] = End value ; [n][2] = actual loop counter (at startup is = to Start value [n][0]) ; ; --- Initializes custom nested For-Next loops -------------------------------------- Local $aLoops[$iDimensions][3] ; nr of nested loops is $iDimensions For $i = 0 To $iDimensions - 1 $aLoops[$i][0] = 0 ; Start value $aLoops[$i][1] = UBound($aMyArray, $i + 1) - 1 ; End value $aLoops[$i][2] = $aLoops[$i][0] ; actual loop counter Next ; ----------------------------------------------------------------------------------- Local $x, $vContent Do $vContent = Execute($sArrayPointer) If IsArray($vContent) Then ; here there is a Nested array, populate the TreeView with a child element $sElement = "" For $i = 0 To $iDimensions - 1 $sElement &= '[' & $aLoops[$i][2] & ']' Next Local $hNode = _GUICtrlTreeView_AddChild($hTree, $hParent, $sElement) ; recursive call for this nested array to search if there are any further nested arrays _ArrayTraverse($vContent, $hTree, $hNode) ; <-- recursive call EndIf ; ------------------------------------------------------------------------------- $x = UBound($aLoops) - 1 $aLoops[$x][2] += 1 While ($aLoops[$x][2] > $aLoops[$x][1]) ; check if and which nested loops are out of bound $aLoops[$x][2] = $aLoops[$x][0] ; reset the counter of this loop ($x) $x -= 1 ; check next outer nest If $x < 0 Then ExitLoop ; if we have finished all nested loops then Exit $aLoops[$x][2] += 1 ; when a deeper loop complete, increment the outer one WEnd Until $x < 0 ; If no more nested loops then exit EndFunc ;==>_ArrayTraverse ; Tree Path to Subscript Func _TreePathParser($Input) Local $sReturn = '$_aInput' Local $aSubArrays = StringSplit($Input, '|', 3) If UBound($aSubArrays) > 1 Then For $i = 1 To UBound($aSubArrays) - 1 $sReturn &= $aSubArrays[$i] If $i < UBound($aSubArrays) - 1 Then $sReturn = '(' & $sReturn & ')' Next EndIf Return $sReturn EndFunc ;==>_TreePathParser ; this will allow the scrolling of window containing ComboBoxes (if number of Combo doesn't fit in window) ; see _GUIScrollBars_Init() in the Help of AutoIt Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL1 point
-
something like : #Include <GUIConstants.Au3> Opt ('GUIOnEventMode','1') Global $Button_Row['5']['4'], $Display_String = '', $Real_String = '' $hGui = GUICreate ('test','151','300','-1','-1','-1','144') GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_MOUSEDOWN") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_MOUSEDOWN") GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit') $Display = GUICtrlCreateInput ('','11','15','129','20','1') $Display1 = GUICtrlCreateInput ('','11','130','129','20','1') $Display2 = GUICtrlCreateInput ('','11','155','129','20','1') $Display3 = GUICtrlCreateInput ('','11','180','129','20','1') GUICtrlSetFont ($Display, '10','','','New Times Roman') _Create_Buttons () _Set_Text () Local $CurrentDisplay = $Display GUISetState (@SW_SHOW) While ('1') Sleep ('750') WEnd Func _MOUSEDOWN() $aCInfo = GUIGetCursorInfo($hGUI) Switch $aCInfo[4] Case $Display $CurrentDisplay = $Display Case $Display1 $CurrentDisplay = $Display1 Case $Display2 $CurrentDisplay = $Display2 Case $Display3 $CurrentDisplay = $Display3 EndSwitch EndFunc Func _Create_Buttons () Local $Top = ('0') For $Array_1 = '1' To '3' For $Array_2 = '0' To '2' $Button_Row[$Array_1][$Array_2] = GUICtrlCreateButton ('','30' * $Array_2 + '18', '50' + $Top, '25','23') GUICtrlSetState (-1, $GUI_NOFOCUS) GUICtrlSetFont ('-1', '10','','','Arial') Next $Top = $Top + '26' Next EndFunc Func _Set_Text () GUICtrlSetData ($Button_Row['1']['0'], '7') GUICtrlSetOnEvent ($Button_Row['1']['0'], '_Set_7') GUICtrlSetData ($Button_Row['1']['1'], '8') GUICtrlSetOnEvent ($Button_Row['1']['1'], '_Set_8') GUICtrlSetData ($Button_Row['1']['2'], '9') GUICtrlSetOnEvent ($Button_Row['1']['2'], '_Set_9') GUICtrlSetData ($Button_Row['2']['0'], '4') GUICtrlSetOnEvent ($Button_Row['2']['0'], '_Set_4') GUICtrlSetData ($Button_Row['2']['1'], '5') GUICtrlSetOnEvent ($Button_Row['2']['1'], '_Set_5') GUICtrlSetData ($Button_Row['2']['2'], '6') GUICtrlSetOnEvent ($Button_Row['2']['2'], '_Set_6') GUICtrlSetData ($Button_Row['3']['0'], '1') GUICtrlSetOnEvent ($Button_Row['3']['0'], '_Set_1') GUICtrlSetData ($Button_Row['3']['1'], '2') GUICtrlSetOnEvent ($Button_Row['3']['1'], '_Set_2') GUICtrlSetData ($Button_Row['3']['2'], '3') GUICtrlSetOnEvent ($Button_Row['3']['2'], '_Set_3') GUICtrlSetData ($Button_Row['4']['0'], '0') GUICtrlSetOnEvent ($Button_Row['4']['0'], '_Set_0') EndFunc Func _Set_0 () _Set_Number ('0') EndFunc Func _Set_1 () _Set_Number ('1') EndFunc Func _Set_2 () _Set_Number ('2') EndFunc Func _Set_3 () _Set_Number ('3') EndFunc Func _Set_4 () _Set_Number ('4') EndFunc Func _Set_5 () _Set_Number ('5') EndFunc Func _Set_6 () _Set_Number ('6') EndFunc Func _Set_7 () _Set_Number ('7') EndFunc Func _Set_8 () _Set_Number ('8') EndFunc Func _Set_9 () _Set_Number ('9') EndFunc Func _Set_Number ($Number) $Display_String = (GUICtrlRead($CurrentDisplay) & $Number) $Real_String = ($Real_String & $Number) GUICtrlSetData ($CurrentDisplay,$Display_String ) ;MsgBox($MB_SYSTEMMODAL, "Title", , "30") EndFunc Func _Exit () Exit EndFunc1 point
-
Now, i'm sure : @Danyfirex comes from another solar system...1 point
-
#include-once #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> ;Opt('MustDeclareVars', 1) Opt('TrayIconDebug', 1) Opt('Guioneventmode', 1) HotKeySet('{ESC}', '_exit') #include <Array.au3> #include <Excel.au3> Global $lastID Global $listEnabled = '' Global $listDisabled = '' Global $hGui, $idListview, $idInput, $width_hGui = 700 $hGui = GUICreate('', $width_hGui, 500) Local $te = StringSplit('' & _ 'rash|lump|pruritus|jaundice|cyanosis|onycholysis|mole changes' & _ '', '|', 2) GUISetOnEvent(-3, '_exit') Local $idBtn[UBound($te)] createBlock($te, 0, 0, 200) GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_SecondaryDown") ;~ GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) WinWait('Forever') Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR ;, $tagNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") ConsoleWrite(@LF & @SEC & ' - ' & $iIDFrom & ' - ' & $iCode) Tooltip($hWndFrom) $lastID = $iIDFrom Return 'GUI_RUNDEFMSG' ;$GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func createBlock(ByRef $text, $x_Zero = Default, Const $y_Zero = 100, Const $width = 150) If $x_Zero = Default Then $x_Zero = 150 Local $idBtn[UBound($text)] $idBtn[0] = GUICtrlCreateButton($text[0], $x_Zero, $y_Zero, -1, -1, 0x4000) For $i = 1 To UBound($text) - 1 Step +1 $posPrev = ControlGetPos($hGui, '', $idBtn[$i - 1]) $x = $posPrev[0] + $posPrev[2] $y = $posPrev[1] $idBtn[$i] = GUICtrlCreateButton($text[$i], $x, $y, -1, -1, 0x4000) $posCurr = ControlGetPos($hGui, '', $idBtn[$i]) If $posCurr[0] + $posCurr[2] - $x_Zero > $width Then GUICtrlDelete($idBtn[$i]) $idBtn[$i] = GUICtrlCreateButton($text[$i], $x_Zero, $posPrev[1] + $posPrev[3]) If $i = UBound($text) - 1 Then $posLast = ControlGetPos($hGui, '', $idBtn[$i]) If $posLast[2] > $width Then GUICtrlDelete($idBtn[$i]) $idBtn[$i] = GUICtrlCreateButton($text[$i], $x_Zero, $posPrev[1] + $posPrev[3], $width, -1, -1, 0x4000) EndIf EndIf Local $array[1] $t = $i - 1 ; t for temp $s = $i $tot_x = 0 While True $s -= 1 $pos2 = ControlGetPos($hGui, '', $idBtn[$s]) If $pos2[1] = $posPrev[1] Then _ArrayAdd($array, $pos2[2]) $tot_x += $pos2[2] If $s = 0 Then ExitLoop Else $s += 1 ExitLoop EndIf WEnd _ArrayDelete($array, 0) _ArrayReverse($array) $x_Zero1 = $x_Zero For $j = $s To $t Step +1 GUICtrlDelete($idBtn[$j]) $k = $j - $s $array[$k] = $width * 1.3 * ($array[$k] / $tot_x) $idBtn[$j] = GUICtrlCreateButton($text[$j], $x_Zero1, $posPrev[1], $array[$k]);, -1, -1, 0x4000) $x_Zero1 += $array[$k] Next EndIf Next For $i = 0 To UBound($idBtn) - 1 GUICtrlSetOnEvent($idBtn[$i], 'yey') $x = GUICtrlCreateContextMenu($idBtn[$i]) GUICtrlCreateMenuItem("Positive", $x) GUICtrlCreateMenuItem("Negative", $x) GUICtrlCreateMenuItem("Not asked", $x) Next EndFunc ;==>createBlock Func _SecondaryDown() $aCInfo = GUIGetCursorInfo($hGUI) MsgBox($MB_SYSTEMMODAL, "Pressed", $aCInfo[4]) EndFunc Func hehe() ; How to get the ID of the right-clicked button? EndFunc ;==>hehe Func yey() $hexDisabled = 0xff8b8b $hexEnabled = 0x8bb1ff $x = @GUI_CtrlId $read = GUICtrlRead($x) Select Case StringRegExp($listEnabled, '\(' & $read & '\)') ; Already enabled ; Disable! ;ToolTip('Will disable!') $listEnabled = StringRegExpReplace($listDisabled, '\(' & $read & '\)', '') $listDisabled = '(' & $read & ')' GUICtrlSetBkColor($x, $hexDisabled) Case StringRegExp($listDisabled, '\(' & $read & '\)') ; Case Else ; Enable! ;ToolTip('Will enable!') $listEnabled = '(' & $read & ')' GUICtrlSetBkColor($x, $hexEnabled) EndSelect ; Tooltip(GUICtrlRead($x)) EndFunc ;==>yey Func _exit() Exit EndFunc ;==>_exit1 point
-
thx. You are a real bughunter! Maybe for the future you can use my bugtracker for bugreporting. (isnetwork.at/bugtracker) Make´s it easier for me1 point
-
Here it is #Include <Array.au3> Local $aFL = [["6", "test6"], ["Full", "testFull"], ["Step", "testStep"], ["032-Test", "test032test"], ["03a", "test03a"], ["a", "testa"], ["51", "test51"]] $aFL = _ArraySortEx2D($aFL, 0, 0) _ArrayDisplay($aFL) Func _ArraySortEx2D($aArray, $iSortOrder, $iSortCol) ; Sort an array of filenames into Explorer sort order If Ubound($aArray, $UBOUND_DIMENSIONS) <> 2 Then SetError(1) Return EndIf Local $iNumRows = UBound($aArray, $UBOUND_ROWS ) Local $iNumCols = UBound($aArray, 2 ) Local $aArray_Num[$iNumRows][$iNumCols], $aArray_Str[$iNumRows][$iNumCols], $iNum = 0, $iStr = 0 ; Split into [pure digits] and [mixed & strings] For $i = 0 To UBound($aArray) - 1 If StringRegExp($aArray[$i][$iSortCol], "^\d+$") Then For $k = 0 to $iNumCols-1 $aArray_Num[$iNum][$k] = $aArray[$i][$k] Next $iNum += 1 Else For $k = 0 to $iNumCols-1 $aArray_Str[$iStr][$k] = $aArray[$i][$k] Next $iStr += 1 EndIf Next ; Redim and sort arrays ReDim $aArray_Num[$iNum][$iNumCols] ReDim $aArray_Str[$iStr][$iNumCols] ; Sort arrays _ArraySort($aArray_Num, $iSortOrder, Default, Default, $iSortCol) _ArraySort($aArray_Str, $iSortOrder, Default, Default, $iSortCol) ; And rejoin _ArrayConcatenate($aArray_Num, $aArray_Str) Return $aArray_Num EndFunc1 point
-
It will be easier if I show you with an example. Compile the runIE example and then run the main example (this one dont need to be compiled). Put them both in the same folder. runIE (need to be compiled) #include <IE.au3> If $CmdLine[0] > 1 Then Local $oIE = _IECreate($CmdLine[1]) MsgBox(0, "", "I will now navigate to: " & $CmdLine[2]) _IENavigate($oIE, $CmdLine[2]) Else MsgBox(0, "Error", "No parameters found!") EndIf Exit main ShellExecute(@ScriptDir & "\runIE.exe", 'http://www.autoitscript.com http://www.autoitscript.com/forum/index.php?') Sleep(3000) ShellExecute(@ScriptDir & "\runIE.exe", 'http://www.google.com http://www.yahoo.com') ; or with Run() ;~ Run(@ScriptDir & '\runIE.exe http://www.autoitscript.com http://www.autoitscript.com/forum/index.php?') ;~ Sleep(3000) ;~ Run(@ScriptDir & '\runIE.exe http://www.google.com http://www.yahoo.com') Despite the variable name is the same, the oIE object is unique in each instance of the script. This also shows you how to pass parameters to your own autoit scripts. So no need to know how many ie instance you will need, or if there is one already.1 point
-
To work with Microsoft Word I suggest to use the Word UDF. IIRC there was a thread discussing this subject. I will have a look.1 point
-
Same in GuiOnEventMode: #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <GuiMenu.au3> Opt("GUIOnEventMode", 1) Global $g_hListView, $hGUI Global Enum $eEven = 1000, $eOdd Example() Func Example() $hGUI = GUICreate("(UDF Created) ListView Create", 400, 300) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit') $g_hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ; Load images Local $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($g_hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($g_hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($g_hListView, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) ; Loop While 1 Sleep(1000) WEnd GUIDelete() EndFunc ;==>Example Func _Exit() Exit EndFunc ;==>_Exit Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch _WinAPI_LoWord($wParam) Case $eEven MsgBox(0, "Item", "Even") Case $eOdd MsgBox(0, "Item", "Odd") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hListView Switch $iCode Case $NM_RCLICK Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $iItem = DllStructGetData($tInfo, "Index") If $iItem > -1 Then Local $hMenu = _GUICtrlMenu_CreatePopup(), $bEven = Mod($iItem, 2) = 0 _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Even", $eEven) _GUICtrlMenu_SetItemEnabled($hMenu, 0, $bEven) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Odd", $eOdd) _GUICtrlMenu_SetItemEnabled($hMenu, 1, Not $bEven) _GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI) _GUICtrlMenu_DestroyMenu($hMenu) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY1 point
-
Thanks You are right, here is one who was used for Trump campaign ! #Region ;************ Includes ************ #Include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #EndRegion ;************ Includes ************ _GDIPlus_Startup() Opt ( 'GUIOnEventMode', 1 ) Global $hGUI, $hGraphic, $hBmp_Buffer, $hGfx_Buffer, $aDim, $aPosCenter, $x, $y ; Code Generated by Shape2Polygon, Polygon Size=328x309 (reduction level=4) from D:\Shape2Polygon\Shapes\Hypnosis-spiral-800px.png Local $aPoints = [[717,0],[164,307],[168,308],[172,308],[190,308],[193,308],[197,307],[202,307],[206,306],[210,305],[214,304],[218,303],[222,302],[226,301],[229,300],[232,298],[236,297],[239,295],[243,294],[246,291],[250,290],[254,288],[258,285],[262,283],[265,281],[269,277],[273,274],[277,271],[281,267],[285,263],[289,259],[292,256],[295,252],[298,248],[300,244],[303,241],[305,237],[308,233],[310,229],[312,225],[313,221],[315,217],[316,214],[318,210],[320,206],[321,202],[322,198],[322,194],[323,190],[324,187],[325,183],[325,179],[325,174],[326,171],[327,168],[327,155],[326,151],[326,147],[325,145],[325,138],[325,135],[324,131],[323,127],[322,124],[322,120],[321,117],[320,113],[318,109],[316,105],[316,101],[313,97],[312,93],[310,90],[308,86],[306,82],[304,79],[301,75],[299,71],[296,67],[293,64],[291,60],[287,56],[284,52],[280,48],[276,44],[272,41],[269,38],[265,34],[261,32],[257,29],[253,26],[249,23],[245,21],[241,19],[237,17],[234,15],[231,14],[227,12],[224,11],[221,9],[217,8],[213,7],[209,6],[205,5],[201,4],[198,3],[195,2],[191,2],[187,1],[182,1],[178,0],[174,0],[171,0],[168,0],[162,0],[159,0],[153,0],[150,0],[146,0],[142,1],[138,2],[135,2],[132,2],[128,3],[125,4],[121,6],[117,6],[114,7],[110,8],[106,10],[102,11],[99,12],[96,14],[92,15],[88,18],[84,19],[82,21],[78,23],[74,25],[71,28],[67,30],[63,32],[59,36],[55,39],[51,42],[47,45],[43,49],[40,53],[36,57],[33,61],[30,65],[27,69],[23,73],[20,77],[18,81],[15,84],[13,88],[12,92],[10,95],[8,99],[6,102],[4,106],[3,110],[2,113],[0,117],[0,120],[0,124],[2,128],[4,131],[8,135],[12,136],[16,136],[20,136],[24,134],[28,130],[29,126],[31,122],[33,118],[34,115],[36,111],[38,108],[40,104],[42,100],[44,97],[47,93],[50,89],[54,85],[56,81],[59,77],[63,73],[66,70],[70,67],[74,64],[78,61],[82,58],[85,56],[88,54],[91,51],[95,49],[99,47],[102,45],[106,43],[110,42],[113,41],[117,39],[121,38],[125,37],[129,36],[133,34],[137,33],[141,33],[145,33],[148,32],[152,31],[161,31],[165,30],[167,31],[179,31],[183,32],[187,33],[191,33],[195,34],[196,34],[200,35],[204,37],[207,38],[211,39],[214,40],[217,42],[221,43],[225,45],[228,48],[232,50],[236,51],[239,54],[243,57],[247,59],[250,63],[254,66],[258,70],[262,74],[266,78],[268,82],[272,86],[274,90],[276,93],[279,96],[281,100],[282,104],[284,108],[285,111],[287,115],[289,119],[289,122],[290,126],[291,129],[292,133],[293,137],[294,140],[295,144],[295,147],[295,151],[295,167],[295,171],[295,174],[294,178],[294,182],[293,185],[292,189],[291,192],[290,196],[289,200],[288,203],[286,207],[284,210],[283,212],[281,215],[280,219],[277,223],[275,227],[272,231],[270,235],[266,239],[262,243],[258,246],[254,249],[251,252],[247,255],[243,258],[239,260],[235,263],[231,265],[227,267],[223,268],[219,270],[216,271],[213,272],[209,273],[205,274],[201,275],[198,275],[195,276],[191,277],[182,277],[179,277],[175,277],[165,277],[162,276],[159,275],[155,275],[152,274],[150,273],[146,272],[143,271],[139,269],[135,268],[132,266],[128,263],[124,261],[121,259],[117,256],[114,254],[110,251],[106,247],[103,243],[100,240],[97,236],[94,232],[92,228],[90,225],[88,222],[86,218],[84,215],[82,212],[81,208],[80,204],[79,200],[78,196],[78,192],[77,189],[76,186],[76,165],[77,162],[77,158],[78,154],[79,151],[80,147],[82,144],[82,140],[84,136],[87,132],[88,128],[92,124],[94,120],[97,117],[100,113],[104,110],[108,106],[111,103],[115,101],[118,98],[122,96],[126,95],[129,92],[133,91],[137,90],[141,88],[145,88],[149,86],[153,86],[158,86],[162,84],[166,84],[169,86],[173,86],[177,86],[180,87],[184,88],[187,88],[191,90],[195,91],[198,93],[202,95],[206,97],[210,100],[214,103],[218,106],[221,110],[224,114],[227,118],[230,122],[232,126],[234,129],[236,133],[237,137],[238,140],[239,144],[240,147],[241,151],[241,167],[240,171],[239,174],[239,178],[237,182],[236,185],[235,189],[232,192],[230,196],[226,200],[223,204],[219,207],[217,210],[213,213],[209,215],[205,217],[201,218],[198,220],[195,221],[191,222],[188,222],[184,223],[178,223],[174,222],[171,222],[168,222],[164,221],[161,219],[157,217],[153,216],[150,213], _ [147,211],[143,207],[140,203],[137,200],[135,196],[134,192],[132,189],[132,185],[130,181],[130,170],[131,166],[132,162],[134,158],[136,154],[140,150],[144,147],[147,143],[151,141],[155,141],[159,139],[166,139],[170,140],[174,141],[178,144],[181,146],[183,149],[186,153],[186,156],[186,160],[183,156],[179,154],[175,152],[167,152],[163,153],[160,155],[156,158],[154,162],[152,165],[150,169],[150,176],[151,180],[152,183],[154,187],[156,191],[160,194],[164,196],[167,198],[171,200],[174,201],[175,201],[184,201],[187,200],[191,199],[195,198],[199,196],[203,192],[207,189],[210,185],[213,182],[214,178],[216,174],[217,171],[218,167],[219,164],[219,154],[218,151],[217,147],[217,144],[215,140],[213,136],[210,133],[208,129],[204,125],[200,121],[197,118],[193,115],[189,114],[186,112],[182,110],[178,110],[174,109],[171,108],[168,108],[160,108],[156,108],[154,109],[150,109],[146,110],[143,111],[139,113],[135,114],[132,117],[128,119],[124,122],[120,126],[117,129],[114,133],[111,137],[108,141],[106,145],[104,149],[103,153],[101,156],[101,160],[100,164],[99,168],[99,185],[100,189],[101,192],[101,196],[103,199],[104,203],[105,207],[108,210],[110,213],[112,217],[114,221],[117,225],[120,228],[123,231],[127,234],[130,237],[133,240],[137,242],[141,244],[145,246],[147,248],[151,249],[155,250],[158,251],[162,253],[166,253],[167,253],[171,254],[188,254],[192,253],[196,253],[200,253],[204,251],[208,250],[211,249],[214,247],[218,246],[220,245],[224,243],[228,240],[231,238],[235,236],[239,232],[243,229],[246,225],[249,222],[252,219],[255,215],[258,211],[260,207],[262,203],[264,200],[265,196],[267,192],[268,188],[270,184],[270,180],[271,176],[272,173],[272,169],[272,165],[272,153],[272,150],[272,145],[271,142],[270,138],[270,134],[268,130],[267,126],[266,123],[264,119],[262,115],[261,111],[259,108],[257,105],[254,101],[251,97],[249,93],[246,90],[242,86],[238,82],[235,79],[231,76],[227,74],[224,72],[221,69],[217,67],[213,65],[210,63],[206,63],[202,60],[198,59],[195,59],[191,57],[188,56],[184,55],[180,55],[177,55],[174,54],[155,54],[152,55],[147,55],[144,55],[141,56],[137,57],[133,57],[129,59],[126,60],[123,61],[119,63],[115,65],[111,67],[108,69],[104,72],[100,74],[96,76],[92,78],[89,81],[85,84],[81,88],[78,91],[74,95],[72,99],[69,102],[66,106],[64,110],[61,114],[59,118],[57,122],[55,126],[54,129],[52,133],[51,137],[50,140],[49,144],[48,147],[47,150],[46,154],[46,158],[46,162],[45,165],[45,185],[46,189],[46,192],[46,196],[47,200],[48,203],[48,207],[50,210],[51,214],[51,218],[53,221],[55,224],[56,228],[57,230],[59,234],[60,237],[63,241],[65,245],[67,248],[69,250],[72,253],[73,255],[74,258],[78,262],[80,264],[84,268],[84,270],[88,272],[92,276],[96,279],[100,282],[103,285],[107,287],[111,290],[114,291],[118,293],[121,295],[125,297],[129,298],[146,304],[159,307]] ; Set Position. $x = 20 $y = 20 $aDim = _PolygonGetSize ( $aPoints ) $hGUI = GUICreate ( 'Vote for Trump !', $aDim[0] +$x*2, $aDim[1] +$y*2 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_Exit' ) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND ( $hGUI ) $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics ( $aDim[0] +$x*2, $aDim[1] +$y*2, $hGraphic ) $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext ( $hBmp_Buffer ) $aPoints = _PolygonSetPos ( $aPoints, $x, $y ) Dim $aPosCenter[2][2] = [[1]] $aPosCenter[1][0] = $aDim[0]/2 +$x $aPosCenter[1][1] = $aDim[1]/2 +$y While 1 _GDIPlus_GraphicsClear ( $hGfx_Buffer, 0xFFFFFFFF ) _GDIPlus_GraphicsFillPolygon ( $hGfx_Buffer, $aPoints ) _GDIPlus_GraphicsTransformPoints ( $hGfx_Buffer, $aPosCenter ) _GDIPlus_GraphicsTranslateTransform ( $hGfx_Buffer, $aPosCenter[1][0], $aPosCenter[1][1] ) _GDIPlus_GraphicsRotateTransform ( $hGfx_Buffer, 5 ) _GDIPlus_GraphicsTranslateTransform ( $hGfx_Buffer, -$aPosCenter[1][0], -$aPosCenter[1][1] ) _GDIPlus_GraphicsDrawImage ( $hGraphic, $hBmp_Buffer, 0, 0 ) Sleep ( 10 ) WEnd _GDIPlus_GraphicsDispose ( $hGfx_Buffer ) _GDIPlus_BitmapDispose ( $hBmp_Buffer ) _GDIPlus_GraphicsDispose ( $hGraphic ) _GDIPlus_Shutdown() Exit Func _PolygonGetSize ( $aPoints ) If UBound ( $aPoints, 2 ) <> 2 Then Return SetError ( 1, 0, '' ) Local $aRet[2] Local $iXMin = _ArrayMin ( $aPoints, 1, 1, -1, 0 ) Local $iYMin = _ArrayMin ( $aPoints, 1, 1, -1, 1 ) Local $iXMax = _ArrayMax ( $aPoints, 1, 1, -1, 0 ) Local $iYMax = _ArrayMax ( $aPoints, 1, 1, -1, 1 ) $aRet[0] = $iXMax - $iXMin +1 ; width $aRet[1] = $iYMax - $iYMin +1 ; height $aPoints = 0 Return $aRet EndFunc ;==> _PolygonGetSize() Func _PolygonSetPos ( $aPoints, $x=0, $y=0 ) If UBound ( $aPoints, 2 ) <> 2 Then Return SetError ( 1, 0, '' ) Local $iXMin = _ArrayMin ( $aPoints, 1, 1, -1, 0 ) Local $iYMin = _ArrayMin ( $aPoints, 1, 1, -1, 1 ) For $i = 1 To UBound ( $aPoints ) -1 $aPoints[$i][0] = $x + $aPoints[$i][0] - $iXMin $aPoints[$i][1] = $y + $aPoints[$i][1] - $iYMin Next Return $aPoints EndFunc ;==> _PolygonSetPos() Func _Exit() Exit EndFunc ;==> _Exit() Edited cause $aPoints Coordinates disapear when posting with AutoIt format.1 point
-
Try this: ;Coded by UEZ 2013 -> This program requires AutoIt version 3.3.9.21 or higher! #include <GDIPlus.au3> #include <Memory.au3> _GDIPlus_Startup() Global $sFile = StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\msoobe.jpg") Global $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global $hBitmap = _GDIPlus_ImageResize($hImage, 10, 7) Global $bImage = _GDIPlus_StreamImage2BinaryString($hBitmap) ConsoleWrite("Error: " & @error & @LF) ConsoleWrite(BinaryLen($bImage) & @CRLF) MsgBox(0, "Binary", $bImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Func _GDIPlus_StreamImage2BinaryString($hBitmap, $sFormat = "JPG", $iQuality = 80, $bSave = False, $sFilename = @ScriptDir & "\Converted.jpg") ;coded by UEZ 2013 build 2014-01-25 (based on the code by Andreik) Local $sImgCLSID, $tGUID, $tParams, $tData Switch $sFormat Case "JPG" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100 Local $pData = DllStructGetPtr($tData) $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Case "PNG", "BMP", "GIF", "TIF" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Case Else Return SetError(1, 0, 0) EndSwitch Local $hStream = _WinAPI_CreateStreamOnHGlobal() ;http://msdn.microsoft.com/en-us/library/ms864401.aspx If @error Then Return SetError(2, 0, 0) _GDIPlus_ImageSaveToStream($hBitmap, $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams)) If @error Then Return SetError(3, 0, 0) Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx If @error Then Return SetError(4, 0, 0) Local $iMemSize = _MemGlobalSize($hMemory) If Not $iMemSize Then Return SetError(5, 0, 0) Local $pMem = _MemGlobalLock($hMemory) $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) _WinAPI_ReleaseStream($hStream) ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473(v=vs.85).aspx _MemGlobalFree($hMemory) If $bSave Then Local $hFile = FileOpen($sFilename, 18) If @error Then Return SetError(6, 0, $bData) FileWrite($hFile, $bData) FileClose($hFile) EndIf Return $bData EndFunc ;==>_GDIPlus_StreamImage2BinaryString It will return a binary string which can be saved.1 point
-
Reizvoller, Use the GUlEdit UDF - the _GUICtrlEdit_AppendText function is the one you want. M231 point
-
Following DigiSoul's discovery that controls are still located relative to the framing GUI rather than the underlying scrollable area, and maintaining my ambition to make the scrollbar process as painless as possible, I have added a function to the GUIScrollBars_Ex UDF. This function, _GUIScrollbars_Locate_Ctrl, will do all the calculations necessary to position any new controls where you would expect them to be rather than where Windows thinks they should be. All you need to pass as parameters are the handle of the window containing the scrollbars and the required coordinates of the control on the underlying scrollable area. The function returns a 2 element array holding the corrected coordinates - use these and your control will be located where you want it to be. Here is a short example script. The 2 GUIs differ in having the scrollbars created BEFORE and AFTER the coloured label. In the original version, the user had to remember to factor the coordinates in the BEFORE case but now the UDF does that automatically. Try moving the scrollbars so that the label changes position - the UDF will compensate for this. Basically, the new label will always overlay the original: #include <GUIConstantsEx.au3> #include "GUIScrollbars_Ex.au3" ; Create GUI 1 $hGUI_1 = GUICreate("BEFORE", 500, 400, 100, 100) $hButton_1 = GUICtrlCreateButton("Press", 400, 300, 80, 30) GUISetState() ; Generate scrollbars BEFORE controls _GUIScrollbars_Generate($hGUI_1, 1000, 1000, 0, 0, True) $hLabel_1 = GUICtrlCreateLabel("", 300, 200, 50, 50) GUICtrlSetBkColor(-1, 0xCCCCFF) ; Create GUI 2 $hGUI_2 = GUICreate("AFTER", 500, 400, 700, 100) $hLabel_2 = GUICtrlCreateLabel("", 200, 300, 50, 50) GUICtrlSetBkColor(-1, 0xCCCCFF) $hButton_2 = GUICtrlCreateButton("Press", 400, 300, 80, 30) GUISetState() ; Generate scrollbars AFTER controls _GUIScrollbars_Generate($hGUI_2, 700, 700) While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hGUI_1 Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $hButton_1 GUISwitch($hGUI_1) $aPos = _GUIScrollbars_Locate_Ctrl($hGUI_1, 300, 200) $hNewLabel_1 = GUICtrlCreateLabel("",$aPos[0], $aPos[1], 50, 50) GUICtrlSetBkColor(-1, 0xCCFFCC) Sleep(1000) GUICtrlDelete($hNewLabel_1) EndSwitch Case $hGUI_2 Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $hButton_2 GUISwitch($hGUI_2) $aPos = _GUIScrollbars_Locate_Ctrl($hGUI_2, 200, 300) $hNewLabel_2 = GUICtrlCreateLabel("",$aPos[0], $aPos[1], 50, 50) GUICtrlSetBkColor(-1, 0xCCFFCC) Sleep(1000) GUICtrlDelete($hNewLabel_2) EndSwitch EndSwitch WEndAnd the new UDF: #include-once ; #INDEX# ============================================================================================================ ; Title .........: GUIScrollBars_Ex ; AutoIt Version : v3.3.6.0 ; Language ......: English ; Description ...: Generates scrollbars for user defined sizes of GUI and aperture and sets proportional thumb sizes ; Remarks .......: ; Note ..........: ; Author(s) .....: Melba23 - with some code based on the WinAPI and GUIScrollBars includes, and from MrCreatoR & Malkey ; ==================================================================================================================== ;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INCLUDES# ========================================================================================================= #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <SendMessage.au3> ; #GLOBAL VARIABLES# ================================================================================================= Global $aSB_WindowInfo[1][8] ; [0] = Handle to window ; [1] = Not used ; [2] = Average horizontal pixels per char ; [3] = Vertical pixels per char ; [4] = Client area width ; [5] = Client area height ; [6] = Horizontal max setting ; [7] = Vertical max setting Global $aSB_WindowInfoEx[1][5] ; [0] = Horizontal scrollable size ; [1] = Vertical scrollable size ; [2] = Width correction factor ; [3] = Height correction factor ; [4] = Before/After flag ; #CURRENT# ========================================================================================================== ; _GUIScrollbars_Generate: Generates scrollbars for a GUI with a defined aperture with proportional thumb sizes ; _GUIScrollbars_Locate_Ctrl: Calculates coordinates to use to position controls after scrollbar creation ; _GUIScrollbars_Scroll_Page: Scrolls to min, max or page number ; ==================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; _Scrollbars_WM_VSCROLL: GUIRegisterMsg procedure for vertical scrollbar ; _Scrollbars_WM_HSCROLL: GUIRegisterMsg procedure for horizontal scrollbar ; _Scrollbars_WM_MOUSEWHEEL : GUIRegisterMsg procedure for vertical mouse wheel scroll ; _Scrollbars_WM_MOUSEHWHEEL : GUIRegisterMsg procedure for horizontal mouse wheel scroll ;===================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIScrollbars_Generate ; Description ...: Generates scrollbars for a GUI with a defined aperture with proportional thumb sizes ; Syntax.........: _GUIScrollbars_Generate ($hWnd, $iH_Scroll = 0, [$iV_Scroll = 0, [$iH_Tight = 0, [$iV_Tight = 0, [$fBefore = False]]]]) ; Parameters ....: $hWnd -> GUI to contain scrollbars ; $iH_Scroll -> Width in pixels of area to be scrolled ; $iV_Scroll -> Height in pixels of area to be scrolled (default = 0) ; $iH_Tight -> 1 = Adjust mean position of right edge of scrolled area to right (default = 0) ; $iV_Tight -> 1 = Adjust mean position of bottom edge of scrolled area down (default = 0) ; $fBefore -> True = Scrollbars are being generated BEFORE controls ; False = Scrollbars are being generated AFTER controls (default) ; Requirement(s).: v3.3.6.0 or higher ; Return values .: Success - Returns a 4-element array (see remarks for details): ; [0] = Actual aperture width ; [1] = Actual aperture height] ; [2] = Width correction factor ; [3] = Height correction factor] ; Failure - Returns either 0 (UDF error) or negative integer (API error) ; If UDF error then @error set as follows: ; 1 - hWnd not a valid handle ; 2 - No scroll size parameters ; 3 - Scrollbar creation or parameter setting failure ; If API error then @error and @extended as set by API error. Return values: ; -1 - GetDC failure ; -2 - GetTextMetricsW failure ; -3 - GetClientRect failure ; Remarks .......; The $fBefore parameter is needed because of the way Windows deals with scrollbars. When the ; scrollbars are generated, the visible part of the scrollable GUI resizes to fit the in the ; remaining (smaller) client area. ; - If the scrollbars are to be generated BEFORE any controls, the UDF shoudl be called with the ; $fBefore parameter set. The new client size of the aperture window is returned so that ; controls can then be created using these values. ; - If controls have been created before the scrollbars are generated then the UDF should be ; called without the $fBefore parameter. The correction factors returned can then be applied to ; any subsequent control positioning and sizing. This is necessary because of the positions and ; sizes of existing controls will be slightly altered as the scrollbars are generated and the GUI ; resized. Any controls created subsequently would therefore be slightly misplaced in relation ; to the existing ones unless the correction factors are used when positoning and sizing them. ; - If existing controls were fixed in place using GUICtrlResizing($GUI_DOCKALL) there is no need ; to apply the correction factors as the controls will not have moved with the GUI resizing. ; Author ........: Melba23 - with some code based on the WinAPI and GUIScrollBars includes ; Example........; Yes ;===================================================================================================================== Func _GUIScrollbars_Generate($hWnd, $iH_Scroll = 0, $iV_Scroll = 0, $iH_Tight = 0, $iV_Tight = 0, $fBefore = False) ; Check if valid window handle If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) If $aSB_WindowInfo[0][0] <> "" Then ReDim $aSB_WindowInfo[UBound($aSB_WindowInfo) + 1][8] ReDim $aSB_WindowInfoEx[UBound($aSB_WindowInfo) + 1][5] EndIf ; If no scroll sizes set, return error If $iH_Scroll = 0 And $iV_Scroll = 0 Then Return SetError(2, 0, 0) ; Confirm Tight values If $iH_Tight <> 0 Then $iH_Tight = 1 If $iV_Tight <> 0 Then $iV_Tight = 1 ; Create structs Local $tTEXTMETRIC = DllStructCreate($tagTEXTMETRIC) Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) DllStructSetData($tSCROLLINFO, "cbSize", DllStructGetSize($tSCROLLINFO)) Local $tRect = DllStructCreate($tagRECT) ; Declare local variables Local $iIndex = UBound($aSB_WindowInfo) - 1 Local $iError, $iExtended ; Save window handle $aSB_WindowInfo[$iIndex][0] = $hWnd ; Determine text size Local $hDC = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) If Not @error Then $hDC = $hDC[0] DllCall("gdi32.dll", "bool", "GetTextMetricsW", "handle", $hDC, "ptr", DllStructGetPtr($tTEXTMETRIC)) If @error Then $iError = @error $iExtended = @extended DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC) Return SetError($iError, $iExtended, -2) EndIf DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC) Else Return SetError(@error, @extended, -1) EndIf $aSB_WindowInfo[$iIndex][2] = DllStructGetData($tTEXTMETRIC, "tmAveCharWidth") $aSB_WindowInfo[$iIndex][3] = DllStructGetData($tTEXTMETRIC, "tmHeight") + DllStructGetData($tTEXTMETRIC, "tmExternalLeading") ; Size aperture window without bars DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hWnd, "ptr", DllStructGetPtr($tRect)) If @error Then Return SetError(@error, @extended, -3) Local $iX_Client_Full = DllStructGetData($tRect, "Right") - DllStructGetData($tRect, "Left") Local $iY_Client_Full = DllStructGetData($tRect, "Bottom") - DllStructGetData($tRect, "Top") $aSB_WindowInfo[$iIndex][4] = $iX_Client_Full $aSB_WindowInfo[$iIndex][5] = $iY_Client_Full ; Register scrollbar and mousewheel messages GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "_Scrollbars_WM_HSCROLL") GUIRegisterMsg($WM_MOUSEWHEEL, "_Scrollbars_WM_MOUSEWHEEL") GUIRegisterMsg($WM_MOUSEHWHEEL, '_Scrollbars_WM_MOUSEHWHEEL') ; Show scrollbars _GUIScrollBars_ShowScrollBar($hWnd, $SB_BOTH, False) If $iH_Scroll Then _GUIScrollBars_ShowScrollBar($hWnd, $SB_HORZ) If $iV_Scroll Then _GUIScrollBars_ShowScrollBar($hWnd, $SB_VERT) ; Size aperture window with bars DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hWnd, "ptr", DllStructGetPtr($tRect)) If @error Then Return SetError(@error, @extended, -3) Local $iX_Client_Bar = DllStructGetData($tRect, "Right") - DllStructGetData($tRect, "Left") Local $iY_Client_Bar = DllStructGetData($tRect, "Bottom") - DllStructGetData($tRect, "Top") ; If horizontal scrollbar is required Local $iH_FullPage If $iH_Scroll Then If $fBefore Then ; Use actual aperture width $aSB_WindowInfo[$iIndex][4] = $iX_Client_Bar ; Determine page size (aperture width / text width) $iH_FullPage = Floor($aSB_WindowInfo[$iIndex][4] / $aSB_WindowInfo[$iIndex][2]) ; Determine max size (scroll width / text width - tight) $aSB_WindowInfo[$iIndex][6] = Floor($iH_Scroll / $aSB_WindowInfo[$iIndex][2]) - $iH_Tight Else ; Use reduced aperture width only if other scrollbar exists If $iV_Scroll Then $aSB_WindowInfo[$iIndex][4] = $iX_Client_Bar ; Determine page size (aperture width / text width) $iH_FullPage = Floor($aSB_WindowInfo[$iIndex][4] / $aSB_WindowInfo[$iIndex][2]) ; Determine max size (scroll width / text width * correction factor for V scrollbar if required - tight) $aSB_WindowInfo[$iIndex][6] = Floor($iH_Scroll / $aSB_WindowInfo[$iIndex][2] * $aSB_WindowInfo[$iIndex][4] / $iX_Client_Full) - $iH_Tight EndIf Else $aSB_WindowInfo[$iIndex][6] = 0 EndIf ; If vertical scrollbar required Local $iV_FullPage If $iV_Scroll Then If $fBefore Then ; Use actual aperture height $aSB_WindowInfo[$iIndex][5] = $iY_Client_Bar ; Determine page size (aperture width / text width) $iV_FullPage = Floor($aSB_WindowInfo[$iIndex][5] / $aSB_WindowInfo[$iIndex][3]) ; Determine max size (scroll width / text width - tight) $aSB_WindowInfo[$iIndex][7] = Floor($iV_Scroll / $aSB_WindowInfo[$iIndex][3]) - $iV_Tight Else ; Use reduced aperture width only if other scrollbar exists If $iH_Scroll Then $aSB_WindowInfo[$iIndex][5] = $iY_Client_Bar ; Determine page size (aperture width / text width) $iV_FullPage = Floor($aSB_WindowInfo[$iIndex][5] / $aSB_WindowInfo[$iIndex][3]) ; Determine max size (scroll width / text width * correction factor for H scrollbar if required - tight) $aSB_WindowInfo[$iIndex][7] = Floor($iV_Scroll / $aSB_WindowInfo[$iIndex][3] * $aSB_WindowInfo[$iIndex][5] / $iY_Client_Full) - $iV_Tight EndIf Else $aSB_WindowInfo[$iIndex][7] = 0 EndIf Local $aRet[4] If $iV_Scroll Then $aRet[0] = $iX_Client_Bar Else $aRet[0] = $iX_Client_Full EndIf If $iH_Scroll Then $aRet[1] = $iY_Client_Bar Else $aRet[1] = $iY_Client_Full EndIf $aRet[2] = $iX_Client_Bar / $iX_Client_Full $aRet[3] = $iY_Client_Bar / $iY_Client_Full ; Save extended window info $aSB_WindowInfoEx[$iIndex][0] = $iH_Scroll $aSB_WindowInfoEx[$iIndex][1] = $iV_Scroll $aSB_WindowInfoEx[$iIndex][2] = $aRet[2] $aSB_WindowInfoEx[$iIndex][3] = $aRet[3] $aSB_WindowInfoEx[$iIndex][4] = $fBefore Local $fSuccess = True If _GUIScrollBars_ShowScrollBar($hWnd, $SB_BOTH, False) = False Then $fSuccess = False If $iH_Scroll Then If _GUIScrollBars_SetScrollInfoMax($hWnd, $SB_HORZ, $aSB_WindowInfo[$iIndex][6]) = False Then $fSuccess = False _GUIScrollBars_SetScrollInfoPage($hWnd, $SB_HORZ, $iH_FullPage) If @error Then $fSuccess = False If _GUIScrollBars_ShowScrollBar($hWnd, $SB_HORZ, True) = False Then $fSuccess = False Else If _GUIScrollBars_ShowScrollBar($hWnd, $SB_HORZ, False) = False Then $fSuccess = False EndIf If $iV_Scroll Then If _GUIScrollBars_SetScrollInfoMax($hWnd, $SB_VERT, $aSB_WindowInfo[$iIndex][7]) = False Then $fSuccess = False _GUIScrollBars_SetScrollInfoPage($hWnd, $SB_VERT, $iV_FullPage) If @error Then $fSuccess = False If _GUIScrollBars_ShowScrollBar($hWnd, $SB_VERT, True) = False Then $fSuccess = False Else If _GUIScrollBars_ShowScrollBar($hWnd, $SB_VERT, False) = False Then $fSuccess = False EndIf If $fSuccess Then Return $aRet Return SetError(3, 0, 0) EndFunc ;==>_GUIScrollbars_Generate ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIScrollbars_Locate_Ctrl ; Description ...: Calculates coordinates to use to position controls after scrollbar creation ; Syntax.........: _GUIScrollbars_Locate_Ctrl ($hWnd, $iX, $iY) ; Parameters ....: $hWnd -> GUI to contain control ; $iX -> Horizontal coordinate relative to scrollable area ; $iY -> Vertical coordinate relative to scrollable area ; Requirement(s).: v3.3.6.0 or higher ; Return values .: Success - Returns a 2-element array: ; [0] = Horizontal coordinate ; [1] = Vertical coordinate ; Failure - Returns either 0 with @error set as follows: ; 1 - Invalid window handle ; 2 - Parameter error ; 3 - Window not found ; Remarks .......; ; Author ........: Melba23 ; Example........; Yes ;===================================================================================================================== Func _GUIScrollbars_Locate_Ctrl($hWnd, $iX, $iY) ; Check $hWnd If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ; Find window info Local $iIndex = -1 For $i = 0 To UBound($aSB_WindowInfo) - 1 If $hWnd = $aSB_WindowInfo[$i][0] Then $iIndex = $i Next If $iIndex = -1 Then Return SetError(3, 0, 0) ; Check if location is within scrollable area of the window If $iX < 0 Or $iX > $aSB_WindowInfoEx[$iIndex][0] Then Return SetError(2, 0, 0) If $iY < 0 Or $iY > $aSB_WindowInfoEx[$iIndex][1] Then Return SetError(2, 0, 0) ; Calculate factored coordinates if needed If Not $aSB_WindowInfoEx[$iIndex][4] Then $iX *= $aSB_WindowInfoEx[$iIndex][2] $iY *= $aSB_WindowInfoEx[$iIndex][3] EndIf ; Correct for any scrollbar movement $iX -= _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_HORZ) * $aSB_WindowInfo[$iIndex][2] $iY -= _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_VERT) * $aSB_WindowInfo[$iIndex][3] Local $aRet[2] = [$iX, $iY] Return $aRet EndFunc ;==>_GUIScrollbars_Locate_Ctrl ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIScrollbars_Scroll_Page ; Description ...: Scrolls scrollbars generated by _GUIScrollbars_Generate to min, max or page number ; Syntax.........: _GUIScrollbars_Scroll_Page ($hWnd, [$iH_Scroll_Pos = -1, [$iV_Scroll_Pos = -1]]) ; Parameters ....: $hWnd -> GUI to contain scrollbars ; $iH_Scroll_Pos -> Horizontal age number: ; 0 = No change ; 1+ = Scroll to page number ; If page number is over max pages, then scroll to max position ; $iV_Scroll_Pos -> As $iH_Scroll_Pos for vertical pages ; Requirement(s).: v3.3.6.0 or higher ; Return values .: None ; Remarks .......; ; Author ........: Melba23 ; Example........; Yes ;===================================================================================================================== Func _GUIScrollbars_Scroll_Page($hWnd, $iH_Scroll_Pos = 0, $iV_Scroll_Pos = 0) Local $iPos ; Check $hWnd If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ; Check $iH/V_Scroll_Pos If Not (IsInt($iH_Scroll_Pos) And IsInt($iV_Scroll_Pos)) Then Return SetError(2, 0, 0) ; Find window info Local $iIndex = -1 For $i = 0 To UBound($aSB_WindowInfo) - 1 If $hWnd = $aSB_WindowInfo[$i][0] Then $iIndex = $i Next If $iIndex = -1 Then Return SetError(1, 0, 0) ; Get page sizes Local $iH_Page = Floor($aSB_WindowInfo[$iIndex][4] / $aSB_WindowInfo[$iIndex][2]) Local $iV_Page = Floor($aSB_WindowInfo[$iIndex][5] / $aSB_WindowInfo[$iIndex][3]) If $iH_Scroll_Pos > 0 Then $iPos = ($iH_Scroll_Pos - 1) * $iH_Page If $iPos > $aSB_WindowInfo[$iIndex][6] Then $iPos = $aSB_WindowInfo[$iIndex][6] _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_HORZ, $iPos) EndIf If $iV_Scroll_Pos > 0 Then $iPos = ($iV_Scroll_Pos - 1) * $iV_Page If $iPos > $aSB_WindowInfo[$iIndex][7] Then $iPos = $aSB_WindowInfo[$iIndex][7] _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, $iPos) EndIf EndFunc ;==>_GUIScrollbars_Scroll_Page ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Scrollbars_WM_VSCROLL ; Description ...: GUIRegisterMsg procedure for vertical scrollbar ; Syntax ........: _Scrollbars_WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) ; Return values .: None ; Author ........: Taken from AutoIt Help file ; Remarks .......: This function is used internally by _Scrollbars_Generate ; =============================================================================================================================== Func _Scrollbars_WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Scrollbars_WM_HSCROLL ; Description ...: GUIRegisterMsg procedure for horizontal scrollbar ; Syntax ........: _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) ; Return values .: None ; Author ........: Taken from AutoIt Help file ; Remarks .......: This function is used internally by _Scrollbars_Generate ; =============================================================================================================================== Func _Scrollbars_WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLL ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Scrollbars_WM_MOUSEWHEEL ; Description ...: GUIRegisterMsg procedure for vertical mouse wheel scroll ; Syntax ........: _Scrollbars_WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) ; Return values .: None ; Author ........: Based on code from MrCreator & Malkey ; Remarks .......: This function is used internally by _Scrollbars_Generate ; =============================================================================================================================== Func _Scrollbars_WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $iDirn, $iDelta = BitShift($wParam, 16) ; Mouse wheel movement If BitAND($wParam, 0x0000FFFF) Then ; If Ctrl or Shft pressed move Horz scrollbar $iDirn = $SB_LINERIGHT If $iDelta > 0 Then $iDirn = $SB_LINELEFT For $i = 1 To 7 _SendMessage($hWnd, $WM_HSCROLL, $iDirn) Next Else ; Move Vert scrollbar $iDirn = $SB_LINEDOWN If $iDelta > 0 Then $iDirn = $SB_LINEUP _SendMessage($hWnd, $WM_VSCROLL, $iDirn) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_MOUSEWHEEL ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Scrollbars_WM_MOUSEHWHEEL ; Description ...: GUIRegisterMsg procedure for horizontal mouse wheel scroll ; Syntax ........: _Scrollbars_WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) ; Return values .: None ; Author ........: Based on code from MSDN, MrCreator & Malkey ; Remarks .......: This function is used internally by _Scrollbars_Generate ; =============================================================================================================================== Func _Scrollbars_WM_MOUSEHWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $iDirn = $SB_LINERIGHT If BitShift($wParam, 16) > 0 Then $iDirn = $SB_LINELEFT ; Mouse wheel movement For $i = 1 To 7 _SendMessage($hWnd, $WM_HSCROLL, $iDirn) Next Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_MOUSEHWHEELNote that the function is only available when the scrollbars have been created using the _GUIScrollbars_Generate function within the UDF as the necessary parameters for the new function are stored within the UDF as the scrollbars are generated. The function has not been added to the _GUIScrollbars_Size UDF for the same reasons. However, I have altered the first _GUIScrollbars_Size example script to show how the user can make the corrections manually (as in the post above). Zip file in first post updated. M231 point
-
James, "dirty"? "Inspired lateral thinking" would be my preferred comment! M231 point