Leaderboard
Popular Content
Showing content with the highest reputation on 09/16/2016 in all areas
-
A simple random number generator based on "Middle Square" method.
coffeeturtle and 2 others reacted to jchd for a topic
That is flawed and terribly weak. Your algorithm isn't even midddle square but middle n*256. Read up this botleg extract from TAOCP about PRNGs: https://vk.com/doc10903696_194276164?hash=1fc65ed563521b76e6&dl=ebca64d98d089930e0 BTW all serious PRNG are predictable in that there is nothing random in their code. This is even a requirement to assess anything about the algorithm. You'd have a fairly hard time to prove its pseudo-randomness usefulness: when you say it produces 8 random digits (here you mean pseudo-...) at each invokation, realize that this is a bold statement you just can't prove anyhow. Assertion #7 is also plain wrong. #include <Array.au3> Local $a[100] For $i = 0 To UBound($a) - 1 $a[$i] = MiddleSquareRandom($i) Next _ArrayDisplay(_Array1DToHistogram($a)) Func MiddleSquareRandom($iSeed = @MSEC) Local Const $TURNS = 8 Local $sRandomNumber, $sSeed For $iTurn = 1 To $TURNS $iSeed = $iSeed * 2 $sSeed = String($iSeed) $sRandomNumber &= StringMid($sSeed, Ceiling(StringLen($sSeed) / 2), 1) Next Return Int($sRandomNumber) EndFunc3 points -
Hi Fedeic, You have to select some settings in AutoIt Recorder window to overcome this error. Please follow the instructions here - How to overcome autoit recorder undefined function error? You can get an overview of AutoIt Recoder here - AutoIt Recorder Overview Thank you2 points
-
- _____ _____ _ _ - |_ _|___ ___ ___ _ _| __|___ ___|_|___| |_ - | | | -_| -_| | | |__ | _| _| | . | _| - |_| |___|___|_|_|_ |_____|___|_| |_| _|_| - By TarreTarreTarre|___|Build '1.0.0' |_| + F5 = Run script + F6 = Build 'AU3' + F7 = Build 'EXE' + F8 = Options GUI + F10 = Exit TeenyScript All example code and documentation moved to: http://teenyscript.tarre.nu/documentation Official Github repo: http://github.com/tarreislam/teenyscript F.A.Q Q: What is TeenyScript? A: TeenyScript is a Superset of AutoIt which makes it more advanced Q: How does it work? A: TeenyScript code are parsed into native AutoiT code Q: Does it depend on anything else than AutoIt? A: Just one dependency, that is AutoitObject, the best UDF ever created for AutoIt, besides that, only Native AutoIt is used Features "Anonymous" functions Endless scope nesting OOP (powered by AutoitObject) User-friendly integration Powerful macros Namespaces Lists Project support, for easy deployment Userfriendly GUI for userfriendly Tasks for the Userfriendly person And much more To come You decide, I am happy to do requests! Install and Update TeenyScript HOW TO GET STARTED Run TeenyScript.au3 Now this should see something like this in your console Code Press F8 and navigate to the misc tab to install SciTE calltips Run \ Build \ Compile How to run with Sublime Text Here is some examples of TeenyScript code ;Basic List usage $Example_A = Func() ; Create a list Local $myList = { 'Name': 'Tarre' } ; Add \ Change data on $MyList $myList{'Age'} = 25 ; Create MySecondList Local $MySecondList = { "Name" => "John", "Age" => "00" } ; Using variable instead of a string Local $KeyName = "Age" Local $KeyVal = 1337 $MySecondList{$KeyName} = $KeyVal ; You may also pass lists to lists. however this has to be done in this fashion. Local $oList = {'myList': $myList, 'mySecondList' => $MySecondList} ; Return the objects Return $oList EndFunc();call the function on the variable ; Loop through list and print their values $Example_B = Func() Local $MyList = {'A': 'Hello FROM A', 'B': 'Hello FROM B', 'C': 'Hello FROM C'} Local $aNames = ['A', 'B', 'C'] For $i = 0 To UBound($aNames) -1 MsgBox(0,0,$myList{$aNames[$i]}) Next EndFunc #MAIN MsgBox(0,"Example A 1", $Example_A.myList.Name) MsgBox(0,"Example A 2", $Example_A.myList.Age) MsgBox(0,"Example A 3", $Example_A.mySecondList.Name) MsgBox(0,"Example A 4", $Example_A.mySecondList.Age) $Example_B(); Execute examble B Here is a non class nested function calculator example (calculator.ts.au3) $calculator = Func($a, $and, $b) $division = Func($a, $b) if Not $a or Not $b Then Return "Error dividing 0" EndIf Return $a/$b EndFunc Switch $and Case '+' Return $a + $b Case '-' Return $a - $b Case '/' Return $division($a, $b) Case '*' Return $a * $b EndSwitch Return "Unkown attribute "&$and EndFunc #MAIN ConsoleWrite($calculator(25, '*', 25)&@CRLF) ConsoleWrite($calculator(25, '/', 0) & @CRLF) ConsoleWrite($calculator(1, '^', 2) & @CRLF) teeny-script.zip (OLD) TeenyScript beta2.zip (OLD) teeny-script Beta 4.zip (OLD) teeny-script Beta 5.zip (OLD) teeny-script BETA 6.zip (OLD) TeenyScript Beta 7.zip (OLD) teeny-script Beta 8.zip (OLD) TeenyScript-master 1.0.0.zip (OLD) TeenyScript-1.1.0.zip (OLD) TeenyScript-1.2.0.zip (OLD) TeenyScript-2.0.0.zip (OLRD, Release notes) TeenyScript-2.1.3.zip (Newest 2016-09-16, Release notes)1 point
-
Difficulty with Combo Box
spudw2k reacted to JLogan3o13 for a topic
Understand, there is absolutely nothing wrong with your code the way you have it; it is solid and works. You will find, as you continue using AutoIt, that there are often many multiple ways to tackle a problem. Forum members will often offer up alternatives simply as a "You could always do it this way, too" suggestion; often those suggestions may lead to something you've never considered, or you may find an amalgam of several suggestions gives you the code that works best for your situation1 point -
#AutoIt3Wrapper_Version=b #include <File.au3> #include <Array.au3> Global $sFilters = "*.psd;*.jpg;*.png;*.gif;*.ico;*.txt;*.mp3" Global $aFilters = StringRegExp($sFilters, "\.(...?)", 3) Global $aFiltersCounter[UBound($aFilters) + 1][2] $aResult = _FileListToArrayRec("c:\temp", $sFilters, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_NOPATH) For $i = 1 To $aResult[0] $iPos = _ArraySearch($aFilters, StringRight($aResult[$i], 3)) $aFiltersCounter[$iPos][1] += 1 Next For $i = 0 To UBound($aFilters) - 1 If $aFiltersCounter[$i][1] = "" Then $aFiltersCounter[$i][1] = 0 $aFiltersCounter[$i][0] = $aFilters[$i] Next $aFiltersCounter[UBound($aFiltersCounter) - 1][0] = "Total Files Scanned" $aFiltersCounter[UBound($aFiltersCounter) - 1][1] = $aResult[0] _ArrayDisplay($aFiltersCounter, "Extension Counter", "", 0, Default, "Extension|Count")1 point
-
Your last param in the mouse click is 0, meaning 0 clicks. Remove it to make it 1 or set it to something > 01 point
-
You mean how to get a count of the number of files of each type? Try something like: #include <Array.au3> #NoTrayIcon Main() Func Main() $_ifiletypes = 2 ; Number of file types we're looking for ; Create a 2 dimension array containing the file extension to search for and it's count Local $_afiletypes[$_ifiletypes][2] = [["*.txt", 0], ["*.au3", 0]] For $loop1 = 0 To $_ifiletypes - 1 Step 1 ; Create a loop to search for each file count Local $_hFile = FileFindFirstFile($_afiletypes[$loop1][0]) ; Search for the first file of that file type If $_hFile = -1 Then ; If No File with that file type found ExitLoop ; Skip the file type and leave the start count was it was Else ; Otherwise Do $_afiletypes[$loop1][1] += 1 ; Add 1 to the file count FileFindNextFile($_hFile) ; Look for more of that file Until @error ; Stop if no more $_afiletypes[$loop1][1] -= 1 ; The above always returns 1 more than there actually is, fix it EndIf FileClose($_hFile) ; Clean up resources Next _ArrayDisplay($_afiletypes) ; Display result EndFunc1 point
-
Hey @AdamUL, I really appreciate your response and customized script. I read through your posts and it helped me a lot to understand the process. However, with my script I'm already using #RequireAdmin and my goal was to not to use re-execution (if possible). Luckily, after days of researching I was able to find the solution I was looking for. I copied and modified an already existing function from this post: Hopefully, I've done this correctly but please correct me if needed. Func _LogonOnUser($sUsername, $sPassword, $sServer = @LogonDomain) Local $aRet Local $stToken Local $phToken Local $nError = -1 $stToken = DllStructCreate("int") $aRet = DllCall("advapi32.dll", "int", "LogonUser", _ "str", $sUsername, _ "str", $sServer, _ "str", $sPassword, _ "dword", 8, _ ; LOGON32_LOGON_NETWORK_CLEARTEXT "dword", 0, _ "ptr", DllStructGetPtr($stToken)) $phToken = DllStructGetData($stToken, 1) If Not @error And $aRet[0] <> 0 Then ;Return True ; Return True if user exists $aRet = DllCall("advapi32.dll", "int", "ImpersonateLoggedOnUser", "ptr", $phToken) If Not @error And $aRet[0] <> 0 Then ConsoleWrite("Impersonated User = " & @UserName & @CRLF) ; Do Impersonation Stuff Here _InitiatePermissionResources() ; Requires Permissions UDF Else $aet = DllCall("kernel32.dll", "int", "GetLastError") If Not @error Then $nError = $aRet[0] EndIf DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $phToken) Else $aRet = DllCall("kernel32.dll", "int", "GetLastError") If Not @error Then $nError = $aRet[0] EndIf If $nError > -1 Then SetError($nError) Return 0 EndIf Return 1 EndFunc ;==>_LogOnUser Once the process is completed I then _LogOffUser and RevertToSelf Func _LogOffUser() _ClosePermissionResources() ; Requires Permissions UDF DllCall("advapi32.dll", "int", "RevertToSelf") ConsoleWrite("RevertToSelf User = " & @UserName & @CRLF) EndFunc Permissions Applied Successfully! If I don't use the _LogonOnUser function it errors out and I lose access to my network folders and it disappears! Luckily, I am able to recover it when I use this function.1 point
-
Însert a Col and assign the wanted data to the new elements. After sort the array #include <Array.au3> $ini = @ScriptDir&"\ini.ini" $aArrays = IniReadSectionNames($ini) _ArrayColInsert($aArrays,1) For $i = 1 To UBound($aArrays)-1 $aArrays[$i][1]=StringRegExp($aArrays[$i][0],'.*\\(.*)\\',1)[0] Next _ArraySort($aArrays,0,1,0,1) ;_ArrayColDelete($aArrays,1) _ArrayDisplay($aArrays) If inserted col isn't needed you can delete it1 point
-
file install
spudw2k reacted to JLogan3o13 for a topic
Aside from FileInstall, why would you want to go through the headache of manually automating the Adobe Reader installation, instead of just installing it silently? Grab the AcroRead MSI and then just do something like this: ShellExecuteWait('msiexec.exe', '/i "AcroRead.msi" /qn')1 point -
Your usage of GetDefaultSharedFolder is wrong. You are providing too many parameters. Shouldn't Global $soItems = $aFolders[1].items do the trick?1 point
-
You have to modify the _WM_LBUTTONDOWN function accordingly: #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <StructureConstants.au3> #include <WinAPIConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hMain = GUICreate("Parent", 400, 400, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) ;~ GUISetBkColor(0xABCDEF) ;~ _WinAPI_SetLayeredWindowAttributes($hMain, 0xABCDEF, 255) GUISetState(@SW_SHOWNA, $hMain) _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global $iW, $iH, $hImage, $hBitmap, $hGUI_Child1, $hGUI_Child2 $hImage = _GDIPlus_BitmapCreateFromFile("C:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png") $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hGUI_Child1 = GUICreate("", $iW, $iH, 0, 0, $WS_POPUP, $WS_EX_LAYERED) _WinAPI_SetParent($hGUI_Child1, $hMain) _WinAPI_BitmapDisplayTransparentInGUI($hBitmap, $hGUI_Child1) GUISetState(@SW_SHOWNA, $hGUI_Child1) $hGUI_Child2 = GUICreate("", $iW, $iH, 150, 150, $WS_POPUP, $WS_EX_LAYERED) _WinAPI_SetParent($hGUI_Child2, $hMain) _WinAPI_BitmapDisplayTransparentInGUI($hBitmap2, $hGUI_Child2) GUISetState(@SW_SHOWNA, $hGUI_Child2) ;~ GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hBitmap2) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() GUIDelete() Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI_Child1, $iOpacity = 0xFF, $bReleaseGDI = True) If Not BitAND(GUIGetStyle($hGUI_Child1)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI_Child1, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hGUI_Child1, $hGUI_Child2 _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch EndFunc ;==>_WM_LBUTTONDOWN Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc1 point
-
The example from the AutoIt documentation (ObjEvent) shows how to:1 point
-
[Updated!] Quickly Email False Positives to AV Vendors
coffeeturtle reacted to EmilyLove for a topic
Updated Mail List (Delete the Registry Key at "HKEY_CURRENT_USER\SOFTWARE\BetaLeaf Software\FalsePositiveReporter\ToAddress") to use the latest list. Comment below if you would like to suggest edits!1 point -
https://drive.google.com/open?id=0B23_uXFHGQQ1M2c2UHdpTC1fd1U Nop, didn't try that and never used fastfind.1 point
-
Maybe this is documented here: https://www.autoitscript.com/wiki/OutlookEX_UDF_-_General#Running_script_as_Administrator1 point
-
Advertising commercial products isn't allowed here.1 point
-
[Updated!] Quickly Email False Positives to AV Vendors
coffeeturtle reacted to EmilyLove for a topic
Update: Added Reason Core Security to the list of Anti-Virus Vendors.1 point -
[Updated!] Quickly Email False Positives to AV Vendors
coffeeturtle reacted to EmilyLove for a topic
By all means, customize away. You can get each vendor's email from http://www.techsupportalert.com/content/how-report-malware-or-false-positives-multiple-antivirus-vendors.htm#List_Of_All_Vendors if you cannot figure it out from the default list.1 point