Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/27/2018 in all areas

  1. StringReplace($TtextClean, ChrW(0x2014), " ") ;em dash Edit : en dash = 2013 BTW you can replace the 3 dashes in one shot using StringRegExpReplace $TtextClean = StringRegExpReplace($TtextClean, "\x{2013}|-|\x{2014}" , " ")
    2 points
  2. Subz

    Variable on For Next loop

    @Skeletor If you used actual numbers you can see why your code won't work for example: In this example we're assuming test.txt has 5 lines and FileRead2 has 10 lines, you can see how it will fail based on that code, but as FrancescoDiMuro pointed out you need to explain what you're trying to achieve. Local $Lines1 = 5 ;~ _FileCountLines(C:\temp\test.txt) Local $linesToCount2 = 7 ;~ $Lines1 + 2 $var = 7 ;~ Number($linesToCount2) (You don't require Number() function since its already a number) For $count = 1 To 10 ;~ _FileCountLines($FileRead2) Step 1 For $i = 7 To 1 ;~ $var To $count (Won't work you need to use Step - 1) However when it reaches 7 it will need to go Step + 1 Next ;Code does stuff here Next
    2 points
  3. Subz

    Variable on For Next loop

    No you just insert data into the array then afterwards you'd just write the entire array to file. It would be simpler if you show an example of the two files and then what you expect it to look like afterwards You don't have to use real data just need to understand what you're trying to achieve.
    1 point
  4. @Skeletor Essentially, you could easily work with arrays, instead of getting line by line your text, and writing it to the "destination file". Expand as much as you want $arrSourceFiles; the content of all the source files will be written in the "Destination File" #include <File.au3> #include <FileConstants.au3> Global $strDestinationFile = @ScriptDir & "\DestinationFile.txt", _ $arrSourceFiles[] = [@ScriptDir & "\SourceFile1.csv", _ @ScriptDir & "\SourceFile2.csv"], _ $arrFileContent, _ $hdlDestinationFile $hdlDestinationFile = FileOpen($strDestinationFile, $FO_APPEND) If $hdlDestinationFile = -1 Then ConsoleWrite("Error while opening the file '" & $strDestinationFile & "'." & @CRLF) Else For $i = 0 To UBound($arrSourceFiles) - 1 Step 1 _FileReadToArray($arrSourceFiles[$i], $arrFileContent, $FRTA_NOCOUNT) If @error Then ConsoleWrite("Error while reading the file '" & $arrSourceFiles[$i] & "'. Error: " & @error & @CRLF) Else ConsoleWrite("The file '" & $arrSourceFiles[$i] & "' has been read correctly." & @CRLF) _FileWriteFromArray($hdlDestinationFile, $arrFileContent) If @error Then ConsoleWrite("Error while writing the data into '" & $strDestinationFile & "'. Error: " & @error & @CRLF) Else ConsoleWrite("The data read from the file '" & $arrSourceFiles[$i] & "' has been write correctly to '" & $strDestinationFile & "'." & @CRLF) EndIf EndIf Next FileClose($hdlDestinationFile) EndIf Here it is all the "sample" Sample.zip
    1 point
  5. Subz

    Variable on For Next loop

    Couldn't you just use an array and add the values you want to a new array variable? #include <Array.au3> #include <File.au3> Local $aFileRead1, $sFileName1 = @ScriptDir & "\FileName1.csv" Local $aFileRead2, $sFileName2 = @ScriptDir & "\FileName2.csv" _FileReadToArray($sFileName1, $aFileRead1, 0, ",") _FileReadToArray($sFileName2, $aFileRead2, 0, ",") _ArrayConcatenate($aFileRead1, $aFileRead2) _ArrayDisplay($aFileRead1)
    1 point
  6. @ur Using a combination of Win* functions, ControlGetHandle() and _GUICtrlToolbar_ClickIndex(), you get what you want #include <GuiToolbar.au3> Global $strWinTitle = "new 1 - Notepad++", _ $hdlWinHandle, _ $strNotepadTB = "[CLASS:ToolbarWindow32; INSTANCE:1]", _ $hdlNotepadTB WinWaitActive($strWinTitle) $hdlWinHandle = WinGetHandle($strWinTitle, "") $hdlNotepadTB = ControlGetHandle($hdlWinHandle, "", $strNotepadTB) _GUICtrlToolbar_ClickIndex($hdlNotepadTB, 1) ; It starts from 0, so it will click on "Open..."
    1 point
  7. Whoops sorry, I was testing something before I posted and forgot to revert it back, here is the correct code for 2d. #include <Array.au3> Local $sExcelData = ClipGet() $sExcelData = StringTrimRight(StringReplace($sExcelData, @TAB, "|"), 2) Local $aExcel1D = StringSplit($sExcelData, @LF, 2) If IsArray($aExcel1D) Then If StringInStr($sExcelData, "|") Then Local $aExcel2D[0][0] For $i = (UBound($aExcel1D) - 1) To 0 Step - 1 If StringStripWS($aExcel1D[$i], 8) = "" Then ContinueLoop $aExcelLine = StringSplit($aExcel1D[$i], "|", 2) ReDim $aExcel2D[UBound($aExcel2D)][UBound($aExcelLine)] _ArrayAdd($aExcel2D, _ArrayToString($aExcelLine)) Next Else Local $aExcel2D = $aExcel1D EndIf EndIf _ArrayDisplay($aExcel2D)
    1 point
  8. Here is one way to use Clipboard Excel Data into an array #include <Array.au3> Local $sExcelData = ClipGet() $sExcelData = StringTrimRight(StringReplace($sExcelData, @TAB, "|"), 2) Local $aExcel1D = StringSplit($sExcelData, @LF, 2) If IsArray($aExcel1D) Then If StringInStr($sExcelData, "|") Then Local $aExcel2D[0][0] For $i = 20 To 0 Step - 1 If StringStripWS($aExcel1D[$i], 8) = "" Then ContinueLoop $aExcelLine = StringSplit($aExcel1D[$i], "|", 2) ReDim $aExcel2D[UBound($aExcel2D)][UBound($aExcelLine)] _ArrayAdd($aExcel2D, _ArrayToString($aExcelLine)) Next Else Local $aExcel2D = $aExcel1D EndIf EndIf _ArrayDisplay($aExcel2D)
    1 point
  9. Sounds good. I haven't read up on all options for this so need to understand what they all are now to be able to produce the right logic/option for the directive. So any input there is welcome. Jos
    1 point
  10. Will do. But I'm going to pause for a couple hours and think over the choices one more time. The statements you've posed don't specifically cover the ones I thought I was concerned with at this point: <dpiAwareness>unaware</dpiAwareness> ... so system handles DPI differences by default <dpiAwareness>system</dpiAwareness> ... so system handles DPI difference by a clear directive But it does appear that <dpiAwareness>PerMonitorV2</dpiAwareness> covers the general case of "Application is Aware" (and will handle differences in DPI ... which is the old HiDPI=Y).
    1 point
  11. Ok, replace the section I posted with this and see if that works for you: If $INP_RES_HiDpi <> "n" Then FileWriteLine($hTempFile2, ' <application xmlns="urn:schemas-microsoft-com:asm.v3"> ') FileWriteLine($hTempFile2, ' <windowsSettings>') FileWriteLine($hTempFile2, ' <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>') If $INP_RES_HiDpi <> "y" Then Write_RC_Console_Msg("Setting DPI awareness Manifest information to true/PM", "", "...", 0) FileWriteLine($hTempFile2, ' <dpiAware>true/PM</dpiAware>') Else Write_RC_Console_Msg("Setting DPI awareness Manifest information to true", "", "...", 0) FileWriteLine($hTempFile2, ' <dpiAware>true</dpiAware>') EndIf FileWriteLine($hTempFile2, ' </windowsSettings>') FileWriteLine($hTempFile2, ' </application>') FileWriteLine($hTempFile2, '') EndIf I have no means of testing so am stabbing in the dark here... Jos
    1 point
  12. I'd love to be able to do that with any confidence. But I was just looking at the AutoIt3Wrapper.au3 statements and immediately I'm not at all clear on how to handle /SMI/2005/ versus /SMI/2016/. Specify only the latest? Or use both in different segments of statements? I'll be glad to make changes and run tests, but I'm facing these questions. Can you recommend a proper course?
    1 point
  13. Obviously not (yet). What about when you try modifying the lines in AutoIt3Wrapper to what you think it should be, test to see if it all works and send me the new version so I can merge it into the current version? Jos
    1 point
  14. OK, I've recompiled my test script with the latest Au3 and the manifest section of both EXEs is exactly the same: But MSFT's page indicates the manifest should now have BOTH awareness parameters: Is there a compiler setting for this?
    1 point
  15. water

    WebLoader

    The forums search function is your friend
    1 point
  16. No need to upgrade your current setup. Just download the zip version of the latest Autoit3 and store it in a separate directory. Then add this directive to the scrip and point it to this separate setup: #AutoIt3Wrapper_AutoIt3Dir= Compile the script and your in business. This should have no impact and makes testing easy. Jos
    1 point
  17. Sure, and pretty easy to figure out too as autoit3wrapper.au3 contains the logic. All it does is add this to the manifest of the compiled program: If $INP_RES_HiDpi <> "n" Then FileWriteLine($hTempFile2, ' <asmv3:application>') FileWriteLine($hTempFile2, ' <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">') If $INP_RES_HiDpi <> "y" Then Write_RC_Console_Msg("Setting DPI awareness Manifest information to true/PM", "", "...", 0) FileWriteLine($hTempFile2, ' <dpiAware>true/PM</dpiAware>') Else Write_RC_Console_Msg("Setting DPI awareness Manifest information to true", "", "...", 0) FileWriteLine($hTempFile2, ' <dpiAware>true</dpiAware>') EndIf FileWriteLine($hTempFile2, ' </asmv3:windowsSettings>') FileWriteLine($hTempFile2, ' </asmv3:application>') FileWriteLine($hTempFile2, '') EndIf The option can be N/Y/P or No/Yes/PM. The details are explained on the Microsoft site as you have found already i guess. Jos
    1 point
  18. Hi, This is not strictly true. When AutoIt creates a control using one of the GUICtrlCreate* functions it adds its details to an internal array and returns the index of that array as its "ControlID" - this value is used internally by AutoIt to identify the controlwhen you use any of the GUICtrl* functions. To allow as many controls as possible, AutoIt looks for the first available empty index in this array to add the new control - normally this means that the returned ControlIDs increase by 1 for each created control. This allows for some easy manipulation of groups of controls by using their ControlIds as the loop counter - as you can see here: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $iStart = GUICtrlCreateDummy() ConsoleWrite("Start : " & $iStart & @CRLF) ; Should be 3 For $i = 1 To 5 $iCID = GUICtrlCreateLabel("", 10, 10 + (50 * $i), 200, 40) ; Display the returned ControlID - I have no idea what Autoit does with elements 1 & 2 !!!!! GUICtrlSetData(-1, $iCID) ; Set colour to red GUICtrlSetBkColor(-1, 0xFFCCCC) Next $iEnd = GUICtrlCreateDummy() ConsoleWrite("End: " & $iEnd & @CRLF) ; Should be 9 $cAlter_1 = GUICtrlCreateButton("Change 1", 10, 450, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAlter_1 ; Set label CIDs as the loop counter For $i = $iStart + 1 To $iEnd - 1 ; Change label colours GUICtrlSetBkColor($i, 0xCCFFCC) Next EndSwitch WEnd But look what happens if you delete a previously created control and then create another group of controls. Change the colour of the first group, then press the Delete, Create and Alter_2 buttons in order: #include <GUIConstantsEx.au3> Global $cLabel_6, $cLabel_10 $hGUI = GUICreate("Test", 500, 500) $cLabel_1 = GUICtrlCreateLabel("", 10, 10, 200, 40) ; Display the returned ControlID - I have no idea what Autoit does with elements 1 & 2 !!!!! GUICtrlSetData(-1, $cLabel_1) ; Set colour to red GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_2 = GUICtrlCreateLabel("", 10, 60, 200, 40) GUICtrlSetData(-1, $cLabel_2) GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_3 = GUICtrlCreateLabel("", 10, 110, 200, 40) GUICtrlSetData(-1, $cLabel_3) GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_4 = GUICtrlCreateLabel("", 10, 160, 200, 40) GUICtrlSetData(-1, $cLabel_4) GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_5 = GUICtrlCreateLabel("", 10, 210, 200, 40) GUICtrlSetData(-1, $cLabel_5) GUICtrlSetBkColor(-1, 0xFFCCCC) $cAlter_1 = GUICtrlCreateButton("Change 1", 10, 450, 80, 30) $cAlter_2 = GUICtrlCreateButton("Change 2", 360, 450, 80, 30) GUICtrlSetState($cAlter_2, $GUI_DISABLE) $cDelete = GUICtrlCreateButton("Delete", 110, 450, 80, 30) $cCreate = GUICtrlCreateButton("Create", 260, 450, 80, 30) GUICtrlSetState($cCreate, $GUI_DISABLE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAlter_1 ; Set label CIDs as the loop counter For $i = $cLabel_1 To $cLabel_5 ; Change left label colours GUICtrlSetBkColor($i, 0xCCFFCC) Next Case $cAlter_2 For $i = $cLabel_6 To $cLabel_10 ; Change right label colours - or does it? <<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetBkColor($i, 0xFFFFCC) Next Case $cDelete ; Delete one of the GUICtrlDelete($cLabel_3) GUICtrlSetState($cCreate, $GUI_ENABLE) Case $cCreate $cLabel_6 = GUICtrlCreateLabel("", 260, 10, 200, 40) GUICtrlSetData(-1, $cLabel_6) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_7 = GUICtrlCreateLabel("", 260, 60, 200, 40) GUICtrlSetData(-1, $cLabel_7) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_8 = GUICtrlCreateLabel("", 260, 110, 200, 40) GUICtrlSetData(-1, $cLabel_8) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_9 = GUICtrlCreateLabel("", 260, 160, 200, 40) GUICtrlSetData(-1, $cLabel_9) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_10 = GUICtrlCreateLabel("", 260, 210, 200, 40) GUICtrlSetData(-1, $cLabel_10) GUICtrlSetBkColor(-1, 0xCCCCFF) GUICtrlSetState($cAlter_2, $GUI_ENABLE) EndSwitch WEnd Not quite what you expected eh? You can see that the first of the new labels has taken the ControlID of the deleted label in the first group and so all the buttons and some of the first group of labels change colour as well - as their ControlIDs are now included in the loop. The moral of the story? Be very careful when using ControlIDs as loop counters if any controls can be deleted anywhere in the script - and remember that deleting whole GUIs also deletes their controls automatically. How should you action groups of controls? Store their returned ControlIDs in an array and loop through them - that way you will only ever use the correct values. M23
    1 point
  19. ID numbers for controls are assigned by order of creation, and usually cannot be assigned again, to prevent conflicts. That said, I do know that in some instances at least, if you delete in reverse order from the last control created, you can work-around that limitation. That is certainly so for ListViews, where each list entry (row) gets its own control ID. With a single ListView for instance, you have it created last, to gain best advantage with List items. In any case, like TheDcoder suggested, you are better off referencing by variable name in most cases, as they are easily reassigned.
    1 point
  20. @Fractured My pleasure I normally totally disregard the actual ID beside storing it inside a well-named variable, you can think of the variable as the name of the control. That is how I worked my way up in the beginning. Just my two cents Feel free to post about what you are trying to do and maybe some of us can offer suggestions.
    1 point
  21. jguinch

    Make copy of GUI

    You want to create a copy of a GUI asking for a password ? suspicious no ?
    1 point
  22. Morality : read the help file pages twice
    1 point
  23. Did you also notice this part in the helpfile for GUICtrlSetOnEvent ?: Jos
    1 point
  24. @Water - Thanks! I can see the array and the size of the array is what I need. Seems fast too - I only have 567 rows in the test file but I expect a lot more. How does the performance compare to the prior _ExcelReadSheetToArray function? Just curious. Also, here is what I did in case anyone searches this thread: #include <Array.au3> #include<Excel.au3> Local $oAppl = _Excel_Open() Local $sWorkbook = @ScriptDir & "\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True) $lastline=_Excel_RangeRead ($oWorkbook,Default,Default,Default) _ArrayDisplay($lastline) JFish
    1 point
  25. Use function _Excel_RangeRead and set parameter $vRange = Default to only read the used cells of a worksheet.
    1 point
  26. http://msdn.microsoft.com/en-us/library/aa...28VS.85%29.aspx
    1 point
×
×
  • Create New...