Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/29/2018 in all areas

  1. Subz

    Combine 32 & 64 Reg values

    Maybe something like: #include <GuiListView.au3> Opt("TrayAutoPause", 0) Opt('GUIOnEventMode', 1) Opt('GUICloseOnEsc' , 1) Global $aSoftwareInfo[0][5] _SoftwareInfo("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") _SoftwareInfo("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") Global $hGui = GUICreate('Currently Installed Software', 810, 650, -1, -1) Global $idListView = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600) _GUICtrlListView_AddArray($idListView, $aSoftwareInfo) GUICtrlSendMsg($idListView, 0x101E, 1, 175) GUICtrlSendMsg($idListView, 0x101E, 2, 65) GUICtrlSendMsg($idListView, 0x101E, 3, 150) GUICtrlSendMsg($idListView, 0x101E, 4, 350) Local $mMen = GUICtrlCreateContextMenu($idListView) Local $Uninstall = GUICtrlCreateMenuItem('Proceed to Software uninstallation', $mMen) GUICtrlSetOnEvent($Uninstall, '_Uninstall') Local $exp = GUICtrlCreateButton(' Expand ', 720, 615) GUICtrlSetOnEvent($exp, '_Expand') GUISetOnEvent(-3, '_AllExit') GUISetState(@SW_SHOW, $hGui) While 1 Sleep(10) WEnd ; Func _AllExit() GUIDelete($hGui) Exit EndFunc Func _Uninstall() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($idListView)), '|', 1) If $proc[1] == 0 Then Return -1 ShellExecuteWait ($proc[5]) EndFunc Func _SoftwareInfo($_sHKLMUninstall) Local $i = 1 While 1 $sRegKey = RegEnumKey($_sHKLMUninstall, $i) If @error Then Exitloop If RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName") = '' Then $i += 1 ContinueLoop EndIf $sDisplayName = StringStripWS(StringReplace(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName"), " (remove only)", ""), 3) $sDisplayVersion = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayVersion"), 3) $sPublisher = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "Publisher"), 3) $sUninstallString = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "UninstallString"), 3) _ArrayAdd($aSoftwareInfo, "|" & $sDisplayName & "|" & $sDisplayVersion & "|" & $sPublisher & "|" & $sUninstallString) $i += 1 WEnd _ArraySort($aSoftwareInfo,0,1) For $i = 0 To UBound($aSoftwareInfo) - 1 $aSoftwareInfo[$i][0] = $i Next EndFunc ; Func _Expand() _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($idListView, 2, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($idListView, 3, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($idListView, 4, $LVSCW_AUTOSIZE) EndFunc
    3 points
  2. On a server? Why are you doing this on a server? Servers aren't supposed to be used to surf the web.
    2 points
  3. water

    Ignoring errors

    If you intend to create reliable scripts you should NEVER ignore ANY error. Catch them, analyze them and then act accordingly. But NEVER ignore anything whithout knowing what you ignore. If you can post some code and explain where your errors occur we might give further advice.
    2 points
  4. RTFC

    Get CPU % with decimal

    @Earthshine: There's actually a C#/.Net AutoIt subforum for your suggestion; I think it's neither apposite nor helpful if your first post in someone's request for Help with AutoIt in the main AutoIt GH & S forum is producing a C# snippet, especially when responding to New Members and obvious beginners, and even more so when native AutoIt solutions are readily available. Thanks.
    1 point
  5. @Earthshine Well we are obviously looking for something which we can easily use in AutoIt code, and it is simpler to add more AutoIt code rather than learning C# and writing your program in it
    1 point
  6. RTFC

    Get CPU % with decimal

    Oh really? kernel32.dll + ntdll.dll + CPU_ProcessorUsage.au3 = 687 Kb + 1909 Kb + 14 Kb = 2,610 Kb .NET = 4.5 GB
    1 point
  7. there are valid reasons to use servers as desktops - bearing in mind that "servers" simply refers to the type of the OS, rather than to the actual usage of the computer running that OS. one such reason (which i encountered personally) is that major cloud service providers (such as Amazon AWS and Microsoft Azure) offer servers as the preferred option, sometimes not offering desktops at all. and since Windows servers are, after all, Windows, they support full desktop capabilities. either way, when working with servers or with dedicated (probably headless) desktops, one encounters the same caveats. @MRAJ, are you actively trying to make us focus on the least important bits of your case? you have provided no indication that you ever tried to run your scripts, to say nothing of the issues you encountered or any troubleshooting efforts. so, what is your problem?
    1 point
  8. look at subz example
    1 point
  9. Trong

    Combine 32 & 64 Reg values

    "HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" AutoItScript List installed programs and system information: #include <GuiListView.au3> Opt("TrayAutoPause", 0) Opt('GUIOnEventMode', 1) Opt('GUICloseOnEsc', 1) ;Opt("MustDeclareVars", 1) ; Global $SoftwList = 'ALL', $iAskSoftName = 0, $sSft[1][0] Global $sGui = GUICreate('Currently Installed Software', 810, 650, -1, -1) Global $sLvw = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600) _ComputerGetSoftware($sSft) For $i = 1 To UBound($sSft) - 1 GUICtrlCreateListViewItem($i & '|' & $sSft[$i][0] & '|' & $sSft[$i][1] & '|' & $sSft[$i][2] & '|' & $sSft[$i][3], $sLvw) Next GUICtrlSendMsg($sLvw, 0x101E, 1, 175) GUICtrlSendMsg($sLvw, 0x101E, 2, 65) GUICtrlSendMsg($sLvw, 0x101E, 3, 150) GUICtrlSendMsg($sLvw, 0x101E, 4, 350) Global $mMen = GUICtrlCreateContextMenu($sLvw) Global $CopI = GUICtrlCreateMenuItem('Uninstall Current Selection', $mMen) GUICtrlSetOnEvent($CopI, '_Uninstall') Global $exp = GUICtrlCreateButton(' Expand ', 720, 615) GUICtrlSetOnEvent($exp, '_Expand') GUISetOnEvent(-3, '_AllExit') GUISetState(@SW_SHOW, $sGui) ; While 1 Sleep(10) WEnd ; Func _AllExit() GUIDelete($sGui) Exit EndFunc ;==>_AllExit ; Func _Uninstall() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1) If $proc[1] == 0 Then Return -1 If $proc[5] Then RunWait($proc[5]) Exit EndFunc ;==>_Uninstall ; Func _Copy2Clip() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1) If $proc[1] == 0 Then Return -1 If $proc[5] Then ClipPut($proc[5]) EndFunc ;==>_Copy2Clip ; ; Author JSThePatriot - Modified June 20, 2010 by ripdad - Modified 2018/29/05 by Dao Van Trong - Trong.LIVE Func _ComputerGetSoftware(ByRef $aSoftwareInfo) Local Const $UnInstKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $i = 1, $Reg, $string, $AppKey ReDim $aSoftwareInfo[1][4] If ($iAskSoftName) Then $SoftwList = InputBox("Which Software", "You are running " & @OSVersion & " " & @OSArch & @CRLF & @CRLF & "Which Software would you like to view?", 'ALL') If @error = 1 Then Exit If $SoftwList = 'ALL' Then For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4] $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1 If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0) Return _ArraySort($aSoftwareInfo, 0, 1) Else For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop Local $Reg = RegRead($UnInstKey & "\" & $AppKey, "DisplayName") $string = StringInStr($Reg, $SoftwList) If $string = 0 Then ContinueLoop ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4] $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1 If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0) Return _ArraySort($aSoftwareInfo, 0, 1) EndIf EndFunc ;==>_ComputerGetSoftware ; Func _Expand() _GUICtrlListView_SetColumnWidth($sLvw, 1, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 2, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 3, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 4, $LVSCW_AUTOSIZE) EndFunc ;==>_Expand
    1 point
  10. #include <Timers.au3> While 1 Sleep(10) $idleTimer = _Timer_GetIdleTime() If $idleTimer > 60000 And Not ProcessExists("process.exe") Then Run("process.exe") ElseIf $idleTimer < 60001 Then Run("otherprocess.exe") Sleep(1000) Exit EndIf WEnd
    1 point
  11. change your function that reads the reg. pass it the key once for 32 bit, once for 64 in main loop Func _ComputerGetSoftware(ByRef $aSoftwareInfo, $UnInstKey) then don;t do this, remark that out. Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" pass that key to your function 2 times, 32 and 64 values and add them to the one array.
    1 point
  12. mLipok

    Ignoring errors

    Func _Example_CatchErrors() While 1 _Function1() If @error Then ContinueLoop While 1 _Function2() If @error Then ContinueLoop ExitLoop Wend Wend EndFunc Func _Example_IngoreErrors() While 1 _Function1() If @error Then ExitLoop While 1 _Function2() If @error Then ExitLoop Wend Wend EndFunc btw. How complicated it is ? check it using: #Au3Stripper_Parameters=/RM /SO /RSLN /PE And check ***_stripped.au3 file how many lines and bytes it contains For example: my biggest project have : 35516 lines and 1 251 423 Bytes
    1 point
  13. Agree with others to correctly handle possible errors. But if you still want your desired way then here is possible way: pseudocode Global $done $done = IniRead('your.ini','Stage','Done') If $done < 1 Then ; ... code part 1 WriteStage(1) EndIf If $done < 2 Then ; ... code part 2 WriteStage(2) EndIf ; ... ; finish WriteStage(0) Exit Func WriteStage($stage) $done = $stage IniWrite('your.ini','Stage','Done',$stage) EndFunc
    1 point
  14. The numbers are actually OS Language Codes (see https://www.autoitscript.com/autoit3/docs/appendix/OSLangCodes.htm), but since you don't need them you can remove them. With regards to Arrays you can use Ubound for this couple of examples: One Dimensional Arrays nb: Arrays are 0 Index based Local $OneDimension[2] $OneDimension[0] = "Row One - One Column" $OneDimension[1] = "Row Two - One Column" Using the example above you can use Ubound($OneDimension) to get the total number of rows, in this example 2 ConsoleWrite("Total Number of Rows: " & Ubound($OneDimension) & @CRLF) If you were going to use this within a For Loop you could use something like Ubound($OneDimension) - 1 to get the last row index For $i = 0 To Ubound($OneDimension) - 1 ConsoleWrite("Row " & $i & " = " & $OneDimension[$i] & @CRLF) Next Two Dimensional Arrays nb: Arrays are 0 Index based Local $TwoDimension[2][2] $TwoDimension[0][0] = "Row One - Column One" $TwoDimension[0][1] = "Row One - Column Two" $TwoDimension[1][0] = "Row Two Column One" $TwoDimension[1][1] = "Row Two Column Two" Using the example above you can use Ubound($OneDimension) to get the total number of rows, in this example 2 Using the example above you can use Ubound($OneDimension, 2) to get the total number of columns, in this example 2 ConsoleWrite("Total Number of Rows: " & Ubound($TwoDimension) & @CRLF) ConsoleWrite("Total Number of Columns: " & Ubound($TwoDimension, 2) & @CRLF) If you were going to use this within a For Loop you could use something like Ubound($OneDimension) - 1 to get the last row index If you were going to use this within a For Loop you could use something like Ubound($OneDimension, 2) - 1 to get the last column index For $i = 0 To Ubound($TwoDimension) - 1 For $j = 0 To UBound($TwoDimension, 2) - 1 ConsoleWrite("Row " & $i & ": " & "Column " & $j & " = " & $TwoDimension[$i][$j] & @CRLF) Next Next Anyway I hope that makes sense, really its just remembering that Arrays are 0 based so as you will notice with the last example it will read: Row 0: Column 0 = Row One - Column One Row 0: Column 1 = Row One - Column Two Row 1: Column 0 = Row Two Column One Row 1: Column 1 = Row Two Column Two
    1 point
  15. You have to specify on which range you intend to work. Example: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) _Excel_RangeWrite($oWorkbook, 1, "Test", "A1:G1") _Excel_RangeCopypaste($oWorkbook.Sheets(1), $oWorkbook.Sheets(1).Range("A1").entirerow, $oWorkbook.Sheets(1).Range("A2"))
    1 point
  16. Lessons learned is: Always check for errors and verify the return value is what you expect it to be
    1 point
  17. According to the help file @extended gets set to the number of bytes read. _AD_SamAccountNameToFQDN: 1/0 means: No record returned from Active Directory. $sSamAccountName not found It seems the file holds more than just the username. Can you write $user to the console like this: ConsoleWrite(">>" & $user & "<<" & @CRLF) Is the result what you expect it to be?
    1 point
  18. IIRC you need to have at least a post count of 5 before you can edit your posts
    1 point
  19. I suggest to add a line to check for errors after each function call. Example: ConsoleWrite("_AD_SamAccountNameToFQDN: " & @error & "/" & @extended & @CRLF) The same is true for the FileRead.
    1 point
  20. Here is an alternative method based upon the @OSLang Macro (Used Chimps Example Gui) #include <Array.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $sLanguageDefault = "" Global $aLanguageSelect[1][3] _Example() Func _Example() _GetLanguages() _ArrayDisplay($aLanguageSelect) ; -------- GUI Zone ------- ; Create a GUI with controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 185, 20) Local $idCloseGui = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Add items to the combobox. ; Items are Language names peeked from the column[3] of the $aData array GUICtrlSetData($idComboBox, _ArrayToString($aLanguageSelect, "", 1, -1, "|", 1, 1), $sLanguageDefault) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $sComboRead = "" ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idCloseGui ExitLoop Case $idComboBox $sComboRead = GUICtrlRead($idComboBox) MsgBox($MB_SYSTEMMODAL, "", "You selected: " & $sComboRead, 0, $hGUI) $sLanguageDefault = $aLanguageSelect[_ArraySearch($aLanguageSelect, $sComboRead, 0, 0, 0, 0, 1, 1)][1] MsgBox($MB_SYSTEMMODAL, "", "The $Var variable has been setted" & @CRLF & "$Var contains --> " & $sLanguageDefault) EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example Func _GetLanguages() Local $aLanguageList[17][3] = [[16, "", ""], _ ;~ Language Count ["AR", "Arabic", "0401;0801;0C01;1001;1401;1801;1C01;2001;2401;2801;2C01;3001;3401;3801;3C01;4001"], _ ["CZ", "Czech", "0405"], _ ["DE", "German", "0407;0807;0C07;1007;1407"], _ ["EN", "English", "0409;0809;0C09;1009;1409;1809;1c09;2009;2409;2809;2C09;3009;3409;4009;4409;4809"], _ ["ES", "Spanish", "040A;0C0A"], _ ["ESMX", "Spanish(Mexico)", "080A"], _ ["FR", "French", "040C;080C;0C0C;100C;140C;180C"], _ ["HU", "Hungarian", "040E"], _ ["IT", "Italian", "0410;0810"], _ ["JP", "Japanese", "0411"], _ ["KR", "Korean", "0412"], _ ["PL", "Polish", "0415"], _ ["PR", "Portuguese", "0816"], _ ["PRBR", "Portuguese(Brazil)", "0416"], _ ["RU", "Russian", "0419"], _ ["ZH", "Chinese", "0004;0404;0804;0C04;1004;1404;7C04"]] Local $aIniFileList = _FileListToArray(@ScriptDir & "\Common\Settings", "Data*.ini", 1, True) For $i = 1 To $aIniFileList[0] For $j = $aLanguageList[0][0] To 1 Step - 1 If IniRead($aIniFileList[$i], "LangInclude", "Include" & $aLanguageList[$j][0], "") <> "" Then If StringInStr($aLanguageList[$j][2], @OSLang) Then $sLanguageDefault = $aLanguageList[$j][1] ;~ OS Default Language _ArrayAdd($aLanguageSelect, $aLanguageList[$j][0] & "|" & $aLanguageList[$j][1] & "|" & $aLanguageList[$j][2]) ContinueLoop EndIf If IniRead($aIniFileList[$i], "LangExclude", "Exclude" & $aLanguageList[$j][0], "") <> "" Then If StringInStr($aLanguageList[$j][2], @OSLang) Then $sLanguageDefault = $aLanguageList[$j][1] ;~ OS Default Language _ArrayAdd($aLanguageSelect, $aLanguageList[$j][0] & "|" & $aLanguageList[$j][1] & "|" & $aLanguageList[$j][2]) EndIf Next Next $aLanguageSelect[0][0] = UBound($aLanguageSelect) - 1 _ArraySort($aLanguageSelect, 0, 1) EndFunc
    1 point
  21. Couldn't such a simple workaround be used ? $var = "_26" ; $sHTML = '<input name="in2xk_92" class="navitem s_147" id="in2xk_26" style="..." etc>' $sHTML = _IEDocReadHTML($oIE) $id = StringRegExpReplace($sHTML, '(?s).*?id="(\w+' & $var & ').*', "$1") ; Msgbox(0,"", $id) $oInput = _IEGetObjById($oIE, $id) ; etc
    1 point
  22. $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $tab Switch GUICtrlRead($tab) Case 1 ControlFocus($hWnd, "", "Edit2") Case 1 ControlFocus($hWnd, "", "Edit1") EndSwitch
    1 point
  23. StungStang

    Obfuscate .exe

    @guinness I try to add that : #AutoIt3Wrapper_Run_Obfuscator=Y #Obfuscator_Parameters=/SF /SV /OM /CS=0 /CN=0 But with the decompiler i have grabbed the source. @Jos Is there no way to make it difficult to extract the source? @Melba23 I don't know if was my fault but with my decompiler i can just simple know the source code from an .exe, in ~ 1 minutes. If you have to crypt a text, with for example _StringEncrypt how you can't inserct the password in the source? Hi!
    1 point
  24. In recent betas, there is a new HWnd statement that converts a variant into an HWnd. I did a quick test and I think you should be able to convert your HWND to a string, store it in the registry or where ever, read it back and convert it back into an HWND. If you original HWND value is stored in $hHwnd, then in the code below, $hHwnd and $hHwnd2 should be identical: $sHwnd = String($hHwnd) $hHwnd2 = HWnd($sHwnd) Dale
    1 point
  25. 0 points
×
×
  • Create New...