Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/08/2016 in all areas

  1. Version 1.6.3.0

    17,749 downloads

    Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    1 point
  2. Danyfirex

    HotKeySet help [SOLVED]

    check GUISetAccelerators in help file. Saludos
    1 point
  3. abdulrahmanok, As j0kky said, this will keep you in the messageloop... #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <File.au3> Local $hGui = GUICreate("Example") $ListviewBannerDate = GUICtrlCreateListView("My Banner Dates", 200, 150, 160, 150, -1) ; dummy control actioned by notify routine when user clicks on control $dummy_lv = GUICtrlCreateDummy() GUISetState(@SW_SHOW) ; routine to recieve notification messages from listview GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Local $sFilePath = @ScriptDir & "\test.txt" ; Read the current script file into an array using the filepath. Local $aDate = FileReadToArray($sFilePath) If @error Then MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. Else For $i = 0 To UBound($aDate) - 1 ; Loop through the array. $iString = StringInStr($aDate[$i], "OPTION VALUE") $sMyString = StringMid($aDate[$i], 16, 9) If $iString > 1 Then GUICtrlCreateListViewItem($sMyString, $ListviewBannerDate) Else ContinueLoop EndIf Next EndIf Local $msg While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $dummy_lv ; ; this is where you would do your search and replace routine $aResult = _LineNumsOfSearchStr($sFilePath, _GUICtrlListView_GetItemTextString($ListviewBannerDate, -1), False) _ArrayDisplay($aResult) ; ; EndSwitch WEnd ;Local $sFileName = "test.txt" ; <<<---- already declared in $sFilePath ;Local $searchStr = $asd ;$aResult = _LineNumsOfSearchStr($sFileName, $searchStr, False) <<--------- put inside msgloop ;_ArrayDisplay($aResult) ; Returns array of found line numbers that contain $searchStr contents. ; Optional delete found line from file. Func _LineNumsOfSearchStr($sFileName, $searchString, $bDeleteLine = False) Local $location, $aCurrentLineNum, $iCurrentLineNum, $sFile, $iOccur = 1, $sRes = "" If FileExists($sFilePath) = 0 Then Return 1 Do $sFile = FileRead($sFilePath) $location = StringInStr($sFile, $searchString, 0, $iOccur) ; Find the $iOccur occurrence of the "substring" If $location > 0 Then $aCurrentLineNum = StringRegExp(StringRegExpReplace($sFile, "(?s)(.{" & $location & "})(.*)$", "\1"), "(?s)(\v+)", 3) ;Find line number $iCurrentLineNum = UBound($aCurrentLineNum) + 1 ; Line number MsgBox(0,"",$searchString) MsgBox(0,"",$iCurrentLineNum) _FileWriteToLine(@ScriptDir&"\test.txt", $iCurrentLineNum+1, "my replacement for line 3", 1) ;ConsoleWrite("CharPos: " & $location & " Ln: " & $iCurrentLineNum & @CRLF) $sRes &= $iCurrentLineNum & "|" If $bDeleteLine Then _FileWriteToLine($sFileName, $iCurrentLineNum, "", 1) ; Remove found line from file. Else $iOccur += 1 EndIf Else ExitLoop EndIf Sleep(10) Until 0 ;ShellExecute($sFileName) Return StringSplit(StringTrimRight($sRes, 1), "|") EndFunc ;==>_LineNumsOfSearchStr Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Switch $tNMHDR.IDFrom Case $ListviewBannerDate Switch $tNMHDR.Code Case $nm_click GUICtrlSendToDummy($dummy_lv) ; action dummy control in the message loop EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY However, I think there are problems with how you are managing "test.txt". And, you will want to maintain the listview in sync with that file (delete corresponding listview entry to test.txt entry). kylomas Edit: I would strongly advise you to review the help file and wiki doc for message mode processing.
    1 point
  4. It is because _LineNumsOfSearchStr is executed only after you exit from the main loop through the command ExitLoop...
    1 point
  5. For $i = 1 To ... For $i = 1 To ... Next Next Your nested for loop is reusing $i, rename to $j or some other arbitrary letter.
    1 point
  6. Unfortunately, I don't think that there is some truth . His question clearly states that, he has a batch file with an environment variable which is getting appended with some file path. And he wants to do it with Autoit. Per my knowledge, envget will not do this.
    1 point
  7. JLogan3o13

    Enumeration

    @iamtheky you deserve remuneration for that enumeration elucidation
    1 point
  8. Tec

    Joining domain...

    This works for me. Const $JOIN_DOMAIN = 1 Const $ACCT_CREATE = 2 Const $ACCT_DELETE = 4 Const $WIN9X_UPGRADE = 16 Const $DOMAIN_JOIN_IF_JOINED = 32 Const $JOIN_UNSECURE = 64 Const $MACHINE_PASSWORD_PASSED = 128 Const $DEFERRED_SPN_SET = 256 Const $INSTALL_INVOCATION = 262144 Const $DOMAIN = "'DOMAIN.LOCAL" ;change Domain Const $ADMINKENNWORT = "ADMINPASSWORD" ;change PW Const $ADMIN = "Administrator" Const $COMPUTER = @ComputerName $objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & $COMPUTER & "\root\cimv2:Win32_ComputerSystem.Name='" & $COMPUTER & "'") $Ergebnis = $objComputer.JoinDomainOrWorkGroup($DOMAIN, $ADMINKENNWORT, $DOMAIN & "\" & $ADMIN, "", $JOIN_DOMAIN + $ACCT_CREATE) If ($Ergebnis <> 0) Then MsgBox(0, "Fehler beim beitritt in die Domain", $COMPUTER & " Fehler code: " & $Ergebnis ) EndIf
    1 point
×
×
  • Create New...