Jump to content

BrewManNH

MVPs
  • Posts

    14,148
  • Joined

  • Last visited

  • Days Won

    67

Community Answers

  1. BrewManNH's post in Is it possible to copy files to startup in autoit? was marked as the answer   
    Your FileCopy command is written wrong, you have the macro inside the quotes.
    FileCopy("C:\Users\" & @UserName & "\Desktop\example.exe", "C:\Users\" & @UserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup")  
  2. BrewManNH's post in DriveGetLabel not giving the expected result? was marked as the answer   
    You're confusing Volume Label (the name of the drive) with the Volume Serial Number. The E649-2540 is the serial number of the drive's volume, a made up number that's created when the drive is formatted. You need the DriveGetSerial if you're looking for the serial number
    ConsoleWrite(DriveGetLabel("C:") & @TAB & Hex(DriveGetSerial ( "c:" )) & @CRLF) Note the Hex function included in there.
  3. BrewManNH's post in having trouble with Run command not executing was marked as the answer   
    Use this command until you know it's working. After you can verify that it's working, you can change the /k to /c so that the command window will close after it's finished running. Then you can also change the @SW_SHOW to @SW_HIDE to keep the window hidden. Before you KNOW it's working do NOT use /c or @SW_HIDE. How are you ever going to know what the problem is if you're hiding all the error messages from yourself?
    Run(@ComSpec & ' /k data\Zip\zip.exe -r "' & $destZip & '" "' & $source & '"', @ScriptDir, @SW_SHOW, $STDOUT_CHILD)
  4. BrewManNH's post in GUI made with ISN AutoIt Studio not showing icons was marked as the answer   
    Try this:
    ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;~ ShellExecute(@DesktopDir & '\test.txt', Default, Default, "open") Global $test = GUICreate("test", 124, 108, -1, -1, -1, -1) GUISetBkColor(0xFFFFFF, $test) GUICtrlCreateButton("Hell No", 12, 12, 100, 30) GUICtrlSetImage(-1, @ScriptDir & '\12.ico') GUICtrlCreateButton("Hell Yeah", 12, 60, 100, 30) GUICtrlSetImage(-1, @ScriptDir & '\11.ico') GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd You were setting the style for the button to display a bitmap and not an icon. Also, you have lines in your code that aren't needed at all. Specifically, #include-once, that's only needed on an include file, not the main script. Also, you're using parameters in there that aren't needed because they're already set as the default values, while not technically wrong, they're not needed.
  5. BrewManNH's post in Hide all controls in GUI was marked as the answer   
    Here's how I'd do it.
    #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $Form1 = GUICreate("Form1", 616, 439, 192, 124) GUICtrlCreateGroup("Group1", 246, 91, 254, 186) Global $DummyStart = GUICtrlCreateDummy() ; get start of control creation control id GUICtrlCreateRadio("Radio1", 312, 108, 113, 17) GUICtrlCreateRadio("Radio2", 312, 231, 113, 23) GUICtrlCreateRadio("Radio3", 312, 211, 113, 17) GUICtrlCreateRadio("Radio4", 312, 149, 113, 17) GUICtrlCreateRadio("Radio5", 312, 190, 113, 17) GUICtrlCreateRadio("Radio6", 312, 129, 113, 17) GUICtrlCreateRadio("Radio7", 312, 169, 113, 17) Global $DummyEnd = GUICtrlCreateDummy() ; get end of control creation id GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Button1 = GUICtrlCreateButton(" Hide ", 273, 372, 75, 25) GUISetState(@SW_SHOW) While 1 Sleep(100) $msg = GUIGetMsg() Switch $msg Case $Button1 Button1Click() Case $GUI_Event_Close Exit EndSwitch WEnd Func Button1Click() Local Static $toggle = True $toggle = Not $toggle For $Loop = $DummyStart + 1 To $DummyEnd - 1 If $toggle Then GUICtrlSetState($Loop, $GUI_SHOW) GUICtrlSetData($Button1, " Hide ") Else GUICtrlSetState($Loop, $GUI_HIDE) GUICtrlSetData($Button1, " Show ") EndIf Next EndFunc ;==>Button1Click Easily adaptable to any script if the controls to be hidden, are created in sequence.
  6. BrewManNH's post in _GUICtrlListView_GetItemText not working with variable was marked as the answer   
    Actually if you change the line to this, it will work with the control ID or the variable.
    $rowID = _GUICtrlListView_GetItemText($hListView, Number($selectedRow)) The function requires a number, _GUICtrlListView_GetSelectedIndices returns a string containing a number. I'm not sure why the SendMsg function works with the string, but the GUICtrlSendMsg function won't. Maybe it has something to do with the DLLCall function that converts the string to a number.
  7. BrewManNH's post in *Problem* Select Loops Duping GUIs *Problem* was marked as the answer   
    $Btn_Min has been declared but contains nothing, or in other words its contents = "0". GUIGetMsg returns 0 when nothing is happening with any controls on the GUI. So because $Btn_Min is 0 until you run the Max_Win function, the Case for $Btn_Min is always going to fire off. The easiest way to handle that in your script is to declare $Btn_Min with a value, such as 9999 or some other unlikely number that isn't a control ID before you try to run the Select loop.
  8. BrewManNH's post in GuiRichEdit.au3 - _GUICtrlRichEdit_StreamToFile - error 102 was marked as the answer   
    That line has been corrected in the beta version. I'm not sure when it was corrected, as there's nothing in the changelog about it, but 3.3.13.19 has the change in it.
  9. BrewManNH's post in Noobie question, gethostbyaddr isn't giving me an output was marked as the answer   
    You should look in the Inet.au3 file for the function _TCPIPToName function to see how it is done in there.
  10. BrewManNH's post in Need Helps About Date Code !!!! was marked as the answer   
    You need to convert the date from _NowCalcDate to DD/MM/YYYY. The easiest way to do it would be to use stringsplit, using "/" as the delimiter, then put the date back together in the format you want. Like this.
    #include <Date.au3> Global $aDate = StringSplit(_NowCalcDate(), "/") Global $sDate = $aDate[3] & "/" & $aDate[2] & "/" & $aDate[1] ConsoleWrite("Today's date = " & $sDate & @CRLF)
  11. BrewManNH's post in How add to combobox +20.000 lines FAST ? was marked as the answer   
    You could use _ArrayToString on the array returned by FileReadToArray, and then just add them all by using GUICtrlSetData.
  12. BrewManNH's post in Adding Text was marked as the answer   
    Sorry about the post above, lack of proper testing on my part. This script will not overwrite the text in the file, but will add the new text above it.
    ;~ #include <FileConstants.au3> #include <File.au3> $sFilename = @ScriptDir & "\Test.txt" $hFile = FileOpen($sFilename, 2) ; create new file For $I = 1 To 10000 FileWriteLine($hFile, "Line: " & $I) ; create 10,000 lines of text Next FileClose($hFile) ; close the file ; Only this part is needed to add something to the start of the file, the top part is just to create the test file. $hFile1 = FileOpen(@ScriptDir & "\Dummy.txt", 2) ; create dummy file, can be deleted later in the script or reused for other files FileWriteLine($hFile1, "I am line No. 1 now :P ") ; write the line to the file FileWriteLine($hFile1, " ") FileClose($hFile1) ; close the file RunWait(@ComSpec & " /c copy /b " & @ScriptDir & "\Dummy.txt + " & $sFilename & " " & @ScriptDir & "\test1.txt", "", @SW_HIDE) ; copy the dummy file to the top of the text file and create a new temp file FileMove(@ScriptDir & "\test1.txt", $sFilename, $FC_OVERWRITE) ; overwrite the original file with the temp file, deleting the temp file
  13. BrewManNH's post in Hotkey gets stuck was marked as the answer   
    https://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F
  14. BrewManNH's post in ArrayFindAll on 2D Array Help was marked as the answer   
    The array columns are zero based, and unfortunately for your script, if the column searched in is past the end of the array, it corrects your search to be the last column. So when you were searching the 3 column of the array in the 6/3 array, it was actually asking to search the 4th column, since there is no 4th column, it was auto-corrected to search the 3rd. When there actually is a 4th column, the auto-correction doesn't happen, and it searches in the 4th column (column order 0,1,2,3,4). Change the 3 in _arrayfindall to 2, and it works correctly.
  15. BrewManNH's post in How to find the file names in a folder with the given folder path was marked as the answer   
    FileListToArray
  16. BrewManNH's post in Bug ? StringIsDigit("-123") was marked as the answer   
    That function only deals with numbers, the minus sign isn't a number so the string isn't seen as a number. It would be the same result if you used "1.0", as the decimal point isn't a number. Not a bug.
  17. BrewManNH's post in Using a stop button to interrupt a function was marked as the answer   
    https://www.autoitscript.com/wiki/Interrupting_a_running_function
  18. BrewManNH's post in Help! IniWrite writing wrong character was marked as the answer   
    By design, INI files are not Unicode aware. You can make your INI file able to save Unicode characters by doing a FileOpen using a Unicode file write mode, and then use FileClose to close it. Do this before using the INI file for the first time. See the Help file for IniWrite.
  19. BrewManNH's post in Natural Sort Order (StrCmpLogicalW) Call Help was marked as the answer   
    You can change that or change the DLLStructCreate line to this:
    Local $tagLC = DllStructCreate('wchar S1[1024];wchar S2[1024]') If you want to use Unicode strings, use Unicode data types in your structs and your DLLCalls.
  20. BrewManNH's post in GUI Combobox only Select if Selected with mouseclick? was marked as the answer   
    Don't use the combobox as a trigger to read from it, use a separate button to trigger the function.
    #include <GUIConstants.au3> Func Program() $hGUI = GUICreate("Logged in as: " & ("info removed ") & StringUpper(GUICtrlRead($Username)), 300, 30) $Runasprogs = GUICtrlCreateCombo("", 5, 5, 275, 20) GUICtrlSetData(-1, "|Test1|Test2|Close", "") Local $idButton = GUICtrlCreateButton(" Execute ", 300, 5) ; <<<<<<<<<<< GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton ; <<<<<<<<<<< Switch GUICtrlRead($Runasprogs) Case "Test1" ShellExecute("URl of Test") If @error = 1 Then MsgBox(0, "Failure", "An Error has occurred, @extended = " & @extended) Case "Test2" ShellExecute("URl of Test") If @error = 1 Then MsgBox(0, "Failure", "An Error has occurred, @extended = " & @extended) Case "Close" Exit EndSwitch EndSwitch WEnd EndFunc ;==>Program
  21. BrewManNH's post in Simple stupid Q.. Output text to a DOS window was marked as the answer   
    When you compile the script  to an exe, you'd need to use the "#AutoIt3Wrapper_Change2CUI=y" directive in your script.
  22. BrewManNH's post in using input to get coords X.Y was marked as the answer   
    You need to use GUICtrlRead($input6) and not just $input6, that's just the control ID for the input control.
  23. BrewManNH's post in Why does this NOT work? was marked as the answer   
    You're only reading from the INI file at the start of the script, you write to it, but never read it back. The only way it would work is to move the IniRead line into the While loop and after the Case $idread.
  24. BrewManNH's post in WinWaitActive or alternatives was marked as the answer   
    Use the window's classname instead of it's title.
  25. BrewManNH's post in Accessing property which has the same name as a keyword was marked as the answer   
    If you had searched the forum you would have found the answer to your question in about a dozen different threads. Download the latest beta version of Au3Check.exe and that will fix the issue. It's not a bug in AutoIt, just a bug in the syntax checker.
    BTW, you posted in the wrong forum, this should have been posted GH&S.
×
×
  • Create New...