
stealth
Active Members-
Posts
21 -
Joined
-
Last visited
Profile Information
-
Location
in the river breathing through a bamboo stick
-
Interests
ninjas
Recent Profile Visitors
82 profile views
stealth's Achievements

Seeker (1/7)
1
Reputation
-
[Solved] _Excel_RangeRead bug or (my) user error?
stealth replied to stealth's topic in AutoIt General Help and Support
Thank you for explaining, water -
Having issues using "3 - The displayed text" in $iReturn parameter of _Excel_RangeRead. I want values from an Excel spreadsheet. Helpfile for _Excel_RangeRead: "4 - Parameter $iReturn is invalid. Has to be > 1 and < 3" Should this be: "4 - Parameter $iReturn is invalid. Has to be>1 and < 4" ? Also, when adjusting Example 3 of _Excel_RangeRead from ; ***************************************************************************** ; Read the formulas of a cell range (all used cells in column A) ; ***************************************************************************** Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 2) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Data successfully read." & @CRLF & "Please click 'OK' to display all formulas in column A.") _ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 3 - Formulas in column A")to ; ***************************************************************************** ; Read the formulas of a cell range (all used VALUES in column A) ; ***************************************************************************** Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 3) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Data successfully read." & @CRLF & "Please click 'OK' to display all formulas in column A.") _ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 3 - Formulas in column A")I get @error = 5, @extended =-2147352567 -2147352567 seems to do with Regional settings. Would the @ScriptDir & "\Extras\_Excel1.xls" being in German ("Tabelle1") have to do with this? Or are both of these issues my user error?
-
stealth reacted to a post in a topic: [SOLVED] Enable Checkbox only when another check box is checked
-
stealth reacted to a post in a topic: [SOLVED] Enable Checkbox only when another check box is checked
-
Ah-ha! Thank you, All!! I think I got it (for now) . Assigned $vCount to not zero and Go button; $iCount to red 'x' Here is only an label and input box that I'll build upon. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> ;#include <MsgBoxConstants.au3> AutoItSetOption("SendKeyDelay", 50) ;Opt("SendKeyDelay", 5) Global $iCount, $InputCatNo, $vCount While 1 _Animal() Run("notepad.exe") WinWaitActive("Untitled - Notepad") If $vCount <> "" Then Send($vCount & "{ENTER}") ;send $vCount only if a number > 0 is inputted ExitLoop ;exit While1 Loop WEnd Func _Animal() $aAnimal = GUICreate("Animals", 342, 273, 509, 166) $LblCat = GUICtrlCreateLabel("Number of Cats", 32, 54, 113, 23, $SS_RIGHT) $InputCatNo = GUICtrlCreateInput("", 152, 54, 137, 23, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) ;allow only numbers to be inputted $BTNGo = GUICtrlCreateButton("GO", 104, 176, 97, 57) GUISetState(@SW_SHOW) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE ; as long as red 'x' is not clicked, loop $msg = GUIGetMsg() ; polls GUI to see if any events have occurred $iCount = GUICtrlRead($InputCatNo) ; read the input If $iCount <> 0 Then ; if we have something in the box not zero $vCount = $iCount ; set $vCount to $iCount Else $iCount = "" ; if there is nothing, then set $iCount to nothing EndIf Select Case $msg = $BTNGo ;when GO is clicked GUISetState(@SW_HIDE); hide the GUI ExitLoop; exit the entire loop Case $msg = $GUI_EVENT_CLOSE ; we need to make sure we are accounting for the red "x" $vCount = "" ; set the $vCount to nothing, since we did not want to go ExitLoop ; exit the entire loop EndSelect WEnd EndFunc ;==>_Animal
- 10 replies
-
Thank you for your suggestion, MilkahS and all--you've pointed me in the right direction! I have several dozen 'animals' and input boxes for count of animals and need to pass the variables to outside the Function to do with the counts later. I got the flickering inputboxes and then found Walkillon's suggestion: https://www.autoitscript.com/forum/topic/149208-flickering-input-box/?do=findComment&comment=1062398 Next question. Say a user checks "Cats?" checkbox, inputs a number, but decides to push Red X instead of "Go"; how do I erase the number and send nothing to notepad? Something like If Red X is pressed then $iCount = "" ? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> ;#include <MsgBoxConstants.au3> AutoItSetOption("SendKeyDelay", 50) ;Opt("SendKeyDelay", 5) Global $iCount, $InputCatNo While 1 _Animal() Run("notepad.exe") WinWaitActive("Untitled - Notepad") If $iCount <> "" Then Send($iCount & "{ENTER}") ExitLoop WEnd Func _Animal() $aAnimal = GUICreate("Animals", 342, 273, 509, 166) $CBcCats = GUICtrlCreateCheckbox("Cats?", 115, 25, 97, 25) $LblCat = GUICtrlCreateLabel("Number of Cats", 32, 54, 113, 23, $SS_RIGHT) GUICtrlSetState($LblCat, $GUI_DISABLE) $InputCatNo = GUICtrlCreateInput("", 152, 54, 137, 23, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetState($InputCatNo, $GUI_DISABLE) $BTNGo = GUICtrlCreateButton("GO", 104, 176, 97, 57) GUISetState(@SW_SHOW) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $BTNGo ExitLoop EndSelect Switch $msg Case $CBcCats If GUICtrlRead($CBcCats) = $GUI_CHECKED Then GUICtrlSetState($LblCat, $GUI_ENABLE) GUICtrlSetState($InputCatNo, $GUI_ENABLE) ElseIf GUICtrlRead($CBcCats) = $GUI_UNCHECKED Then GUICtrlSetState($LblCat, $GUI_DISABLE) GUICtrlSetState($InputCatNo, $GUI_DISABLE) EndIf EndSwitch WEnd $iCount = GUICtrlRead($InputCatNo) If $iCount Then $iCount = $iCount Else $iCount = "" EndIf Select Case $msg = $BTNGo GUISetState(@SW_HIDE) EndSelect EndFunc ;==>_Animal
- 10 replies
-
Thanks, Supdw2k. I want notepad to open and value sent only when GO is clicked. If the GUI is closed with red X, I want nothing to happen.
- 10 replies
-
The variable $iCount only gets sent to notepad when the red X is clicked, and clicking the GO button takes no action. Why? What am I doing wrong? I want to pass the $InputCatNo as a variable--could be $iCount or another variable. Thank you in advance! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> ;#include <MsgBoxConstants.au3> Global $iCount, $InputCatNo While 1 _Animal() Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send($iCount & "{ENTER}") ExitLoop WEnd Func _Animal() $aAnimal = GUICreate("Animals", 342, 273, 509, 166) $CBcCats = GUICtrlCreateCheckbox("Cats?", 115, 25, 97, 25) $LblCat = GUICtrlCreateLabel("Number of Cats", 32, 54, 113, 23, $SS_RIGHT) GUICtrlSetState($LblCat, $GUI_DISABLE) $InputCatNo = GUICtrlCreateInput("", 152, 54, 137, 23, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetState($InputCatNo, $GUI_DISABLE) $BTNGo = GUICtrlCreateButton("GO", 104, 176, 97, 57) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($aAnimal) Return Case $BTNGo $iCount = GUICtrlRead($InputCatNo) If $iCount Then $iCount = $iCount Else $iCount= "" EndIf Case $CBcCats If GUICtrlRead($CBcCats) = $GUI_CHECKED Then GUICtrlSetState($LblCat, $GUI_ENABLE) GUICtrlSetState($InputCatNo, $GUI_ENABLE) Else GUICtrlSetState($LblCat, $GUI_DISABLE) GUICtrlSetState($InputCatNo, $GUI_DISABLE) EndIf EndSwitch WEnd EndFunc ;==>_Animal
- 10 replies
-
Thank you, Melba. I meant "Enable GUI only when checkbox is checked" in topic and "How to enable a (disabled) GUI only when checkbox has been checked?" as my question. But, you pointed out where my logic was wrong. Thank you!!
- 10 replies
-
I've read the help file, but can't find a solution. How to enable a (disabled) checkbox only when another checkbox has been checked? Once "Cats?" checkbox has been checked, I want the Label "Number of Cats" to be enabled and allow numeric-only input of Input Box $InputCatNo After inputting a number and pressing the Go button, I want to run notepad and send the inputted number to notepad. Thank you in advance for advice or pointing me to a help file. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Math.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> Global $InputCatNo, $InputCatNo2 While 1 _Animal() Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send($InputCatNo2) ExitLoop WEnd Func _Animal() $aAnimal = GUICreate("Animals", 342, 273, 509, 166) $CBcCats = GUICtrlCreateCheckbox("Cats?", 115, 25, 97, 25) GUICtrlSetFont(-1, 16, 400, 0, "Calibri") $LblCat=GUICtrlCreateLabel("Number of Cats", 32, 54, 113, 23, $SS_RIGHT) GUICtrlSetFont(-1, 12, 400, 0, "Calibri") GUICtrlSetstate($LblCat,$GUI_DISABLE) $InputCatNo = GUICtrlCreateInput("", 152, 54, 137, 23, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Calibri") GUICtrlSetstate($InputCatNo,$GUI_DISABLE) $BTNGo = GUICtrlCreateButton("GO", 104, 176, 97, 57) GUICtrlSetFont(-1, 24, 400, 0, "Calibri") GUISetState(@SW_SHOW) $msg = GUIGetMsg() Switch GUIGetMsg() Case GUICtrlRead($CBcCats) = $GUI_CHECKED GUICtrlSetState($LblCat,$GUI_ENABLE) GUICtrlSetState($InputCatNo,$GUI_ENABLE) If GUICtrlRead($InputCatNo) <> "" Then $InputCatNo2 = GUICtrlRead($InputCatNo) Else $InputCatNo2 = "" EndIf EndSwitch While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $BTNGo ExitLoop EndSelect WEnd Select Case $msg = $BTNGo GUISetState(@SW_HIDE) EndSelect EndFunc ;=> _Animal
- 10 replies
-
stealth reacted to a post in a topic: 3.3.12 Pass Variable of Last Row in ColB to _Excel_RangeRead
-
@error 3 @extended -2147352567 $LNC = $oWorkbook.ActiveSheet.Range("B65535").End($xlUp).Row ;dims last row in Excel Col B Msgbox(0, "last row", $LNC) Correctly returns value of the last Cell in Column B. However, I'd like to pass the cell address as a variable to _Excel_RangeRead and that's where I'm stuck.
-
While using 3.3.8, this worked fine: Local $fFile = "C:\Users\" & @UserName & "\Documents\test.xlsx" If Not FileExists($fFile) Then MsgBox(0, "Excel File Test", "Can't run this script b/c you don't have " & @CRLF & $fFile & " open") Exit EndIf $oExcel = ObjGet("", "Excel.Application") ;Gets an existing Excel Object If @error Then ;Error traps if Excel file is not open MsgBox(0, "ExcelFileTest", "You don't have Excel running at this moment. Error code: " & Hex(@error, 8)) Exit EndIf $oExcelDoc = ObjGet($fFile) ;Get an Excel Object from an existing filename $dDdoc = $oExcel.Sheets("Sheet1") ;dim the Workbook's sheet Global Const $xlUp = -4162 ;global constant for Excel up, finding last row $LNC = $oExcel.Sheets("Sheet1").Range("B65535").End($xlUp).Row ;dims last row in Excel Col B I'm unable to pass variable $LNC (last empty cell in ColumnB) to _Excel_RangeRead. What am I doing wrong? Is Global Const $xlUp = -4162 still valid in 3.3.12? $oAppl = _Excel_Open() $sWorkbook = "C:\Users\" & @UserName & "\Documentstest.xlsx" $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Dim $LNC Global Const $xlUp = -4162 ;global constant for Excel up, finding last row $LNC = $oWorkbook.ActiveSheet.Range("B65535").End($xlUp).Row ;dims last row in Excel Col B $sResult = _Excel_RangeRead($oWorkbook, Default, $LNC, 1) MsgBox(0, "last row", $sResult) Thank you in advance.
-
Re-Arrange Excel Cells(cut and paste) HELP
stealth replied to johnsonaaronemt's topic in AutoIt General Help and Support
Does the first record begin in Cell A1? Do all of the records begin in Column A? Are the records consistent (take up the same number of columns)? Also, are you doing anything else with the data (using other applications)? If you're just working in excel, you could write and run an Excel macro. For excel macros, try: http://www.ozgrid.com/forum/forumdisplay.php?f=8 -
More elegant/effective way to use Select/Case
stealth replied to stealth's topic in AutoIt General Help and Support
Thank you, both! -
More elegant/effective way to use Select/Case
stealth replied to stealth's topic in AutoIt General Help and Support
JohnOne, I have two more questions. How come there is no need to include $PKG these two lines? Switch _Select($Loose, $CRTN) and Func _Select($Loose, $CRTN) Also, how do I place the function out of the way of the main body of the script? For example: $Loose = MsgBox(4, "Loose?", "Are the cartons on a skid?") $CRTN = 1 $PKG = 1 code code ;send carton and skid count to Notepad _Select($Loose,$CRTN) code code Msgbox(0,"Done","Finished!") WinActivate("Untitled - Notepad") Switch _Select($Loose, $CRTN) Case 1 Send($CRTN & " LOOSE CARTON") Case 2 Send($CRTN & " LOOSE CARTONS") Case 3 Send($CRTN & " CARTON ON " & $PKG & " SKID") Case 4 Send($CRTN & " CARTONS ON " & $PKG & " SKID") Case 5 Send($CRTN & " CARTONS ON " & $PKG & " SKIDS") EndSwitch Func _Select($Loose, $CRTN) Select Case $Loose = 7 And $CRTN = 1 Return 1 Case $Loose = 7 And $CRTN > 1 Return 2 Case $Loose = 6 And $CRTN = 1 And $PKG = 1 Return 3 Case $Loose = 6 And $CRTN > 1 And $PKG = 1 Return 4 Case $Loose = 6 And $CRTN > 1 And $PKG > 1 Return 5 EndSelect EndFunc ;==>_Select