Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/14/2020 in all areas

  1. ptrex

    Real-Time log file viewer

    @jguinch Oh yes I forget it is an autoit forum. Here you go šŸ˜‰ #AutoIt3Wrapper_UseX64=y #include <MsgBoxConstants.au3> #include "C:\CLR.au3" #include <Clipboard.au3> Local $PS_Script = " " _Run_PSHost_Script('Get-content "C:\pfirewall.log" -Tail 10', 1) Func _Run_PSHost_Script($PSScript, $iOutput = 0) Local $oAssembly = _CLR_LoadLibrary("System.Management.Automation") ConsoleWrite("!$oAssembly: " & IsObj($oAssembly) & @CRLF) ; Get Type Local $pAssemblyType = 0 $oAssembly.GetType_2("System.Management.Automation.PowerShell", $pAssemblyType) ConsoleWrite("$pAssemblyType = " & Ptr($pAssemblyType) & @CRLF) Local $oActivatorType = ObjCreateInterface($pAssemblyType, $sIID_IType, $sTag_IType) ConsoleWrite("IsObj( $oAssemblyType ) = " & IsObj($oActivatorType) & @TAB & @CRLF) ; Create Object Local $pObjectPS = 0 $oActivatorType.InvokeMember_3("Create",0x158, 0, 0, 0, $pObjectPS) ConsoleWrite("IsObject: " & IsObj($pObjectPS) & @TAB & "$pObject: " & ObjName($pObjectPS) & @CRLF) ; ------------- CONSOLE --------------- Local $oAssembly1 = _CLR_LoadLibrary("mscorlib") ConsoleWrite("!$oAssembly: " & IsObj($oAssembly1) & @CRLF) ; Get Type Local $pAssemblyType1 = 0 $oAssembly1.GetType_2("System.Console", $pAssemblyType1) ConsoleWrite("$oAssembly1 = " & Ptr($oAssembly1) & @CRLF) Local $oActivatorType1 = ObjCreateInterface($pAssemblyType1, $sIID_IType, $sTag_IType) ConsoleWrite("IsObj( $oActivatorType1 ) = " & IsObj($oActivatorType1) & @TAB & @CRLF) ; Create Object Local $pObjectPS1 = 0 Local $sText[] = [@CRLF & "AutoIT Rocks !!" & @CRLF & @CRLF] $oActivatorType1.InvokeMember_3("Write", 0x158, 0, 0, CreateSafeArray($sText), $pObjectPS1) ;~ ConsoleWrite("$pObjectPS1: " & IsObj($pObjectPS1) & @TAB & "$pObjectPS1: " & ObjName($pObjectPS1) & @CRLF) ; <<<<<<<<<<<<<<<<<<< PS COMMAND HERE >>>>>>>>>>>>>>>>>>>> $pObjectPS.AddScript($PSScript) ; Add Script here ; <<<<<<<<<<<<<<<<<<< Output >>>>>>>>>>>>>>>>>>>> Switch $iOutput Case 0 $pObjectPS.AddCommand("Clip") Case 1 $pObjectPS.AddCommand("Out-GridView") Case 2 $pObjectPS.AddCommand("Out-Printer") Case 3 $pObjectPS.AddCommand("Out-File") $sFile = @DesktopDir & "\PShost.txt" ConsoleWrite("> " & $sFile & @CRLF) $pObjectPS.AddArgument($sFile) Case 4 $pObjectPS.AddCommand("Out-Null") Case Else MsgBox(0,"PSHost","Wrong Output Choice ?") EndSwitch $objAsync = $pObjectPS.BeginInvoke() ConsoleWrite("$objAsync " & IsObj($objAsync & @TAB & "$pObject: " & ObjName($objAsync) ) & @CRLF) While $objAsync.IsCompleted = False ContinueLoop WEnd ConsoleWrite("Completed : " & $objAsync.IsCompleted & @CRLF) $objPsCollection = $pObjectPS.EndInvoke($objAsync) ;============================================================ Switch $iOutput Case 0 MsgBox(0,"PSHost",_ClipBoard_GetData()) ClipPut("") _ClipBoard_Close() Case 1 WinWaitClose("") Case 3 MsgBox(0,"PSHost","File Output Ready on Desktop.") EndSwitch EndFunc Enjoy !!
    3 points
  2. water

    AD - Active Directory UDF

    Version 1.6.3.0

    17,299 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
  3. Version 4.0.0-beta

    1,006 downloads

    Version 2.x.x and 3.x.x has been moved to branch 3.x About Autoit-Socket-IO Autoit-Socket-IO is a event driven TCP/IP wrapper heavily inspired from Socket.IO with focus on user friendliness and long term sustainability. I constantly want to make this UDF faster and better, so if you have any suggestions or questions (beginner and advanced) Do not hesitate to ask them, I will gladly help! Key features Simple API 99% data-type serialization thanks to Autoit-Serialize Can easily be extended with your own functionality thanks to Autoit-Events "Educational" examples Data encryption thanks to _<Crypt.au3> Limitations Speed. This UDF will sacrifice some speed for convenience Read more in the official thread
    1 point
  4. Yup, but I'm not feeling motivated to make a script for you. If you want help, we're (often) happy to do that out of the kindness of our hearts if you put forth a little effort
    1 point
  5. As I'm sure that you already know, Github API requests using BASIC authentication is deprecated. The preferred method is to use OAUTH or personal tokens. When you use personal tokens as authentication, you pass the token in the "Authorization" request header, not as a BASIC authentication password for your username. The example script that I have created below works for me. Make sure that you check and modify all of the lines that are marked "Modify as needed". The example token that I used in the script is NOT a valid token. So if you use it, you will generate the following error in the console: "HTTP Status Code = 401 Unauthorized". Make sure to use a personal token that has been granted access to the required API endpoints. #include <Constants.au3> #include <MyIncludes\WinHttp\WinHttp.au3> ;Modify as needed #include <MyIncludes\WinHttpRequestConstants.au3> ;Modify as needed #include <MyIncludes\json\json.au3> ;Modify as needed github_notifications_request() Func github_notifications_request() Local $hSession = -1, $hConnection = -1, $hRequest = -1 Local $oJson = Null Local $sResponse = "", $sStatusCode = "", $sStatusText = "" ;Establish WinHTTP session handle $hSession = _WinHttpOpen() If @error Then Exit MsgBox($MB_TOPMOST + $MB_ICONERROR, "ERROR", "_WinHttpOpen failed - @error = " & @error) ;Establish WinHTTP connection handle $hConnection = _WinHttpConnect($hSession, "https://api.github.com") If @error Then Exit MsgBox($MB_TOPMOST + $MB_ICONERROR, "ERROR", "_WinHttpConnect failed - @error = " & @error) ;Establish WinHTTP requests handle $hRequest = _WinHttpOpenRequest($hConnection, _ "GET", _ "/notifications", _ Default, Default, Default, _ BitOR($WINHTTP_FLAG_SECURE, $WINHTTP_FLAG_ESCAPE_DISABLE)) If @error Then Exit MsgBox($MB_TOPMOST + $MB_ICONERROR, "ERROR", "_WinHttpOpenRequest failed - @error = " & @error) ;Set request headers _WinHttpAddRequestHeaders($hRequest, "Accept: application/vnd.github.v3+json") _WinHttpAddRequestHeaders($hRequest, "Authorization: Token 159bc76fd252a4c1f02e9f7f940fef0000000000") ;Modify as needed ;Send request and wait for the response _WinHttpSendRequest($hRequest) If @error Then Exit MsgBox($MB_TOPMOST + $MB_ICONERROR, "ERROR", "_WinHttpSendRequest failed - @error = " & @error) _WinHttpReceiveResponse($hRequest) If @error Then Exit MsgBox($MB_TOPMOST + $MB_ICONERROR, "ERROR", "_WinHttpReceiveResponse - @error = " & @error) ;Get response status code and status text $sStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE) $sStatusText = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_TEXT) ;If good status code If $sStatusCode = "200" Then ;Get response $sResponse = _WinHttpReadData($hRequest) ;Format JSON response $oJson = Json_Decode($sResponse, 2000) ;Convert JSON string to object $sResponse = Json_Encode($oJson, $JSON_PRETTY_PRINT) ;Pretty print json object ConsoleWrite("-> API Response:" & @CRLF & $sResponse & @CRLF) Else ConsoleWrite(StringFormat("-> HTTP Status Code = %s %s", $sStatusCode, $sStatusText) & @CRLF) EndIf _WInHttpCloseHandle($hRequest) _WInHttpCloseHandle($hConnection) _WInHttpCloseHandle($hSession) EndFunc
    1 point
  6. This is actually exactly what I expected so you understand why I was wondering why you need to ask this in the first place. Jos
    1 point
  7. indeed the fast and easy way is to use PS You can use the WAIT parameter to only show the new lines added to the log file for montoring If you want the Gui version of FileOpenDialogue CLS [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null $dlg = New-Object System.Windows.Forms.OpenFileDialog $dlg.initialDirectory = """ + initialDir + """ $dlg.filter = "ZIP files|*.zip|Text Documents|*.txt|Shell Scripts|*.*sh|All Files|*.*" $dlg.FilterIndex = 4 $dlg.Title = 'Select a file to upload' $dlg.ShowHelp = $True $dlg.ShowDialog() | Out-Null $dlg.FileName Get-content $dlg.FileName -Tail 10 Enjoy !
    1 point
  8. Dan_555

    Dan's misc. Scripts

    Right, thanks, i didn't know that it existed. I made the custom sleep function, because the tray menu may react very slowly, when using the real sleep function.
    1 point
  9. TheDcoder

    Dan's misc. Scripts

    Slight nitpick, you can use TrayOnEvent instead of making your own Sleep function which checks for tray messages
    1 point
  10. Nice to see you find SQLite a good basis for solving your problem. Chime again as needed.
    1 point
  11. though you should get about 2 minutes of relief a day from the loud fan noise, if Iā€™m reading the script right
    1 point
  12. Your While loop is eating too many CPU cycles. Add a Sleep just before the WEnd and all should be good.
    1 point
×
×
  • Create New...