Leaderboard
Popular Content
Showing content with the highest reputation on 07/30/2015 in all areas
-
If @error Then EndIf ; Is suffice, unless you really really need to know it produced an error of 62 points
-
I found the idea funny... First attempt : #include <GuiEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $prompt = "#Type a command:> " Global $sel, $oldsel, $readonly, $iMinPos, $iStyle Global $Form = GUICreate("Console", @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $DS_SETFOREGROUND), $WS_EX_TOPMOST) GUISetBkColor(0x000000) Global $Console = GUICtrlCreateEdit('Loading...', 32, 32, @DesktopWidth-15, @DesktopHeight - 64, $ES_AUTOVSCROLL, 0) GUICtrlSetFont(-1, 12, 400, 0, 'OCR A Extended') GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0) GUICtrlSetCursor (-1, 2) _GUICtrlEdit_SetMargins( -1, $EC_RIGHTMARGIN, Default, 49) Global $dummy = GUICtrlCreateDummy() Global $aKeys[1][2] = [["{ENTER}", $dummy]] GUISetAccelerators($aKeys) GUISetState(@SW_SHOW) Sleep(1000) _Enter() While True $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Quit() Case $dummy _Enter() EndSwitch $sel = _GUICtrlEdit_GetSel($Console) If $sel <> $oldsel Then $oldsel = $sel If $sel[0] < $iMinPos Or $sel[1] < $iMinPos Then If NOT $readonly Then GUICtrlSetStyle($Console, $ES_READONLY) $readonly = 1 EndIf Else If $readonly Then $readonly = 0 $iStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($Console), $GWL_STYLE) GUICtrlSetStyle($Console, BitXOR($iStyle, $ES_READONLY)) EndIf EndIf EndIf WEnd Func Quit() _GUICtrlEdit_AppendText($Console, @CRLF&@TAB&'Goodbye...') Sleep(1500) Exit EndFunc Func _Enter() Local $sCommand = StringRegExp( GUICtrlRead($Console), "\R\Q" & $prompt & "\E\h*(\N*)$|()$", 1)[0] Switch $sCommand Case "clear" GUICtrlSetData($Console, "") Case "quit", "exit" Quit() Case "" Beep(1000,50) Case Else _GUICtrlEdit_AppendText($Console, @CRLF & @TAB & $sCommand & " : command not found") EndSwitch _GUICtrlEdit_AppendText($Console, @CRLF & $prompt) $iMinPos = StringLen(GUICtrlRead($Console) ) EndFunc1 point
-
Just changed the username to "TheDcoder" in GitHub, There was a user called "TheDCoder" when I joined GitHub, I contacted GitHub about his, this was the reply: I am happy, TD1 point
-
It's not. Search online for it's usage.1 point
-
Just as a curiosity I scribbled a simple test. #include <Array.au3> Local $oArrayList = ObjCreate("System.Collections.ArrayList") If Not IsObj($oArrayList) Then Exit MsgBox(0, "Error", "Object not created") EndIf Local $aArray[0] Local $iTimer = TimerInit() _AddToArray() ConsoleWrite("Array: " & TimerDiff($iTimer) & @LF) $iTimer = TimerInit() _AddToArrayList() ConsoleWrite("ArrayList: " & TimerDiff($iTimer) & @LF) Func _AddToArray() _ArrayAdd($aArray, "Hello") _ArrayAdd($aArray, "World") _ArrayInsert($aArray, 1, "There") EndFunc ;==>_AddToArray Func _AddToArrayList() $oArrayList.Add("Hello") $oArrayList.Add("World") $oArrayList.Insert(1, "There") EndFunc ;==>_AddToArrayList I get results around the region of...1 point
-
ArrayList is old and was created before generics existed in v2.0. Anyway, use Scripting.Dictionary or the Autoit array data structure.1 point
-
Does not return an object on Win8.1, and tells me i need to install .Net 3.5. Though it shows as available on 4, 4.5, and 4.6 here: https://msdn.microsoft.com/en-us/library/system.collections.arraylist(v=vs.110).aspx1 point
-
Hi, What BrewmanNH explained is that you just need to create the file as UTF16-LE, like this: _Example1() Func _Example1() FileDelete('test.ini') Local $h = FileOpen('test.ini', 2 + 1024) ; <--- here FileWrite($h, @CRLF) ; you need to write something FileClose($h) MsgBox(0, '0', FileGetEncoding('test.ini')) ; 1024 = UTF16-LE IniWrite('test.ini','Test1','1','Piorko') MsgBox(0, '1', FileGetEncoding('test.ini')) IniWrite('test.ini','Test1','2','Piórko') IniWrite('test.ini','Test1','3','αβγδεζηθ') IniWrite('test.ini','Test1','4','ЖЗИЙЛЦЩ') MsgBox(0, '2', FileGetEncoding('test.ini')) MsgBox(0, '2', IniRead('test.ini','Test1','2','')) MsgBox(0, '3', FileRead('test.ini')) EndFuncIf you ever delete the file, you must recreate it as UTF16-LE again. Then both *INI functions, FileRead* and FileWrite* don't need extra steps to correctly handle it.1 point
-
Color Variation
Guilherme Tocchetto reacted to BrewManNH for a topic
In the help file, under PixelSearch, you will notice that there is a parameter in the function for shade variation.1 point -
you can play a bit with both ways, that is: by using only _Array* functions or by involving Sqlite to our rescue. Here two examples to play with: 1) By using only _Array* functions (basically _ArrayUnique() and _ArrayFindAll() ) #include <array.au3> local $aInput[27][4] = [['Name', 'Team', 'Age', 'Salary'], _ ['A', 'Blue', '41', '98658'], _ ['B', 'Red', '40', '54406'], _ ['C', 'Green', '33', '74489'], _ ['D', 'Yellow', '36', '57857'], _ ['E', 'Red', '34', '55565'], _ ['F', 'Blue', '33', '83666'], _ ['G', 'Yellow', '44', '66627'], _ ['H', 'Red', '40', '63970'], _ ['I', 'Red', '49', '89346'], _ ['J', 'Blue', '37', '79437'], _ ['K', 'Red', '41', '79038'], _ ['L', 'Yellow', '31', '84754'], _ ['M', 'Red', '46', '96611'], _ ['N', 'Blue', '43', '86699'], _ ['O', 'Red', '32', '94452'], _ ['P', 'Red', '39', '77050'], _ ['Q', 'Yellow', '31', '76837'], _ ['R', 'Blue', '45', '59680'], _ ['S', 'Red', '50', '72844'], _ ['T', 'Blue', '42', '90642'], _ ['U', 'Red', '48', '83451'], _ ['V', 'Blue', '38', '60356'], _ ['W', 'Red', '37', '70999'], _ ['X', 'Yellow', '46', '70282'], _ ['Y', 'Red', '47', '69867'], _ ['Z', 'Red', '48', '57109']] _ArrayDisplay($aInput, "Input as array") Local $ii $aUniques = _ArrayUnique($aInput, 1, 1, 0, 0) Local $aOutputs[UBound($aUniques) + 1][UBound($aInput, 2)] ; make room for output data For $i = 0 to UBound($aUniques) - 1 ; scan all uniques $ii = $i + 1 ; do not use row 0 of $aOutputs (shift all rows by 1), row 0 will be used for titles of columns $aIndexes = _ArrayFindAll($aInput, $aUniques[$i], 1, 0, 0, 0, 1) ; rows of $aInput containing only the unique nr. $i $aOutputs[$ii][1] = $aInput[$aIndexes[0]][1] ; the name of this unique goes to column 1 of $aOutputs for $i2 = 0 to UBound($aIndexes) - 1 ; scan all rows containing this "team" value $aOutputs[$ii][2] += $aInput[$aIndexes[$i2]][2] ; sum all ages (column 2) $aOutputs[$ii][3] += $aInput[$aIndexes[$i2]][3] ; sum all salary (column 3) Next $aOutputs[$ii][2] = Round($aOutputs[$ii][2] / UBound($aIndexes), 5) ; average of ages Next ; next group of uniques for $i = 0 to UBound($aInput, 2) - 1 ; titles of columns $aOutputs[0][$i] = $aInput[0][$i] Next _ArrayDisplay($aOutputs, "Outputs 1 & 2")2) by using an udf that will facilitate you allowing the use of SQL (nearly) directly on arrays: ; by sql #include <array.au3> #include <ArraySQL.au3> ; <-- https://www.autoitscript.com/forum/topic/166536-manage-arrays-by-means-of-sql/#comment-1234441 Local $aInput[26][4] = [['A', 'Blue', '41', '98658'], _ ['B', 'Red', '40', '54406'], _ ['C', 'Green', '33', '74489'], _ ['D', 'Yellow', '36', '57857'], _ ['E', 'Red', '34', '55565'], _ ['F', 'Blue', '33', '83666'], _ ['G', 'Yellow', '44', '66627'], _ ['H', 'Red', '40', '63970'], _ ['I', 'Red', '49', '89346'], _ ['J', 'Blue', '37', '79437'], _ ['K', 'Red', '41', '79038'], _ ['L', 'Yellow', '31', '84754'], _ ['M', 'Red', '46', '96611'], _ ['N', 'Blue', '43', '86699'], _ ['O', 'Red', '32', '94452'], _ ['P', 'Red', '39', '77050'], _ ['Q', 'Yellow', '31', '76837'], _ ['R', 'Blue', '45', '59680'], _ ['S', 'Red', '50', '72844'], _ ['T', 'Blue', '42', '90642'], _ ['U', 'Red', '48', '83451'], _ ['V', 'Blue', '38', '60356'], _ ['W', 'Red', '37', '70999'], _ ['X', 'Yellow', '46', '70282'], _ ['Y', 'Red', '47', '69867'], _ ['Z', 'Red', '48', '57109']] _ArrayDisplay($aInput, "Input as array") $sQuery = "Select column1,avg(column2), sum(column3) from array group by column1;" $aResult = _ArraySQL($aInput, $sQuery) _ArrayDisplay($aResult)1 point
-
SciTE 3.2.5.99 has been updated (build 1.2.0).1 point
-
suntisuka, You can find inspiration for the DLL in this AutoIt example.1 point
-
Hm, if you don't have much experience with "the coding stuff", I'd like you to be responsible for documentation. I'll type up some guidelines to this on the weekend and I'll create a Perseus-Doc repo on my github. Today, I have migrated all repos from the Perseus Developer group to my private profile. I'll create a new group once I've come up with clear guidelines.1 point
-
EXCEL OBJGET & CREATE
232showtime reacted to water for a topic
I would reduce it to: If ProcessExists("excel.exe") Then $oExcel = ObjGet("", "Excel.Application") Else $oExcel = ObjCreate("Excel.Application") EndIfSo you save the second ProcessExists. What is still missing is the error checking.1 point -
SQLite encryption with System.Data.SQLite.dll
argumentum reacted to jchd for a topic
I just downloaded this version then copied the DLL in the @scriptdir from the zip file. Then this exemple works as intended: #include <SQLite.au3> ; don't include sqlite.dll.au3 !!! Local $path = @ScriptDir & "\mydb.sql" _SQLite_Startup ("System.Data.SQLite.dll") ConsoleWrite(_SQLite_LibVersion() & @LF) Local $row ; using encryption _SQLite_Open($path) _SQLite_Exec(-1, "pragma key = 'Radu is happy!';create table if not exists test (id integer, val text);" & _ "insert into test values (1, 'abc');") _SQLite_QuerySingleRow(-1, "select * from test;", $row) ConsoleWrite($row[1] & @LF) _SQLite_Close(-1) ; not using encryption over the encrypted DB gives a failure _SQLite_Open($path) _SQLite_QuerySingleRow(-1, "select * from test;", $row) ConsoleWrite(_SQLite_ErrMsg(-1) & @LF) _SQLite_Close(-1) ; changing back to no encryption _SQLite_Open($path) _SQLite_Exec(-1, "pragma key = 'Radu is happy!'") _SQLite_Exec(-1, "pragma rekey = ''") _SQLite_QuerySingleRow(-1, "select * from test;", $row) ConsoleWrite($row[1] & @LF) _SQLite_Close(-1) _SQLite_Shutdown()1 point -
Uploaded v3.3.14.1 Removed au3record.exe as it's often mistakenly flagged as malware causing the entire AutoIt zip/installer to be flagged. We'll host it separately.Reworked AutoIt3Help.exe and applied a digital signature to help with malware false positives - as above.No other changes to the AutoIt exes so no real need to update if you are not having issues.1 point
-
Use input control as fake label to avoid flickering on update
jaberwacky reacted to UEZ for a topic
Nice catch KaFu Here an additional one: #include <WindowsConstants.au3> #include <EditConstants.au3> HotKeySet("{ESC}", "_Exit") GUICreate("My GUI", 300, 200, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED)) GUISetBkColor(0x00ff00) $c_Label = GUICtrlCreateLabel(0, 10, 10, 200, 20) $c_Input = GUICtrlCreateInput(0, 10, 60, 200, 20) ;, $ES_READONLY, $WS_EX_TRANSPARENT) GUICtrlSetBkColor(-1, 0x00ff00) GUICtrlSetCursor(-1, 2) ; Arrow GUISetState(@SW_SHOW) While 1 GUICtrlSetData($c_Label, TimerInit()) GUICtrlSetData($c_Input, TimerInit()) WEnd Func _Exit() Exit EndFunc ;==>_Exit1 point -
jsnyder213, Sorry for the late reply. Now to answer one of your questions. The reason my the script I gave you executes correctly, and your's didn't is due to UAC (User Account Control). A process will not execute with full admin rights unless it is requested from the user executing the process, and that user has to have the rights to request elevation. This is why you see "Run as administrator" in the context menu, when you right click on some file types. In the script, the ShellExecuteWait with the "runas" verb, request the elevation. Since we are running it in a non-admin user context, we have to re-execute the script as the admin user. Now that the script is running by a user that can request elevation, the script re-executes itself again, requesting the admin token. There are other ways of doing this, but for me I believe this is the simplest in turns of scripting. There is one thing I should of mentioned that may be related to your CD issue. After the script has re-executed itself as a different user, the user that it is running as must have rights to access to the file locations of the other files that may be used in the script. Also, I try to use full paths when calling file, like the MSIs. I'm glad that jguinch was able to help you. Adam1 point
-
RunAs
revertex reacted to jsnyder213 for a topic
OK, so Thanks to @AdamnUL, I have my script working for a user that does nto have admin rights to the machine. They can double click on the .exe file and the MSI's run as needed. However, now, if I put it on a CD/DVD I get the error stating that the MSI can not be found. Code: Global $sAdminUser = "ADMIN" Global $sAdminPassword = "PASSWORD" Global $sDomain = @ComputerName Global $iLogOnFlag = 0 Global $sParameters = "" ;Elevate with Admin account. If @UserName <> $sAdminUser And Not IsAdmin() Then $sParameters = "" If Not @Compiled Then $sParameters = ' "' & @ScriptFullPath & '"' EndIf If RunAs($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) Then Exit Else Exit MsgBox(16 + 262144, "ERROR!", "Unable to run under administrator account.") EndIf EndIf ; Run with Admin Token in Windows Vista and Higher. If @UserName = $sAdminUser And Not IsAdmin() And Not StringRegExp(@OSVersion, "_(XP|200(0|3))") Then $sParameters = "" If Not @Compiled Then $sParameters = '"' & @ScriptFullPath & '"' EndIf If ShellExecute(@AutoITExe, $sParameters, "", "runas") Then Exit Else Exit MsgBox(16+262144, "ERROR!", "Unable to elevate to Admin due to UAC.") EndIf EndIf ; Script for MSI Runwait('msiexec /i CiscoJabberSetup.msi /qb ALLUSERS=2 CLEAR=1 SERVICES_DOMAIN=DOMAIN') MsgBox(0, "Complete", "You are done! Click OK") I converted this file to an .exe and saved it to a disc. When I run it, it can't find the file path. I can do Nameofdrive\subfolder\CiscoJabberSetup... (and it works!) but not every machine is going to have the CD drive as the same drive letter (machine I burned it on was E:\ but test machine's CD drive is D:\... so this won't work). *note: the .exe is in the same subfolder as the MSI files. What excatly am I missing here?1 point -
Change the domain to Global $sDomain = @ComputerNamefor a local admin account. This will allow a normal user to run the script with full admin rights using the local admin account. Use RunWait or ShellExecuteWait commands to run the MSI's silently after the code I posted. You can replace the MsgBox calls with what ever error catching you would like. You might want to put in a progress box (See functions ProgressOn, ProgressSet, and ProgressOff.), so the user knows what is installing and the script is running, or call each MSI with the "/qb-" switch. Adam1 point
-
RunAs
revertex reacted to jsnyder213 for a topic
whoa. this is intense. I was hoping to store the local admin in the .exe. The users that will be getting this deployment, do not have local admin rights to their machine... so they are prevented from installing anything on their machines. I need a package that stores the local admin account, and runs the MSI files (preferably silent) to install the software.1 point -
Update system date/time via HTTP (Firewall workaround)
ThomasLx reacted to TouchOdeath for a topic
I know this is an old thread, but I reworked the code to place everything in a func which changed globals to locals, and it returns the date/time in an array. so that way you can do 1 global variable array if one so desired. The missing backslashes are there. ;usage Global $currentdatetimearr = SetSysTime() ;or you could just do SetSysTime() without the global variable. func SetsysTime() ; For the ActiveTimeBias registry key: ; 4294967296 = 0 for UTC +X:YZ Time zones ; subtract value of key to get Time zone offset. ; EG: 4294976296-4294976236 = 60 = UTC +1:00; ; UTC Time zone uses 0 for the value; ; UTC -A:BC Time zones use the number of minutes of the offset ; EG: 480 = UTC -8:00; To-Do: ; 1. Add a timezone check to make sure the system is properly configured for its area ; EG: Time Zone is currently "Pacific Standard Time", is this correct? [Y/N] ; 2. Add error checking to _EndOfMonth() should the need arise [user editing of code] ; EG: -2 is not a valid month, you silly goose! ; ---------------------------------------------------------------------------------------------------------------------------------- ; Get Time from HTTP server (Defaults to google.com ... pool.ntp.org is a good alternative) ; ---------------------------------------------------------------------------------------------------------------------------------- $site = "www.google.com" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://" & $site & "/", False) $oHTTP.Send() $date = $oHTTP.GetResponseHeader("Date") ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set Global variables used throughout the script ; ---------------------------------------------------------------------------------------------------------------------------------- ; $tzo: timezoneOffset (the number of hours by which the local machine varies from UTC) Local $tzo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation", "ActiveTimeBias"), _ $y = StringMid($date, 13, 4), _ ; The current year $m = StringMid($date, 9, 3), _ ; The current month $d = StringMid($date, 6, 2), _ ; The current day of month $h = StringMid($date, 18, 2), _ ; The current hour $n = StringMid($date, 21, 2), _ ; The current minute $s = StringMid($date, 24, 2) ; The current second If $tzo < 1500 Then $tzo /= -60 Else $tzo = (4294967296 - $tzo) / 60 EndIf ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Calculate Time zone changes (correct the hour/day/month/year based on timezone/hour/day/month changes ; ---------------------------------------------------------------------------------------------------------------------------------- $h += $tzo ; Set the local hour based on offset from UTC Select ; If the hour changes day forward/backward, correct appropriate values. Case $h >= 24 $d += 1 $h -= 24 Case $h < 0 $d -= 1 $h += 24 EndSelect Switch $m Case 'JAN'; 31 days in month $m = 1 Case 'FEB'; 28/29 days in month $m = 2 Case 'MAR' ; 31 days in month $m = 3 Case 'APR'; 30 days in month $m = 4 Case 'MAY'; 31 days in month $m = 5 Case 'JUN' ; 30 days in month $m = 6 Case 'JUL' ; 31 days in month $m = 7 Case 'AUG' ; 31 days in month $m = 8 Case 'SEP' ; 30 days in month $m = 9 Case 'OCT' ; 31 days in month $m = 10 Case 'NOV' ; 30 days in month $m = 11 Case 'DEC' ; 31 days in month $m = 12 EndSwitch Local $epm = _EndOfMonth($m - 1), _ ; The last day of the previous month (28-31) $ecm = _EndOfMonth($m) ; The last day of the current month (28-31); Correct value for $tzo from the registry value to a +/- number of hours Switch $d ; If the day changes month forward/backward, correct appropriate values. Case $ecm + 1 $m += 1 $d = 1 Case 0 $m -= 1 $d = $epm EndSwitch Switch $m ; If the month changes year forward/backward, correct appropriate values. Case 0 $m = 12 $d = 31 $y -= 1 Case 13 $m = 1 $d = 1 $y += 1 EndSwitch ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set system date/time using functions from #include ; ---------------------------------------------------------------------------------------------------------------------------------- _SetDate($d, $m, $y) _SetTime($h, $n, $s) local $sysdatetime[6] $sysdatetime[0] = $m $sysdatetime[1] = $d $sysdatetime[2] = $y $sysdatetime[3] = $h $sysdatetime[4] = $n $sysdatetime[5] = $s Return $sysdatetime ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; FUNCTION: _EndOfMonth ::: Determine the ending date of the month (28, 29, 30, or 31) ; ---------------------------------------------------------------------------------------------------------------------------------- EndFunc Func _EndOfMonth($vMON) Local $end Switch $vMON Case 0, 1, 3, 5, 7, 8, 10, 12, 13 $end = 31 Case 4, 6, 9, 11 $end = 30 Case 2 If IsInt(@YEAR / 4) Then $end = 29 Else $end = 28 EndIf Case Else SetError(-1) Return (0) EndSwitch Return ($end) EndFunc ;==>_EndOfMonth1 point