Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/08/2018 in all areas

  1. #include <Array.au3> Local $aArray_Base[15][20] For $i = 0 To 14 For $j = 0 To 19 $aArray_Base[$i][$j] = $i & "-" & $j Next Next _ArrayDisplay ($aArray_Base, "before") _ArrayColInsert ($aArray_Base, 3) For $i = 0 to 14 $aArray_Base[$i][3] = $aArray_Base[$i][15] Next _ArrayColDelete ($aArray_Base, 15) _ArrayDisplay ($aArray_Base, "after")
    1 point
  2. Your code is really pretty messed up as far as logic is concerned. Have a look at this version and see if that is what you like to do: #include <Misc.au3>; include statements To handdel basic input functions #include <MsgBoxConstants.au3>; include statement To use message box object #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 254, 233, 516, 270) $List1 = GUICtrlCreateList("", 16, 8, 217, 149, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) ; BitOR style taken from help file $sItems = "+|-|*|/" GUICtrlSetData($List1, $sItems) _GUICtrlListBox_SetSel($List1, 1) ; Set position 1 (which is the 2nd in list) as default $Button1 = GUICtrlCreateButton("Select", 80, 176, 75, 25) GUISetState(@SW_SHOW) $selItems = _GUICtrlListBox_GetSelItemsText($sItems) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 Switch GUICtrlRead($List1) Case "+" MsgBox(0, "You choose:", "+") Case "-" MsgBox(0, "You choose:", "-") Case "*" MsgBox(0, "You choose", "*") Case "/" MsgBox(0, "You choose", "/") EndSwitch EndSwitch WEnd Jos
    1 point
  3. See water has already replied, but was going to say the same thing, use the array data than _Excel_RangeRead within a loop something like the following: #include <Array.au3> #include <Excel.au3> Local $sWorkbook = @ScriptDir & "\Timesheets.xls" Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) Local $aWorkbook = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:AU")) _ArrayDelete($aWorkbook, "0-4") For $i = 0 To UBound($aWorkbook) - 1 ConsoleWrite("Column A: " & $aWorkBook[$i][0] & @CRLF) Next _ArrayDisplay($aWorkbook)
    1 point
  4. To edit your own posts you have to have at least a post count of 5.
    1 point
  5. iamtheky

    Script Questions

    how is this script getting to the users computer to even run the fileexists command successfully? using fileinstall and blowing up the size of the compiled executable is an option (so all possible packages are local), but if it has to go over the same pipe you have just moved the wait time to this transfer rather than as a result of the script calling packages from network resources.
    1 point
  6. Just edit your post and use the <> in the toolbar
    1 point
  7. Subz

    Script Questions

    If you want a cheap option I would recommend using PDQ Deploy or Lansweeper, both can deploy software and run scripts from a centralized repository and very inexpensive. Alternatively just create a network share which the users have read/execute rights and have the users run the installer from the share, if the installers are all msi based you could also use Group Policy although not sure if your machines are in a domain or a workgroup. Don't really see any advantages with copying files locally and than installing unless other computers have slow links.
    1 point
  8. _ArrayDisplay displays arrays, Msgbox displays strings So to display ALL the sorted numbers in a Msgbox you have to use _ArrayToString
    1 point
  9. Something like this (I know it is not 100% what you expect - but it runs without errors): #include <Array.au3> #include <INet.au3> #include <File.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <string.au3> #include <File.au3> #include <Excel.au3> #include <Date.au3> #include-once ; #include <ExcelChart.au3> Local $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Global Const $xlDouble = -4119 ; Double line. Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "ID", "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Name", "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Company", "C1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Laptop", "D1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "SerialNumber", "E1") For $i = 1 To 10 Step 1 _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "00" & $i, "A" & $i) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Name0" & $i, "B" & $i) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Scania", "C" & $i) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Dell", "D" & $i) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "W2314" & $i, "E" & $i) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "=SUMME(20 / " & $i & ")", "F" & $i) Next With $oExcel.ActiveWorkbook.Sheets(1) .Range("A:E").Font.Color = 0x111111 .Range("A:E").Font.Size = 9 .Range("A:M").Font.Name = "Arial" .Range("A1:F10").Borders.LineStyle = $xlDouble EndWith ; ###################################################################################################################### ; ADD CONDITIONAL FORMATTING ; ###################################################################################################################### Local $xl3Arrows = 1 Local $xlCellValue = 1 Local $xl5Arrows = 13 Local $xlConditionValueNumber = 0 $oIconSet = $oExcel.ActiveWorkbook.Sheets(1).Range("F1:F10").FormatConditions.AddIconSetCondition $oIconSet.IconSet = $oExcel.ActiveWorkbook.IconSets($xl3Arrows) $oIconCriterion = $oIconSet.IconCriteria(2) $oIconCriterion.Type = $xlConditionValueNumber $oIconCriterion.Value = 15 $oIconCriterion.Operator = $xlGreaterEqual ; Retrieve information about each IconCriteria For $oIconCriterion In $oIconSet.IconCriteria ConsoleWrite($oIconCriterion.Type & "-" & $oIconCriterion.Value & "-" & $oIconCriterion.Operator & @CRLF) Next Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
    1 point
  10. I'm very, very, very, experienced, and I'm sill making stupid things. But the most important thing is to : "Stop making the same mistakes or be creative - make new mistakes."
    1 point
  11. mLipok

    Error Handling Help

    @BatMan22 take a look also here: https://www.autoitscript.com/wiki/User_Defined_Functions#Script_Coding.2FAnalyzing.2FDebugging cDebug (by c.haslam) - Dumps the values of all AutoIt subtypes and expressions including nested arrays, DLL structs and maps. ErrorLog (by mLipok) - Logs program activities and errors to different output locations. Log4a (by zorphnog) - Logging library loosely based upon the log4j and NLog libaries. Loga (by Danyfirex) - Simple logging library to keep track of code with an integrated console. and focus on examples, like here:
    1 point
  12. @BatMan22 Check these links: Function Notes; COM Reference; A good example made by @water.
    1 point
  13. mLipok

    Error Handling Help

    Try to use: COM error handling is related to COM/ActiveX Objects not to COM ports. Using COM error Handler in Global Scope is'not stupid thing, provided you do not want to use a more advanced "Local" form.
    1 point
  14. Example: You define a global COM error handler to grab all COM errors occurring in the main script. A local COM error handler grabs all COM errors occurring inside a function. When the function ends the local COM error handler is dropped and the global COM error handler is active again. Global $oGlobalCOMErrorHandler = ObjEvent("AutoIt.Error", "_ErrFuncGlobal") ; Global COM error handler Global $oIE = ObjCreate("InternetExplorer.Application") $oIE.xyz FunctionLocal() $oIE.xyz Exit Func FunctionLocal() Local $oLocalCOMErrorHandler = ObjEvent("AutoIt.Error", "_ErrFuncLocal") ; Local COM error handler $oIE.xyz EndFunc ; Global COM error handler Func _ErrFuncGlobal($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> Global COM error handler - COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc ; Local COM error handler Func _ErrFuncLocal($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> Local COM error handler - COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
    1 point
  15. Hi Guys, When I used to scratch the surface with Delphi5, I could only create a simple Notepad program. Now that I'm into AutoIt, I've created just a bare bone Notepad. Can be improved, but maybe this will be useful for those, like me, starting out with programming. I know there are way better notepads out there like Aupad, but, #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <APIDlgConstants.au3> #include <Memory.au3> #include <WinAPIDlg.au3> #include <WinAPIFiles.au3> Opt('WinTitleMatchMode', 3) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Notepad", 620, 440, 192, 124) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem4 = GUICtrlCreateMenuItem("New" & @TAB & "Ctrl+N", $MenuItem1) $MenuItem5 = GUICtrlCreateMenuItem("Open" & @TAB & "Ctrl+O", $MenuItem1) $MenuItem6 = GUICtrlCreateMenuItem("Save" & @TAB & "Ctrl+S", $MenuItem1) $MenuItem17 = GUICtrlCreateMenuItem("Print" & @TAB & "Ctrl+P", $MenuItem1) $MenuItem7 = GUICtrlCreateMenuItem("Exit" & @TAB & "Ctrl+W", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("Edit") $MenuItem8 = GUICtrlCreateMenuItem("Undo" & @TAB & "Ctrl+Z", $MenuItem2) $MenuItem9 = GUICtrlCreateMenuItem("Cut" & @TAB & "Ctrl+X", $MenuItem2) $MenuItem10 = GUICtrlCreateMenuItem("Copy" & @TAB & "Ctrl+C", $MenuItem2) $MenuItem11 = GUICtrlCreateMenuItem("Paste" & @TAB & "Ctrl+V", $MenuItem2) $MenuItem12 = GUICtrlCreateMenuItem("Delete" & @TAB & "Del", $MenuItem2) $MenuItem16 = GUICtrlCreateMenu("Format") $MenuItem19 = GUICtrlCreateMenuItem("Word Wrap", $MenuItem16) $MenuItem18 = GUICtrlCreateMenuItem("Font", $MenuItem16) $MenuItem15 = GUICtrlCreateMenu("View") $MenuItem20 = GUICtrlCreateMenuItem("Status Bar", $MenuItem15) $MenuItem3 = GUICtrlCreateMenu("Help") $MenuItem13 = GUICtrlCreateMenuItem("View Help", $MenuItem3) $MenuItem14 = GUICtrlCreateMenuItem("About Notepad" & @TAB & "F1", $MenuItem3) $Edit1 = GUICtrlCreateEdit("", 0, 0, 620, 420, $ES_WANTRETURN) GUICtrlSetFont($Edit1, 10, 400, -1, "Lucida Console") GUICtrlSetData(-1, "") Dim $Form1_AccelTable[11][2] = [["^n", $MenuItem4], ["^o", $MenuItem5], ["^s", $MenuItem6], ["^p", $MenuItem17], ["^w", $MenuItem7], ["^z", $MenuItem8], ["^x", $MenuItem9], ["^c", $MenuItem10], ["^v", $MenuItem11], ["{DEL}", $MenuItem12], ["{F1}", $MenuItem14]] GUISetAccelerators($Form1_AccelTable) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Warning If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52, "Notepad Closing", "Are you sure you want to exit?") Select Case $iMsgBoxAnswer = 6 ;Yes Exit Case $iMsgBoxAnswer = 7 ;No EndSelect #EndRegion --- CodeWizard generated code Start --- Case $MenuItem4 GUICtrlSetData($Edit1, "") Case $MenuItem5 FileOpenDialog("Open Text File", @DesktopDir, "Text File (*.txt)") Case $MenuItem6 $filesave = FileSaveDialog("Save Text File", @DesktopDir, "Text File (*.txt)") $Edit1_Read = GUICtrlRead($Edit1) FileWrite($filesave, $Edit1_Read) Case $MenuItem7 #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Warning If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52, "Notepad Closing", "Are you sure you want to exit?") Select Case $iMsgBoxAnswer = 6 ;Yes Exit Case $iMsgBoxAnswer = 7 ;No EndSelect #EndRegion --- CodeWizard generated code Start --- EndSwitch WEnd If you don't attempt something, you never know you can actually achieve that goal.
    1 point
  16. i found a workaround, that works for me: #include <IE.au3> Global $oIE = _IECreate("about:blank") Global $eval = 0 $oIE.Document.parentWindow.execScript("document.body.oAutoIt = eval;") $eval = Execute("$oIE.Document.body.oAutoIt") If IsObj($eval) Then MsgBox(0, "eval", $eval('typeof "str"'));execute js and get return $eval("alert('test');") EndIf hope it's useful to someone
    1 point
  17. trancexx

    HTML editor

    Here it is HTML Editor.zip Unzip the folder, save and run. ...I was greenish.
    1 point
  18. runsnake, Try running this: #include <File.au3> ; Get path to Autoit installed icons $sIconPath = StringReplace(@AutoItExe, "AutoIt3.exe", "Icons\") ; List icons $aIcon_List = _FileListToArray($sIconPath, "*.ico", 1) ; Loop through the icon list For $i = 1 To $aIcon_List[0] ; Allow time to see the icon Sleep(2000) ; Change the icon TraySetIcon($sIconPath & $aIcon_List[$i]) Next Clearer now? M23
    1 point
  19. Melba23

    Keyloggers

    Previously when code which was (or could very easily be converted to) a keylogger has appeared on the forum I have limited my actions to deleting the code and warning the poster. I even went to the trouble to post the above announcement so there could be no doubt as to the fact that such code was not permitted here. Yesterday I had to remove code which checked the entire keyboard and lit up the pressed key on a "virtual keyboard" GUI. Note that the post above talks of "code which checks for the best part of the keyboard" - that is exactly what this code did and with the addition of a few lines it could easily have been turned into a crude, but entirely workable, keylogger. The poster is now enjoying a short holiday - and the same fate awaits anyone else who posts similar code in future. The prohibitions in the Forum rules are there to keep this forum clean and to protect the reputation of AutoIt - which is in the interests of us all. Please use your brains and do not post code which flouts the spirit, if not the exact letter, of the rules. If you do then do not complain if you are moderated and warned. M23
    1 point
  20. I grabbed this somewhere in the forum, dont remember where CODE #include <GDIPlus.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() ;$hGUI = GUICreate("Screen Capture", 400, 300, @DesktopWidth, @DesktopHeight) ;GUISetState() $hGUI = WinGetHandle("AutoIt Help") WinMove($hGUI, "", @DesktopWidth, @DesktopHeight) $iWidth = _WinAPI_GetWindowWidth($hGUI) $iHeight = _WinAPI_GetWindowHeight($hGUI) $hParent = GUICreate("WindowViewer", 500, 400) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hParent) GUISetState() While 1 $hBMP = _WinCapture($hGUI, $iWidth, $iHeight) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight, 50, 50, 400, 300) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBMP) Sleep(1000) WEnd Func _WinCapture($hWnd, $iWidth = -1, $iHeight = -1) Local $iH, $iW, $hDDC, $hCDC, $hBMP If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0) ;_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, 0, 0, 0x00330008) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) ;_ScreenCapture_SaveImage(@DesktopDir&"\window.jpg", $hBMP) ;_WinAPI_DeleteObject($hBMP) Return $hBMP EndFunc ;==>_WinCapture
    1 point
  21. trids

    Nirsoft

    Nirsoft has freeware utilities galore, most with commandline interfaces. There is too much to list here, and it's really worth a visit. Extremely cool site offering lots of goodies to script with All of them powerful + free + tiny (no installs needed)
    1 point
×
×
  • Create New...