Leaderboard
Popular Content
Showing content with the highest reputation on 08/13/2016 in all areas
-
Tab control example: Tabs and subtabs on demand
jaberwacky reacted to LarsJ for a topic
Create tab items and subtabs dynamically. The tabs and subtabs are managed by a tree structure implemented as a treeview control. Add tab items and subtabsResizable windowRename tab itemsDrag and drop supportCut, copy (once), paste (many)Save to and read from inifile23 December 2011 Added an option to the context menu to set the spacing between the tab controls. The zipfile below is updated. 19 December 2011 Drag and drop You can drag a tab item (tab header) and drop it on another tab item. An item is dropped under the mouse cursor moving the item you are dropping on to the left or right. You can't drop an item on one of it's own subtabs. That means that you can drag sidewards and upwards but not downwards. When you click a tab item you can't drag until the item is updated (when you see the dotted rectangle around the text). TabExDemo.au3 is a demo program. It shows how the tabs and subtabs are managed by the tree structure in the treeview control. TabExEdit.au3 is an example with an edit control. For tab items with an even number (name) the edit control is initially set to the number. TabExList.au3 is an example with a listview (includes WinAPIEx.au3). TabExEmpty.au3 has an empty window with no data. It can be used as a starting point for applications. TabExFunc.au3 is common functions (includes APIConstants.au3). This is a zipfile with the scripts. TabEx.zip LarsJ1 point -
The help file isn't meant as a tutorial, and shouldn't be inflated to be one. It tells you how to use the functions, what they do, what you get when they succeed and when they fail. Beyond that it's up to the programmer to figure out what might go wrong, and write your code accordingly. In the specific case of the Run function you're told when it fails, YOU should know how to figure out why it failed or take the time to learn why what you wrote didn't work as intended. You're not going to find it in the help file so learn about what you're doing before trying to do it. Programming isn't about having your hand held all along the way, it's about learning what the command set available does and if you can't do that then don't be a programmer (even a sometimes one).1 point
-
Disable ESK key close window
behdadsoft reacted to Melba23 for a topic
mike2003, Opt("GUICloseOnESC", 0) should do the trick. M231 point -
Hello. First UISF_HIDEFOCUS constant has not that value :S It's defined as UISF_HIDEFOCUS=0x1 _HighPrecisionSleep Function is pretty wrong. Check ; www.autoitscript.com/forum/topic/56536-easy-shell-hooking-example/?page=2 ; autohotkey.com/board/topic/82458-how-to-disable-the-standard-focus-rectangle/ ;~ #NoTrayIcon #include <WinAPI.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("WinWaitDelay", 0) Opt("MouseClickDelay", 0) Opt("MouseClickDownDelay", 0) Opt("MouseClickDragDelay", 0) Opt("SendKeyDelay", 0) Opt("SendKeyDownDelay", 0) Opt("WinTitleMatchMode", 3) Global $hNTDll = DllOpen("ntdll.dll") ;just load once :P Global Const $UIS_SET = 1 Global Const $UIS_CLEAR = 2 Global Const $UISF_HIDEFOCUS = 0x1 OnAutoItExitRegister("_Free") Global $hHookFunc = DllCallbackRegister('_WinEventProc', 'none', 'ptr;uint;hwnd;int;int;uint;uint') Global $hWinHook = _WinAPI_SetWinEventHook($EVENT_OBJECT_CREATE, $EVENT_OBJECT_CREATE, DllCallbackGetPtr($hHookFunc)) While 1 _HighPrecisionSleep(0.1) WEnd Func _Free() If $hWinHook Then _WinAPI_UnhookWinEvent($hWinHook) If $hHookFunc Then DllCallbackFree($hHookFunc) If $hNTDll Then DllClose($hNTDll) EndFunc ;==>_Free Func _WinEventProc($hHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iEventThread, $imsEventTime) _SendMessage($hWnd, $WM_CHANGEUISTATE, _WinAPI_MakeLong($UIS_CLEAR, $UISF_HIDEFOCUS)) _SendMessage($hWnd, $WM_UPDATEUISTATE, _WinAPI_MakeLong($UIS_SET, $UISF_HIDEFOCUS)) EndFunc ;==>_WinEventProc Func _HighPrecisionSleep($iMicroSeconds) Local $hStruct = DllStructCreate("int64 time;") DllStructSetData($hStruct, "time", -1 * ($iMicroSeconds * 10)) DllCall($hNTDll, "dword", "NtDelayExecution", "int", 0, "ptr", DllStructGetPtr($hStruct)) EndFunc ;==>_HighPrecisionSleep Saludos1 point
-
rootx, That sounds as if you need to look at GUICtrlSetResizing in the Help file. M231 point
-
AndyG, Bravo for the "no need to check when there is a trailing 0 after rotation" brainwave in post #55 above - that more than halved the execution time when I amended my array-based script (although it is still lamentably slow when compared to ones you and czardas have been posting). M23 #include <Array.au3> $nBegin = TimerInit() Local $iBit = 14 ; Number of bits to process Local $iRows = 500 ; Array size increases ; Create array to hold binary patterns Local $aBinArray[$iRows][$iBit + 1] ; Add all 0s element to 0 column $aBinArray[0][0] = 1 $aBinArray[1][0] = "" For $i = 1 To $iBit $aBinArray[1][0] &= "0" Next ConsoleWrite("Filling array" & @CRLF) ; Skip all even numbers - they must be duplicates when rotated For $i = 1 to (2 ^ $iBit) - 1 Step 2 $sBinary = Dec2Bin($i) ; Create binary string $sBinary = StringRegExpReplace($sBinary, "(?U)^(.*)0*$", "$1") ; Strip any trailing zeros $sBinary = StringFormat("%0" & $iBit & "s", $sBinary) ; Pad with leading zeros as required StringReplace($sBinary, "1", "") ; Get number of 1s within it $iCount = @extended $aBinArray[0][$iCount] +=1 ; Determine column in which to add... If $aBinArray[0][$iCount] > UBound($aBinArray) - 1 Then ; ...and resize array if required ReDim $aBinArray[UBound($aBinArray) + $iRows][$iBit + 1] EndIf $aBinArray[$aBinArray[0][$iCount]][$iCount]= $sBinary ; Store in required column Next ;_ArrayDisplay($aBinArray, "Full", Default, 8) ConsoleWrite(TimerDiff($nBegin) & @CRLF) ; Determine column after which we can mirror $iMirror = Ceiling(($iBit + 1) / 2) ; Create array to hold unique elements Local $aUnique[UBound($aBinArray) * 2] = [0] ; Create array to hold unique array indices for each column - first 2 cols are only single values Local $aColIndex[$iBit][2] = [[1, 1], [2, 2]] ; Add elements from first and second columns which are unique by definition For $i = 0 To 1 ConsoleWrite("Column: " & $i & @CRLF & "Adding" & @CRLF) $aUnique[0] += 1 $aUnique[$aUnique[0]] = $aBinArray[1][$i] Next ; Now loop through other columns checking for duplicates when rotated For $i = 2 To $iMirror - 1 ; No need to go further as later columns are mirrored ConsoleWrite("Column: " & $i & @CRLF) ; Extract column from main array $aCol = _ArrayExtract($aBinArray, 1, $aBinArray[0][$i], $i, $i) ConsoleWrite("Rotating" & @CRLF) ; Now work through column rotating each element For $j = 0 To UBound($aCol) - 2 ; String to rotate $sRotated = $aCol[$j] ; If this element has not already been deleted If $sRotated Then ; Loop through all possible rotations For $k = 1 To $iBit ; Compare to elements in array - only need to look below the current element For $m = $j + 1 To UBound($aCol) - 1 If $aCol[$m] = $sRotated Then ; If there is a match then delete the element $aCol[$m] = "" EndIf Next ; Rotate string While 1 $sRotated = StringRight($sRotated, 1) & StringLeft($sRotated, $iBit - 1) ; Check for trailing 0 - automatically no matches If StringRight($sRotated, 1) = 1 Then ; Check this pattern ExitLoop Else ; Try next rotation, so increase count $k += 1 EndIf WEnd Next EndIf Next ConsoleWrite("Adding" & @CRLF) ; Set start index for later mirroring $aColIndex[$i][0] = $aUnique[0] + 1 ; Add remaining elements to the unique array For $j = 0 To UBound($aCol) - 1 If $aCol[$j] Then $aUnique[0] += 1 $aUnique[$aUnique[0]] = $aCol[$j] EndIf Next ; Set end index $aColIndex[$i][1] = $aUnique[0] ConsoleWrite(TimerDiff($nBegin) & @CRLF) Next ;_ArrayDisplay($aColIndex, "Col indices", Default, 8) ; Now mirror the remaining columns For $i = $iMirror To $iBit - 2 ; Final 2 columns are already unique ConsoleWrite("Column: " & $i & @CRLF) ; Determine column to mirror $iMirrorCol = $iBit - $i ; Mirror found elements ConsoleWrite("Mirroring" & @CRLF) For $j = $aColIndex[$iMirrorCol][0] To $aColIndex[$iMirrorCol][1] $aUnique[0] += 1 $aUnique[$aUnique[0]] = _Mirror($aUnique[$j]) Next ConsoleWrite(TimerDiff($nBegin) & @CRLF) Next ; Add elements from the penultimate and final columns which are also are unique by definition For $i = $iBit - 1 To $iBit ConsoleWrite("Column: " & $i & @CRLF & "Adding" & @CRLF) $aUnique[0] += 1 $aUnique[$aUnique[0]] = $aBinArray[1][$i] Next ReDim $aUnique[$aUnique[0] + 1] ConsoleWrite(TimerDiff($nBegin) & @CRLF) _ArrayDisplay($aUnique, "Unique patterns", Default, 8) Func _Mirror($sString) $aSplit = StringSplit($sString, "") $sMirrorString = "" For $i = 1 To $aSplit[0] $sMirrorString &= ( ($aSplit[$i] = 1) ? (0) : (1) ) Next Return $sMirrorString EndFunc Func Dec2Bin($iD) Return (BitShift($iD, 1) ? Dec2Bin(BitShift($iD, 1)) : "") & BitAnd($iD, 1) EndFunc1 point
-
You beast! The latency in my version is due to the final string formatting, not the method. And here to prove it is the same script without conversion. #include <Array.au3> Local $iBits = 14 Local $aArray, $iTimer $iTimer = TimerInit() $aArray = BitLoopPermute($iBits) ConsoleWrite(TimerDiff($iTimer) / 1000 & " seconds" & @LF) ConsoleWrite(UBound($aArray) & " variants" & @LF) _ArrayDisplay($aArray) Func BitLoopPermute($iBinLen) ; limit = 24 bits $iBinLen = Int($iBinLen) If $iBinLen < 1 Then Return SetError(1) ; lowest loop size = 1 If $iBinLen > 24 Then Return SetError(2) ; to remain within array size limits ;Local $sZeros = StringRight('000000000000000000000000', $iBinLen), _ $oDictionary = ObjCreate("Scripting.Dictionary") $oDictionary.Item(0) Local $iBound = 2^$iBinLen, $aArray[$iBound] For $i = 1 To $iBound -1 Step 2 $aArray[$i] = $i Next Local $iInversion For $i = 1 To $iBound -1 Step 2 If $aArray[$i] Then $iInversion = $aArray[$i] Do $iInversion = FirstInversion($iInversion, $iBinLen) If $iInversion > $aArray[$i] Then $aArray[$iInversion] = '' Until $iInversion = $i ; recursion either due to symmetry or a complete cycle $oDictionary.Item($aArray[$i]) ; generate new key EndIf Next Return $oDictionary.Keys() ; return array EndFunc ;==> BitLoopPermute Func FirstInversion($iInteger, $iLoopSize) ; skips all even numbers If $iLoopSize < 2 Then Return $iInteger Local $iPosition ; the position of the first set bit For $i = 1 To $iLoopSize If BitAND(2^($iLoopSize - $i), $iInteger) Then $iPosition = $i ExitLoop EndIf Next $iInteger -= 2^($iLoopSize - $iPosition) ; remove MSB $iInteger *= 2^($iPosition) ; shift the bits right $iInteger += 1 ; MSB becomes the LSB Return $iInteger EndFunc ;==> FirstInversion Func DecToBase($iInt, $iBase) ; for bases 2 to 9 Local $iRem, $sRet = '' While $iInt > $iBase -1 $iRem = Mod($iInt, $iBase) $sRet = $iRem & $sRet $iInt = Int(($iInt - $iRem) /$iBase) WEnd Return $iInt & $sRet EndFunc ;==> DecToBase Now it takes approx 0.18 seconds. Still slower than your version though!1 point
-
@czardas, nice idea But I had an idea, too We have a "number" and shift it to left until the MSB is at the "bits" position. After that, we rotate that number BITCOUNT times. Bitcount is the number of used bits. 111001 are 6 bits, 111000000111 are 12 bits... Then there are two cases for every of the next bitcount rotations. First case after rotate: The bit at the left border is 1. Without any calculation, this number is always a "rotated" (not unique) one, so we can delete it from the array(index). Rotate means, shift the number left, delete the left bit and write it to the right side. You did that with "strings" in your script. With "numbers" the calculation of the shift is: number = number *2 To delete the left bit : number = number - (2^bits) To "add" the right bit: number = number +1 resulting formula: number = number * 2 - 2^bits +1 or: number = number * 2 - (2^bits-1) If this number is greater than the actual index, this number is always a "rotated" (not unique) one, so we can delete it from the array(index). Second case after rotate: The bit at the left border is 0 0 means, there is no bit to cut from left and add it to the right, only a shift: number =number *2 So we reduce the number of rotations to the number of Bits used by the number aka bitcount. This reduces the over all calculation significantly. #include <Array.au3> ; $bits = 14 $ar = 2 ^ ($bits) - 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ar = ' & Dec2Bin($ar) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console; Dim $a[$ar + 1] For $i = 1 To $ar Step 2 ;all odd numbers $a[$i] = $i ;into array, even ones are 0 Next $m = 2 ^ ($bits - 1) ;msb $mask = 2 ^ $bits - 1 ;mask $timer = TimerInit() For $i = 1 To $ar Step 2 ;all odd numbers If $a[$i] <> 0 Then ;only if not deleted $bitcount = Floor(Log($i) / Log(2)) + 1 ;number of bits of the actual number $t = BitShift($i, $bitcount - $bits) ;shift to the left border $a[$t] = 0 ;greater numbers are always deleted from array For $x = 1 To $bitcount ;only bitcount loops needed to process the number If $t > $m Then ;only if msb =1 $a[$t] = 0 $t = $t * 2 - $mask ;shift left, eliminate msb, add 1 (place msb at bit0) If $t > $i Then $a[$t] = 0 Else $t = $t * 2 ;shift left (because msb=0) EndIf Next EndIf Next ConsoleWrite("time[ms]= " & TimerDiff($timer) & @CRLF) ; $r = _ArrayUnique($a) Dim $c[UBound($r) + 1][2] For $i = 1 To UBound($r) - 1 $c[$i][0] = $r[$i] $c[$i][1] = Dec2Bin($r[$i]) Next $z = _ArrayDisplay($c) Func Dec2Bin($D) Return (BitShift($D, 1) ? Dec2Bin(BitShift($D, 1)) : "") & BitAND($D, 1) ; EndFunc ;==>Dec2Bin1 point
-
The GuiBuilder Return
argumentum reacted to DFerrato for a topic
Thanks argumentum by your corrections and suggestions Daniel1 point -
and the one in native AutoIt, fast #include <Array.au3> $bits = 14 $ar = 2 ^ ($bits) - 1 Dim $a[$ar + 1] For $i = 0 To $ar ;all numbers $a[$i] = $i ;into array Next For $i = 1 To $ar Step 2 ;all numbers If $a[$i] <> 0 Then ;only if not deleted For $x = 1 To $bits - 1 ;ROL loop through all bits $t = ROL2($i, $x, $bits) ;ROLled numbers... If $t > $i Then $a[$t] = 0 ;...are always deleted Next EndIf Next $r = _ArrayUnique($a) ;~ _ArrayDisplay($r) Dim $c[UBound($r) + 1][2] For $i = 1 To UBound($r) - 1 $c[$i][0] = $r[$i] $c[$i][1] = Dec2Bin($r[$i]) Next $z = _ArrayDisplay($c) Func Dec2Bin($D) Return (BitShift($D, 1) ? Dec2Bin(BitShift($D, 1)) : "") & BitAND($D, 1) EndFunc ;==>Dec2Bin Func ROL2($number, $anz, $bits) $var3 = $number $n = 2 ^ $bits For $i = 1 To $anz $var = BitShift($var3, -1) ;shift left 1 $var1 = (BitAND($var, $n) >= 1) ;msb true or false / 1 or 0 $var2 = BitAND($var, $n - 1) ;eliminate msb $var3 = $var2 + $var1 ;add shifted number + MSB Next Return $var3 EndFunc ;==>ROL21 point
-
hmmm, seems we have the same algorithm Chimp, so nice #include <Array.au3> ;#include <assembleit2_64.au3> #AutoIt3Wrapper_UseX64=n #cs ROL_it use32 mov eax, [esp+4] ;number mov edi, [esp+8] ;count mov ecx, [esp+12] ;bits to rol dec ecx ;bitnumber to carry xor ebx,ebx ;=0 jecxz end_rol ;exit, if cnt=zero more_rol: ;loop btr eax,ecx ;bit into carryflag, clear bit setc bl ;Carry into bl ;~ _asmdbg_() ;debugger shl eax,1 ;ROL it add al,bl ;add eax and carrybit sub edi,1 jnz more_rol ;until count is reached end_rol: ret ;eax is returned #ce $bits = 14 $ar = 2 ^ ($bits) - 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ar = ' & Dec2Bin($ar) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $binarycode = "0x8B4424048B7C24088B4C240C4931DBE30F0FB3C80F92C3D1E000D883EF0175F1C3" $tCodeBuffer = DllStructCreate("byte[" & StringLen($binarycode) / 2 - 1 & "]") ;reserve Memory for opcodes DllStructSetData($tCodeBuffer, 1, $binarycode) Dim $a[$ar + 1] For $i = 0 To $ar ;all numbers $a[$i] = $i ;into array Next For $i = 1 To $ar Step 2 ;all numbers in array If $a[$i] <> 0 Then ;only if not deleted For $x = 1 To $bits - 1 ;ROL loop through all bits $t = ROL($i, $x, $bits) ;ROLled numbers... If $t > $i Then $a[$t] = 0 ;...are always deleted Next EndIf Next $r = _ArrayUnique($a) ;~ _ArrayDisplay($r) Dim $c[UBound($r) + 1][2] For $i = 1 To UBound($r) - 1 $c[$i][0] = $r[$i] $c[$i][1] = Dec2Bin($r[$i]) Next $z = _ArrayDisplay($c) Func Dec2Bin($D) Return (BitShift($D, 1) ? Dec2Bin(BitShift($D, 1)) : "") & BitAND($D, 1) EndFunc ;==>Dec2Bin Func ROL($number, $anz, $bits) ;~ $return=_AssembleIt2("uint", "ROL_it", "uint", $number, "uint", $anz, "uint", $bits) ;~ return $return $ret = DllCallAddress("uint:cdecl", DllStructGetPtr($tCodeBuffer), "uint", $number, "uint", $anz, "uint", $bits) Return $ret[0] EndFunc ;==>ROL1 point
-
...... a little adjustment in the logic, now with 14 bits it runs in about 2 seconds. #include <array.au3> Local $iTimer = TimerInit() Local $iBits = 14 ; nr. of bit Local $iTotalCombinations = 2 ^ $iBits ; total number of combinations Local $aCombinations[$iTotalCombinations][2] ; make space to develop all combinations For $i = 0 To $iTotalCombinations - 1 ; To 0 Step -1 $aCombinations[$i][1] = _ToBase($i, 2, $iBits) ; number in binary digits (base number) If $aCombinations[$i][0] = "" Then ; is this combination to be calculated ?? $aCombinations[$i][0] = $i ; index of this "base" number $sBits = $aCombinations[$i][1] For $iRotation = 1 To $iBits - 1 ; generate all rotations of this number. $sBits = StringRight($sBits, $iBits - 1) & StringLeft($sBits, 1) ; rotate the bits $aCombinations[_Bin_To_Dec($sBits)][0] = $i ; same index as the base for any rotated variation Next EndIf Next $aIndexes = _ArrayUnique($aCombinations, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT) ; keep only uniques indexes Local $aResult[UBound($aIndexes)] ; make room for result For $i = 0 To UBound($aIndexes) - 1 $aResult[$i] = $aCombinations[$aIndexes[$i]][1] ; take only one of the possible rotations. Next ConsoleWrite("Elaborated " & $iBits & " in " & Int(TimerDiff($iTimer) / 1000) & " seconds." & @CRLF) _ArrayDisplay($aResult, "uniques") ; http://www.autoitscript.com/forum/topic/93742-converting-decimal-numbers-to-another-base/#entry673358 Func _ToBase($iNumber, $iBase, $iPad = 1) Local $sRet = "", $iDigit Do $iDigit = Mod($iNumber, $iBase) If $iDigit < 10 Then $sRet = String($iDigit) & $sRet Else $sRet = Chr(55 + $iDigit) & $sRet EndIf $iNumber = Int($iNumber / $iBase) Until ($iNumber = 0) And (StringLen($sRet) >= $iPad) Return $sRet EndFunc ;==>_ToBase Func _Bin_To_Dec($BinNum) ; from binary to decimal Local $dec = 0 For $i = 0 To StringLen($BinNum) - 1 $dec += 2 ^ $i * StringMid($BinNum, StringLen($BinNum) - $i, 1) Next Return $dec EndFunc ;==>_Bin_To_Dec1 point
-
So not sure about the rest of you, but even after downloading the SDK and launching the application, I still got errors and was unable to use it (figured out needed to launch as admin for it to work right), but for those who would rather just use a small, portable application that does the exact same thing (and even almost looks the exact same) as the OLE/COM Object Viewer in the Windows SDK, click here. On this page, you will find a crap ton of free tools including "MiTeC OLE/COM Object Explorer 1.3". Enjoy!1 point