Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/23/2015 in all areas

  1. Just a quick one, how you can add AutoIt support in Visual Studio Code. Download Visual Studio CodeDownload https://github.com/backr/Visual-Studio-Code-AutoItPut the "autoit" folder in UserName\.vscode\extensions\Restart Visual Studio CodeNow AutoIt is configured automatically for all available Visual Studio Themes:
    1 point
  2. czardas, I have seen your edit and it has persuaded me that you are correct. I shall look at how best to implement this. M23
    1 point
  3. Melba23

    Need a script made

    OLivay, Welcome to the AutoIt forums. Here are a few hints to get your fishing trip underway: ;--------------------------- >Esc should terminate it - HotKeySet & Exit >Once F1 is pressed record PosA: current mouse's X and Y position - HotKeySet & MouseGetPos >Once F2 is pressed record PosB: current mouse's X and Y position - HotKeySet & MouseGetPos >Capture the pixel color in PosA - PixelGetColor >Keep waiting for the PosA pixel color to change - PixelgetColor & Do...Until >If pixel color in PosA changes: - If...Then >>move mouse to PosB - MouseMove >>Wait between 1 second and 2 seconds (random) - Sleep & Random >>click once - MouseClick >terminate - Exit ;--------------------------- Now read the Help file for those functions and see what you can code yourself (even if it does not work correctly). You will find that you will get lots if help if you show you are making some effort. And please do read the Forum rules - we do enforce them rigourously M23
    1 point
  4. STaufa

    PDF password protect

    Thank you for the help. I've managed to do it in C#, I just had to include PDFSharp library http://pdfsharp.com/PDFsharp/ Here's what I did (It worked perfectly) static void Main(string[] args) { FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\documents\"; watcher.Filter = "*.pdf"; watcher.IncludeSubdirectories = true; watcher.Created += new FileSystemEventHandler(fw_Created); watcher.EnableRaisingEvents = true; System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); } static void fw_Created(object sender, FileSystemEventArgs e) { string path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\documents"; PdfDocument document = PdfReader.Open(path + "\\" + e.Name, ""); PdfSecuritySettings securitySettings = document.SecuritySettings; // Setting one of the passwords automatically sets the security level to // PdfDocumentSecurityLevel.Encrypted128Bit. //securitySettings.UserPassword = "yourUserPassword"; securitySettings.OwnerPassword = "yourOwnerPassword"; // Don't use 40 bit encryption unless needed for compatibility reasons //securitySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted40Bit; // Restrict some rights. securitySettings.PermitAccessibilityExtractContent = false; securitySettings.PermitAnnotations = false; securitySettings.PermitAssembleDocument = false; securitySettings.PermitExtractContent = false; securitySettings.PermitFormsFill = false; securitySettings.PermitFullQualityPrint = false; securitySettings.PermitModifyDocument = false; securitySettings.PermitPrint = false; // Save the document... document.Save(path + "\\" + e.Name); }
    1 point
  5. To repair this you will need to edit the registry so clicking on Start and then Run is necessary. Then, enter regedit in the Open box and click OK. Next, navigate to the registry key: HKEY_CURRENT_USERSoftwareMicrosoftOffice14.0OutlookRPC On the Edit menu, point to New, and then click DWORD Value. Type DefConnectOpts, and then press ENTER. Now, right-click DefConnectOpts, and then click Modify. In the Value data box, type 0, and then click OK. . If you are still experiencing the issue I can suggest this program Exchange Server Repair Toolbox This error occurs when Outlook is unsure of the default gateway address. The former is the error message that shows when the Outlook profile is configured automatically and the latter appears when the profile is manually configured. Both have the same fix. To repair this you will need to edit the registry so clicking on Start and then Run is necessary. Then, enter regedit in the Open box and click OK. Next, navigate to the registry key: HKEY_CURRENT_USERSoftwareMicrosoftOffice14.0OutlookRPC On the Edit menu, point to New, and then click DWORD Value. Type DefConnectOpts, and then press ENTER. Now, right-click DefConnectOpts, and then click Modify. In the Value data box, type 0, and then click OK. See more: https://social.technet.microsoft.com/Forums/office/en-US/bd28d11c-e9c1-4a4c-8268-ba482c693601/my-edb-file-corrupted-in-exchange-server?forum=exchangesvrclients
    1 point
  6. I'll look at this more later, but I can tell you that running separate loops like you posted in your example should behave no different than the While loop I posted so the issue that is happening must have something to do with your code. If you really want to do this in a professional manner you should look at the IUIAutomation thread where you can click/full screen without using MouseClick() so that it will always work no matter the resolution, and I think FireFox UDF has methods to detect when a page has loaded so you can get rid of the excessive Sleep() you have for page loading.
    1 point
  7. Welcome to AutoIt and the forum! What do you mean by "open the Microsoft Exchange Server"? Do you want to connect to the Exchange Server using Outlook?
    1 point
  8. Thanks Manadar for your replay well, here a very primitive attempt (primitive but at least it works) to achieve the purpose (just a proof of concept). in short: added a new "Case" to the Switch $sFileType to catch .ha3 filetypes added _parseSource() at bottom added _ExecuteScript() at bottom For who wants to try: Save the modified server script and the 2 "web pages" in the same directory, run the server open a web browser and enter as address the IP of the machine where the server is running (a very basic page will open) click on the only link and a second page with embedded Autoit code will be parsed on the server and opened on the client. modified Basic_Server save it as Server.au3 #cs Resources: Internet Assigned Number Authority - all Content-Types: http://www.iana.org/assignments/media-types/ World Wide Web Consortium - An overview of the HTTP protocol: http://www.w3.org/Protocols/ Credits: Manadar for starting on the webserver. Alek for adding POST and some fixes Creator for providing the "application/octet-stream" MIME type. #ce ; // OPTIONS HERE // Local $sRootDir = @ScriptDir ; & "\www" ; The absolute path to the root directory of the server. Local $sIP = @IPAddress1 ; ip address as defined by AutoIt Local $iPort = 80 ; the listening port Local $sServerAddress = "http://" & $sIP & ":" & $iPort & "/" Local $iMaxUsers = 15 ; Maximum number of users who can simultaneously get/post Local $sServerName = "ManadarX/1.1 (" & @OSVersion & ") AutoIt " & @AutoItVersion ; // END OF OPTIONS // Local $aSocket[$iMaxUsers] ; Creates an array to store all the possible users Local $sBuffer[$iMaxUsers] ; All these users have buffers when sending/receiving, so we need a place to store those For $x = 0 To UBound($aSocket) - 1 ; Fills the entire socket array with -1 integers, so that the server knows they are empty. $aSocket[$x] = -1 Next TCPStartup() ; AutoIt needs to initialize the TCP functions $iMainSocket = TCPListen($sIP, $iPort) ;create main listening socket If @error Then ; if you fail creating a socket, exit the application MsgBox(0x20, "AutoIt Webserver", "Unable to create a socket on port " & $iPort & ".") ; notifies the user that the HTTP server will not run Exit ; if your server is part of a GUI that has nothing to do with the server, you'll need to remove the Exit keyword and notify the user that the HTTP server will not work. EndIf ConsoleWrite("Server created on " & $sServerAddress & @CRLF) ; If you're in SciTE, While 1 $iNewSocket = TCPAccept($iMainSocket) ; Tries to accept incoming connections If $iNewSocket >= 0 Then ; Verifies that there actually is an incoming connection For $x = 0 To UBound($aSocket) - 1 ; Attempts to store the incoming connection If $aSocket[$x] = -1 Then $aSocket[$x] = $iNewSocket ;store the new socket ExitLoop EndIf Next EndIf For $x = 0 To UBound($aSocket) - 1 ; A big loop to receive data from everyone connected If $aSocket[$x] = -1 Then ContinueLoop ; if the socket is empty, it will continue to the next iteration, doing nothing $sNewData = TCPRecv($aSocket[$x], 1024) ; Receives a whole lot of data if possible If @error Then ; Client has disconnected $aSocket[$x] = -1 ; Socket is freed so that a new user may join ContinueLoop ; Go to the next iteration of the loop, not really needed but looks oh so good ElseIf $sNewData Then ; data received $sBuffer[$x] &= $sNewData ;store it in the buffer If StringInStr(StringStripCR($sBuffer[$x]), @LF & @LF) Then ; if the request has ended .. $sFirstLine = StringLeft($sBuffer[$x], StringInStr($sBuffer[$x], @LF)) ; helps to get the type of the request $sRequestType = StringLeft($sFirstLine, StringInStr($sFirstLine, " ") - 1) ; gets the type of the request If $sRequestType = "GET" Then ; user wants to download a file or whatever .. $sRequest = StringTrimRight(StringTrimLeft($sFirstLine, 4), 11) ; let's see what file he actually wants If StringInStr(StringReplace($sRequest, "\", "/"), "/.") Then ; Disallow any attempts to go back a folder ;;~ _HTTP_SendError($aSocket[$x]) ; sends back an error _HTTP_SendFileNotFoundError($aSocket[$x]) ; sends back an error Else If $sRequest = "/" Then ; user has requested the root $sRequest = "/index.html" ; instead of root we'll give him the index page EndIf $sRequest = StringReplace($sRequest, "/", "\") ; convert HTTP slashes to windows slashes, not really required because windows accepts both If FileExists($sRootDir & "\" & $sRequest) Then ; makes sure the file that the user wants exists $sFileType = StringRight($sRequest, 4) ; determines the file type, so that we may choose what mine type to use Switch $sFileType ; -- just a pre alpha "proof of concept" ----------------------------------------- Case ".ha3" ; just for example extension .ha3 could be used -> (h)tml (a)utoit(3) $hFile = FileOpen($sRootDir & "\" & $sRequest);, 16) ; read file of web page $bFileData = FileRead($hFile) FileClose($hFile) ; now use _parseSource() to extract and execute embedded AutoIt code ; and then send result to client's browser _HTTP_SendData($aSocket[$x], _parseSource($bFileData), "text/html") ; ---------------------------------------------------------------------------- Case "html", ".htm" ; in case of normal HTML files _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/html") Case ".css" ; in case of style sheets _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/css") Case ".jpg", "jpeg" ; for common images _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/jpeg") Case ".png" ; another common image format _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/png") Case Else ; this is for .exe, .zip, or anything else that is not supported is downloaded to the client using a application/octet-stream _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "application/octet-stream") EndSwitch Else _HTTP_SendFileNotFoundError($aSocket[$x]) ; File does not exist, so we'll send back an error.. EndIf EndIf EndIf $sBuffer[$x] = "" ; clears the buffer because we just used to buffer and did some actions based on them $aSocket[$x] = -1 ; the socket is automatically closed so we reset the socket so that we may accept new clients EndIf EndIf Next Sleep(10) WEnd Func _HTTP_ConvertString(ByRef $sInput) ; converts any characters like %20 into space 8) $sInput = StringReplace($sInput, '+', ' ') StringReplace($sInput, '%', '') For $t = 0 To @extended $Find_Char = StringLeft(StringTrimLeft($sInput, StringInStr($sInput, '%')), 2) $sInput = StringReplace($sInput, '%' & $Find_Char, Chr(Dec($Find_Char))) Next EndFunc ;==>_HTTP_ConvertString Func _HTTP_SendHTML($hSocket, $sHTML, $sReply = "200 OK") ; sends HTML data on X socket _HTTP_SendData($hSocket, Binary($sHTML), "text/html", $sReply) EndFunc ;==>_HTTP_SendHTML Func _HTTP_SendFile($hSocket, $sFileLoc, $sMimeType, $sReply = "200 OK") ; Sends a file back to the client on X socket, with X mime-type Local $hFile, $sImgBuffer, $sPacket, $a ConsoleWrite("Sending " & $sFileLoc & @CRLF) $hFile = FileOpen($sFileLoc, 16) $bFileData = FileRead($hFile) FileClose($hFile) _HTTP_SendData($hSocket, $bFileData, $sMimeType, $sReply) EndFunc ;==>_HTTP_SendFile Func _HTTP_SendData($hSocket, $bData, $sMimeType, $sReply = "200 OK") $sPacket = Binary("HTTP/1.1 " & $sReply & @CRLF & _ "Server: " & $sServerName & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Lenght: " & BinaryLen($bData) & @CRLF & _ "Content-Type: " & $sMimeType & @CRLF & _ @CRLF) TCPSend($hSocket, $sPacket) ; Send start of packet While BinaryLen($bData) ; Send data in chunks (most code by Larry) $a = TCPSend($hSocket, $bData) ; TCPSend returns the number of bytes sent $bData = BinaryMid($bData, $a + 1, BinaryLen($bData) - $a) WEnd $sPacket = Binary(@CRLF & @CRLF) ; Finish the packet TCPSend($hSocket, $sPacket) TCPCloseSocket($hSocket) EndFunc ;==>_HTTP_SendData Func _HTTP_SendFileNotFoundError($hSocket) ; Sends back a basic 404 error Local $s404Loc = $sRootDir & "\404.html" If (FileExists($s404Loc)) Then _HTTP_SendFile($hSocket, $s404Loc, "text/html") Else _HTTP_SendHTML($hSocket, "404 Error: " & @CRLF & @CRLF & "The file you requested could not be found.") EndIf EndFunc ;==>_HTTP_SendFileNotFoundError ; --- new pre alpha test functions --------------- ; ; following function grabbed from AuCGI.au3 ; from here: http://www.autoitscript.com/forum/topic/111133-autoit-cgi-handler-aucgi/ ; by Erik Pilsits (wraithdu), and Josh Rowe (JRowe) ; original author Matt Roth (theguy0000) <theguy0000@gmail.com> ; (slightly modified by me) ; ; parse source for <?au3 ?> code Func _parseSource($source) Local $idx = 1, $idx2, $lastidx = 1, $parsed = "", $chunk = "" Do ; get first code snippet $idx = StringInStr($source, "<?au3", 0, 1, $idx) ; position of "<?au3" in $idx If $idx Then If $idx > $lastidx Then ; we have html $chunk = StringMid($source, $lastidx, $idx - $lastidx) ; get it (get html) $parsed &= $chunk ;~ _splitHTML($chunk) ; write it to $parsed EndIf $idx += 5 ; start of code ; get end of code tag $idx2 = StringInStr($source, "?>", 0, 1, $idx) If $idx2 Then ; found end of code --------------------------------------------------------------+ $chunk = StringMid($source, $idx, $idx2 - $idx) ; get it (portion of AutoIt code) | ; --- execute autoit code and get back result --- | $chunk = _ExecuteScript($chunk) ; | $parsed &= $chunk & @CRLF ; | $lastidx = $idx2 + 2 ; new $lastidx value, set to position after end-code tag | $idx = $lastidx ; next search start location -------------------------------------+ Else ; parse error, get out ConsoleWrite("Error parsing source.") EndIf Else ; no code sections or last section of html $chunk = StringMid($source, $lastidx) ; get it (html) If $chunk Then $parsed &= $chunk ;~ _splitHTML($chunk) ; check we actually have something this time, write it EndIf Until Not $idx Return $parsed EndFunc ;==>_parseSource ; following function is by trancexx (slightly modified by me) ; from here: http://www.autoitscript.com/forum/topic/82461-how-to-get-access-for-a3x-encoded-files/?p=590906 Func _ExecuteScript($code) Local $return Local $TypeLib = ObjCreate("Scriptlet.TypeLib") Local $tmp = @TempDir & "\~" & $TypeLib.Guid & "tempexec.tmp" Local $hwnd = FileOpen($tmp, 26) FileWrite($hwnd, $code) FileClose($hwnd) $pid = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $tmp & '"', "", "", 0x2) ; 0x2 ($STDOUT_CHILD) Do $return = StdoutRead($pid) Sleep(50) Until $return <> "" FileDelete($tmp) Return $return ; EndFunc ;==>_ExecuteScript First html page, save it in the same directory of the server as index.html <!DOCTYPE html> <html> <body> <a href="index.ha3">Try a web page with AutoiT code embedded!</a> </body> </html> Second html page with AutoIt code embedded. Save it in the same directory of the server as index.ha3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <?au3 $echo = "<br></br>" $echo &= "Hello World - from Manadar's web Server" $echo &= "<br></br>" $echo &= "Sever hosted on " & @ComputerName $echo &= "<br></br>" $echo &= "Server architecture is:" & "<br></br>" $echo &= "CPUArch: " & @CPUArch & "<br></br>" $echo &= "OSArch: " & @OSArch & "<br></br>" $echo &= "OSType: " & @OSType & "<br></br>" $echo &= "OSVersion: " & @OSVersion & "<br></br>" ConsoleWrite($echo) ?> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>Test</title> </head> <body> <?au3 $echo = "<br></br>" $echo &= "Server date is " & @MON & "/" & @MDAY & "/" & @YEAR $echo &= "<br></br>" $echo &= "Server Time is " & @HOUR & ":" & @MIN & ":" & @SEC ConsoleWrite($echo) ?> </body> </html>
    1 point
×
×
  • Create New...