Jump to content

water

MVPs
  • Posts

    26,674
  • Joined

  • Last visited

  • Days Won

    204

water last won the day on March 1

water had the most liked content!

About water

Recent Profile Visitors

11,934 profile views

water's Achievements

  1. When you learn to ride a bike, you don't ask your parents every 100 metres whether you're doing it right. As long as you don't fall, you're doing it right. It's the same with programming. If it works, then you've done a lot of things right. Maybe not efficiently or according to all the rules of programming, but it works. You've been working with AutoIt long enough that you should have this confidence in your own abilities and not have to ask after every 5 lines of code. Have more confidence! If it works, then it's good. If you get wrong results or error messages, that's the time to ask. Just my 2 cents worth! Written with the help of DeepL.com translator
  2. Welcome to AutoIt and the forum You noticed that the thread is nearly 10 years old and the OP has left in October 2015?
  3. @SmileFace123 Could you please post full sentences? I see you are new on this forum. The goal of this forum is to help other users with their problems. Two word sentences do not help very much
  4. You are correct. The thread is very, very old. It would have been better to create a new thread and - if needed - refer to this thread I have been able to translate this VBA solution to AutoIt: #include <Excel.au3> ; XlDirection enumeration - Specifies the direction in which to move. Global Const $xlUp = -4162 ; Up. ; XlPageBreak-Enumeration - Specifies page break location on the worksheet. Global Const $xlPageBreakManual = -4135 ; Page breaks are manually inserted. Global $oExcel, $oWorkbook, $oWorksheet, $iLastRow $oExcel = _Excel_Open() $oWorkbook = _Excel_BookAttach("Mappe1") ; Change the name of the already opened workbook _AddPageBreaks($oExcel, $oWorkbook.Sheets(1)) Exit Func _AddPageBreaks($oExcel, $oWorksheet) Local $iLastRow = $oWorksheet.Cells($oWorksheet.Rows.Count, "A").End($xlUp).Row ; find last used row in column A For $iRow = 10 To $iLastRow Step 8 $oWorksheet.HPageBreaks.Add($oWorksheet.Rows($iRow)) $oWorksheet.Rows($iRow).PageBreak = $xlPageBreakManual Next EndFunc ;==>_AddPageBreaks
  5. My understanding is: AutoIt is a wrapper for Windows functions. The documentation describes the AutoIt language. It ends where the Windows documentation starts.
  6. Oops, my mistake! Consolewrite seems to be the famous exception to the rule
  7. I suggest to use functions provided by AutoIt as long as they do the job. AutoIt returns enough information to debug the script in case of an error. Implementing external programs into your script is - most of the time - much harder and time consuming. I had a quick look at your script and will post my reply as a quiz: @error is set to 0 whenever a function is entered. ConsoleWrite is a function Can you find the error in your script?
  8. Talking about arrays: Your code tells me that you do not understand how arrays work. Subz tried to tell you, but ... You created an array with 4 rows and 4 columns, but only fill the first column of all rows. Then you loop through all rows. Your code passes the same cell 4 times to RegWrite. That returns an error. Add debugging code to your script to make sure all function calls work properly. I already posted code in one of your threads that exaclty tells you what went wrong.
  9. Even without further troubleshooting information from you, the cause of the problem is fairly obvious. The solution is: Learn the basics of AutoIt! That includes arrays!
  10. As a coder you want to become, you should know that "does not work" isn't an acceptable description of a bug
  11. I had a quick look at the Excel-File you posted. OMG - Can you please tell me why you store it this way? I have never seen something like this before.
  12. Simple Example? Already available in the helpfile. At least for ArrayTranspose 🙂
  13. The Array UDF offers function _ArrayTranspose. Excel offers the Transpose method (e.g. $oExcel.Transpose). Should be a good starting point
  14. How about this little function? Added a function header describing every aspect of the function so you can modify/debug the function even many years after you have written the code. Added the name of the program to be displayed in error messages, so users know where the message came from. I hate anonymous error messages! Added an array holding the full text of possible errors. Makes debugging much easier. Removed $sRegSZ = "REG_SZ" as this is only used once and this literal is required by RegWrite and will not change in the near future. Replaced Splashtext by MsgBox. When there is an error I like to get easy readable/understandable information. No eye candy. In conclusion: I wouldn't write a separate function here, but carry out the error check directly in the programme. A user function isn't worth the effort! #include <MsgBoxConstants.au3> Opt("MustDeclareVars", 1) Global $sProgramName = "Registry Testprogram" Global $sRegWriteErrors[] = ["value type not supported", "unable to open requested value", "", "unable to open requested key", "unable to open requested main key", "unable to remote connect to the registry"] AddRegKeyHKCUValue() Exit ; #FUNCTION# ==================================================================================================================== ; Name...........: AddRegKeyHKCUValue ; Description ...: Writes a success message or an error message with detailed debug information for RegWrite. ; Syntax.........: AddRegKeyHKCUValue() ; Parameters ....: None ; Return values .: None ; Author ........: Jon Doe ; Remarks .......: ; Related .......: ; Link ..........: ; =============================================================================================================================== Func AddRegKeyHKCUValue() Local $sKeyname = "HKEY_CURRENT_USER\Software\Native Instruments\Guitar Rig 5" Local $sValuename = "UserContent" Local $sString = "C:\Program Files\Native Instruments\Reflektor\16 User_Impulses\" If RegWrite($sKeyname, $sValuename, "REG_SZ", $sString) = 1 Then MsgBox($MB_ICONINFORMATION, $sProgramName, "RegWrite was SUCCESSFUL!", 2) Else MsgBox($MB_ICONERROR, $sProgramName, "RegWrite has returned ERROR " & @error & "!" & @CRLF & $sRegWriteErrors[@error + 2] & "!") EndIf EndFunc ;==>AddRegKeyHKCUValue
×
×
  • Create New...