Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/25/2017 in all areas

  1. is there any reason you want use notepad ? you can read from a master file and write lines in new files directly #include <FileConstants.au3> Local $sLineRead = "", $x = 0 Local $sFilePath = "MasterFile.txt" ; Open the file for reading and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Do ; Read a line from the file using the handle returned by FileOpen. $sLineRead = FileReadLine($hFileOpen) If @error Then Exit ; if no more lines in master file then exit $x += 1 ; write previously read line to a new file FileWrite("NewFile" & $x & ".txt", $sLineRead) Until @error ; if problem on writing then end
    1 point
  2. I am confused. Do you want to copy not.txt to a new text file on disk? Or do you want to read the contents of file not.txt and then... paste it into another text file? Much of muchness it seems. First solution would be FileCopy ; Copy Au3 files in the temporary directory to a new folder/directory called Au3Files. FileCopy("c:\myautoit\not.txt", "c:\myautoit\new.txt", $FC_OVERWRITE + $FC_CREATEPATH)
    1 point
  3. Will look on this today.
    1 point
  4. @killergoose75 I think you need to post your code this way here when posting in forum. I prefer to use the suggested response from @Xandy to use Run() instead of ShellExecute(). Sometimes ShellExecute() will prompt if to run your program or not, while Run() will run it with no prompting.
    1 point
  5. kylomas

    Write data from file

    tezhihi, Does this give you what you want? #include <Array.au3> #include <file.au3> Local $aRSLT = StringRegExp(FileRead(@ScriptDir & "\aaaaaaaaaa.visf"), '.*\$200.*', 3) If @error Then Exit MsgBox(0, 'Stringregexp error', 'Error = ' & @error) _FileWriteFromArray(@ScriptDir & '\$200.txt', $aRSLT) If @error Then Exit MsgBox(0, 'File write error', 'Error = ' & @error) ShellExecute(@ScriptDir & '\$200.txt') kylomas
    1 point
  6. I can only assume the poster was using Asian keyboard or something like that. You can view the characters in NotePad++ by copying the text in and change encoding to Ansi and you should see the odd characters, I'm fairly sure that is what triggers the SimSun font. In IE there are a couple of other characters that are also displayed. You can use something like the following to convert them to unicode: $String = "And i have a easy  way to slove this problem:" MsgBox(0,'Before', $String) $String = BinaryToString(StringToBinary($String), 4) MsgBox(0,'After', $String)
    1 point
  7. JLogan3o13

    Write data from file

    @tezhihi you might try actually reading the help file on these two sections, you could probably find the answer to your question faster than you can post the question here. The help file shows you exactly what _ArraySearch returns vs. _ArrayFindAll (hint), and even has these nice little examples to show you when to use one over the other.
    1 point
  8. I'm not sure about what you exactly want to do. If you want to get the text of the whole line then you will run into the problem described by martin : "Then if you want to get the text of a particular line you have a problem. You can find the length of a line by sending a message. To get the text of a line there is a message $SCI_GETLINE, which you know, but you have to pass it the line number (first is 0) and the address of a buffer where it can write the result. If the editor is part of your program this is not a problem, but since it isn't (...) then the program which has the editor cannot write to the memory owned by your program." So you will need the same workaround and your method is the good one If you want to get other occurences of the search with details then in the loop I (personally) prefer the use of regex to make the search more versatile #include <SciteConstants.au3> WinActivate("[CLASS:SciTEWindow]", "") $Sci = ControlGetHandle("[CLASS:SciTEWindow]", "", "[CLASS:Scintilla; INSTANCE:1]") $str = "CLASS" $len = StringLen($str) $txt = ControlGetText("[CLASS:SciTEWindow]", "", "[CLASS:Scintilla; INSTANCE:1]") Local $offset = 1 While 1 $res = StringRegExp($txt, '(\Q' & $str & '\E)', 1, $offset) $offset = @extended If not IsArray($res) Then Exitloop $end = $offset-1 $start = $end - StringLen($res[0]) ; SendMessage($Sci, $SCI_SETSEL, $start, $end) ; Sleep(800) $line = SendMessage($Sci, $SCI_LINEFROMPOSITION, $start, 0)+1 Consolewrite("found at pos " & $start & " - in line " & $line & @crlf) Wend Func SendMessage($hwnd, $msg, $wp, $lp) Local $ret $ret = DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hwnd, "int", $msg, "int", $wp, "int", $lp) If @error Then Return SetError(1) Return $ret[0] EndFunc ;==>SendMessage
    1 point
  9. czardas

    Array

    You can do this using _PreDim() without any data loss. The function was designed for this very purpose. See ArrayWorkshop in my signature below. #include <ArrayWorkshop.au3> Local $aArrayXD = [[1,2],[3,4]] ; 2D array _PreDim($aArrayXD, 3) ; becomes a 3D array After this you can increase the size of the third dimension using (the more standard) ReDim. Alternatively, you can attach 2D arrays in the 3rd dimension using _ArrayAttach(): think of this as stacking spread sheets in a pile.
    1 point
  10. 1 point
  11. @Melba23 No offence but you literally googled that URL
    1 point
  12. Info, Let me google that for you. M23
    1 point
  13. jchd

    Source Code?

    As a programmer using the language you don't need to know the underlying working of built-in functions and you shouldn't even care. I don't care whether MsgBox() uses Windows UI primitives, draws the thing directly by writing in the graphics card memory or even employs an army of underpaid chinese workers to raise or hide microscopic red, green and blue flags. All I want is the function to have clear specifications and consistent behavior suitable for my use cases and nothing else. Now what issue(s) do you experience with those functions?
    1 point
  14. Also, is your script made for 32 bit or 64 bit?
    1 point
  15. Put this at the beginning of the script: _WinAPI_SetErrorMode($SEM_FAILCRITICALERRORS Or $SEM_NOGPFAULTERRORBOX) Most likely your script will die anyway, but nobody will notify you about it
    1 point
  16. Good practice is that your application controls displaying error messages. System does it and will do it only if you fail to handle critical type of errors. This is done by calling SetErrorMode function as one of the first things you do in the script if there is even a remote possibility critical error will occur. See this example: Global Const $SEM_FAILCRITICALERRORS = 1 ; This is the line. You are telling: I'll handle possible displaying of critical errors myself SetErrorMode($SEM_FAILCRITICALERRORS) ConsoleWrite(FileOpen("A:") & @CRLF) ; This line would create system's critical-error-handler message box for my system if I haven't called SetErrorMode passing SEM_FAILCRITICALERRORS argument Func SetErrorMode($iMode) Local $aCall = DllCall("kernel32.dll", "dword", "SetErrorMode", "dword", $iMode) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc
    1 point
  17. Yashied

    CDrom no disc error

    Replace do do $DriveStatus = DriveStatus("Z:") until $DriveStatus = "READY" if not FileExists ("Z:test.txt") then _EjectDisc() until FileExists("Z:test.txt") to #Include <APIConstants.au3> #Include <WinAPIEx.au3> ... $Mode = _WinAPI_SetErrorMode($SEM_FAILCRITICALERRORS) While 1 If Not FileExists('Z:test.txt') Then Switch _WinAPI_GetLastError() Case 21 ; ERROR_NOT_READY ; Nothing Case Else _WinAPI_EjectMedia('Z:') EndSwitch Else ExitLoop EndIf Sleep(100) WEnd _WinAPI_SetErrorMode($Mode)
    1 point
×
×
  • Create New...