Jump to content

picaxe

Active Members
  • Posts

    473
  • Joined

  • Last visited

Recent Profile Visitors

419 profile views

picaxe's Achievements

Universalist

Universalist (7/7)

2

Reputation

  1. One way;Opt("GUIOnEventMode", 1) If _IsOnEvent() Then $sState = "On" Else $sState = "Off" EndIf ConsoleWrite("Event Mode is " & $sState & @LF) Func _IsOnEvent() $iOnEvent = Opt("GUIOnEventMode", 1) Opt("GUIOnEventMode", $iOnEvent) Return $iOnEvent EndFunc
  2. Correct, AutoIt help says "The control must be in icon or small icon view mode". This works for me #include <GUIListView.au3> #include <GUIImageList.au3> $hGUI = GUICreate("") $hGUIListView = _GUICtrlListView_Create($hGUI, "", 0, 0, 212, 300, BitOR($LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SMALLICON));$LVS_LIST)) $hImageList = _GUIImageList_Create(24, 24, 5) _GUIImageList_AddIcon($hImageList, @ProgramFilesDir & "\AutoIt3\Icons\au3script_v9.ico", 0, True) _GUICtrlListView_SetImageList($hGUIListView, $hImageList, 1) _GUICtrlListView_AddItem($hGUIListView, "1", 0) _GUICtrlListView_AddItem($hGUIListView, "2", 0) _GUICtrlListView_AddItem($hGUIListView, "3", 0) GUISetState() _GUICtrlListView_SetItemPosition($hGUIListView, 0, 25, 80) While 1 If GUIGetMsg() = -3 Then Exit WEnd
  3. #include <Excel.au3> $oExcel = _ExcelBookNew() For $i = 1 To 3 _ExcelSheetAddNew($oExcel, "S" & $i) Next ConsoleWrite("return=" & _ExcelSheetAddAfter($oExcel, "S2", "Add After S2") & " @error=" & @error & @LF) ConsoleWrite("return=" & _ExcelSheetAddAfter($oExcel) & " @error=" & @error & @LF) ConsoleWrite("return=" & _ExcelSheetAddAfter($oExcel, "", "Add After Last") & " @error=" & @error & @LF) ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExcelSheetAddAfter ; Description ...: Add a new sheet (optionally with a name) to a workbook after a named sheet. ; Syntax.........: _ExcelSheetAddAfter($oExcel [, $sAfterSheet = "" [, $sNewSheetName = ""]]) ; Parameters ....: $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew() ; $sAfterSheet - Name of the sheet after which a new sheet will be added, add to end if not supplied ; $sNewSheetName - Name of the added new sheet, use default name if none supplied ; Return values .: Success - Returns 1 ; Failure - Returns 0 and sets @error on errors: ; @error=1 - Specified object does not exist ; @error=2 - $sAfterSheet name not found ; Author ........: picaxe ; Remarks .......: None ; =============================================================================================================================== Func _ExcelSheetAddAfter($oXl, $sAfterSheet = "", $sNewSheetName = "") If Not IsObj($oXl) Then Return SetError(1, 0, 0) Local $iSheetCount = $oXl.ActiveWorkbook.Sheets.Count If $sAfterSheet = "" Then $oXl.ActiveWorkBook.WorkSheets.Add(Default, $oXl.ActiveWorkbook.Sheets($iSheetCount)).Activate Else For $i = 1 To $iSheetCount If $oXl.ActiveWorkbook.Sheets($i).Name = $sAfterSheet Then $oXl.ActiveWorkBook.WorkSheets.Add(Default, $oXl.ActiveWorkbook.Sheets($i)).Activate ExitLoop EndIf Next If $i > $iSheetCount Then Return SetError(2, 0, 0) EndIf If $sNewSheetName <> "" Then $oXl.ActiveSheet.Name = $sNewSheetName Return 1 EndFunc
  4. Au3Info shows it is a listview, so try adapting this example.
  5. Const $xlByRows = 1 Const $xlByColumns = 2 Const $xlPrevious = 2 $oExcel = ObjCreate("Excel.Application") With $oExcel ; open new workbook .Visible = True .WorkBooks.Add .ActiveWorkbook.Sheets(1).Select() $oSheet = .ActiveSheet $iStart = Random(1, 19, 1) $iEnd = Random(20, 49, 1) For $i = $iStart To $iEnd $oSheet.Cells($i, 1).Value = Random(1, 100000, 1) Next $iStart = Random(50, 69, 1) $iEnd = Random(70, 100, 1) For $i = $iStart To $iEnd $oSheet.Cells($i, 1).Value = Random(1, 100000, 1) Next EndWith $iLastRow = $oSheet.Cells.Find('*', $oSheet.Cells(1, 1), Default, Default, $xlByRows, $xlPrevious).Row $oSheet.Cells(3, 3).Value = "Last non empty row = " & $iLastRow
  6. RotateDisplay() ; rotate 90 deg Sleep(3000) RotateDisplay(1, 0) ; restore Func RotateDisplay($iDisplayNumber = 1, $iRotate = 90) Run("rundll32.exe NvCpl.dll,dtcfg rotate " & $iDisplayNumber & " " & $iRotate) If @error Then Return SetError(1, 0, 0) EndFunc
  7. The problem is reusing the array $filelist in a For In Next statement, because of the read only limitation. Whereas For To Next is Ok.
  8. You can read but not update/create an array inside a For In Next statement.
  9. If problem is not as suggested by Melba23. Try this
  10. #include <GuiListView.au3> $sDelim = "|" $hListview = ControlGetHandle("µTorrent 2.0.2", "", "[CLASS:SysListView32; INSTANCE:2]") $sItems = "" For $i = 0 To _GUICtrlListView_GetItemCount($hListview) - 1 For $j = 0 To _GUICtrlListView_GetColumnCount($hListview) - 1 $sItems &= _GUICtrlListView_GetItemText($hListview, $i, $j) & $sDelim Next $sItems = StringTrimRight($sItems, 1) & @CRLF Next ConsoleWrite($sItems)
  11. This works for me on Excel 2003, WinXP$eObj = _ExcelBookAttach($myfilepath) $eObj.Sheets($mySheet).Select()
  12. #include <GUIConstants.au3> #include <GUIEdit.au3> $gui = GUICreate('', 200, 120) $edit = GUICtrlCreateEdit('This is a string. This is a string', 0, 0, 200, 80) ;~ $button1 = GUICtrlCreateButton('Test 1', 0, 80, 100, 20) ;~ $button2 = GUICtrlCreateButton('Test 2', 100, 80, 100, 20) $label = GUICtrlCreateLabel('', 0, 100, 200, 20) GUISetState() Opt("CaretCoordMode", 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop ;~ Case $button1 ;~ GUICtrlSetState($edit, $GUI_FOCUS) ;~ _GUICtrlEdit_SetSel($edit, 5, 9) ;~ $aSel = _GUICtrlEdit_GetSel($edit) ;~ GUICtrlSetData($label, 'Selection is: ' & $aSel[0] & ' to ' & $aSel[1] & ' Active: ' & Active()) ;~ Case $button2 ;~ GUICtrlSetState($edit, $GUI_FOCUS) ;~ _GUICtrlEdit_SetSel($edit, 9, 5) ;~ $aSel = _GUICtrlEdit_GetSel($edit) ;~ GUICtrlSetData($label, 'Selection is: ' & $aSel[0] & ' to ' & $aSel[1] & ' Active: ' & Active()) EndSwitch $aSel = _GUICtrlEdit_GetSel($edit) If $aSel[0] <> $aSel[1] Then GUICtrlSetData($label, 'Selection is: ' & $aSel[0] & ' to ' & $aSel[1] & ' Active: ' & Active()) Else GUICtrlSetData($label, '') EndIf Sleep(50) WEnd Func Active() ;$iOpt = Opt("CaretCoordMode", 0) $aCaret = WinGetCaretPos() ;$iErrSav = @error ;Opt("CaretCoordMode", $iOpt) If @error Then Return SetError(1, 0, -1) $aPos = _GUICtrlEdit_CharFromPos($edit, $aCaret[0], $aCaret[1]) Return $aPos[0] EndFunc ;==>Active
×
×
  • Create New...