Jump to content

Leaderboard

Popular Content

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

  1. Found a visual basic script online which searches for, downloads, and installs all available Windows updates available for the current operating system. It also lets you choose the "source" you obtain the updates from. I wanted to convert it over to autoit and share, as this was the only missing piece in my automated os deployment script, which is now complete.. Note that you will need attached udf for script to work. The original vbscript can be found here. All credit goes to author of original script. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.15.0 (Beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ;ServerSelection values #include <console.au3> $ssDefault = 0 $ssManagedServer = 1 $ssWindowsUpdate = 2 $ssOthers = 3 $intSearchStartChar = 1 Local $strTitle Cout ( "searching for updates..." & @CRLF ) $updateSession = ObjCreate("Microsoft.Update.Session") $updateSearcher = $updateSession.CreateupdateSearcher() $updateSearcher.ServerSelection = $ssWindowsUpdate $searchResult = $updateSearcher.Search("IsInstalled=0 and Type='Software'") cout ( "List of applicable items on the machine:" & @CRLF & @CRLF ) For $i = 0 to Int ( $searchResult.Updates.Count ) - 1 Step 1 $update = $searchResult.Updates.Item($i) cout ( ( $i + 1 ) & ". " & $update.Title & @CRLF ) Next If Int ( $searchResult.Updates.Count ) = 0 Then cout ( "There are no applicable updates." & @CRLF ) Exit EndIf cout ( "Creating collection of updates to download:" & @CRLF & @CRLF ) $updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl") For $i = 0 to Int ( $searchResult.Updates.Count ) - 1 Step 1 $update = $searchResult.Updates.Item($i) $addThisUpdate = false If $update.InstallationBehavior.CanRequestUserInput = true Then cout ( $i + 1 & ". skipping: " & $update.Title & " because it requires user input" & @CRLF ) Else If $update.EulaAccepted = false Then $update.AcceptEula() $addThisUpdate = true Else $addThisUpdate = True EndIf EndIf If $addThisUpdate = true Then cout ( ( $i + 1 ) & ". adding: " & $update.Title & @CRLF ) $updatesToDownload.Add($update) EndIf Next If $updatesToDownload.Count = 0 Then cout ( "All updates were skipped" & @CRLF ) Exit EndIf Cout ( "Would you like to download available updates? (Y/N)" & @CRLF ) $input2 = Getch () If $input2 <> "y" And $input2 <> "Y" Then Cout ( "Either invalid input was entered or you chose not to install. Exiting.." & @CRLF ) Exit Else cout ( "Downloading updates..." & @CRLF ) $downloader = $updateSession.CreateUpdateDownloader() $downloader.Updates = $updatesToDownload $downloader.Download() $updatesToInstall = ObjCreate ("Microsoft.Update.UpdateColl") $rebootMayBeRequired = false cout ( "Successfully downloaded updates:" & @CRLF & @CRLF ) For $i = 0 to Int ( $searchResult.Updates.Count ) - 1 Step 1 $update = $searchResult.Updates.Item($i) If $update.IsDownloaded = true Then cout ( ( $i + 1 ) & ". " & $update.Title & @CRLF ) $updatesToInstall.Add($update) If Int ( $update.InstallationBehavior.RebootBehavior ) > 0 Then $rebootMayBeRequired = true EndIf EndIf Next If $updatesToInstall.Count = 0 Then cout ( "No updates were successfully downloaded." & @CRLF ) Exit EndIf If $rebootMayBeRequired = true Then cout ( "These updates may require a reboot." & @CRLF ) EndIf Cout ( "Would you like to install updates now? (Y/N)" & @CRLF ) $input = Getch ( ) If $input <> "y" And $input <> "Y" Then Cout ( "Either invalid input was entered or you chose not to install. Exiting.." & @CRLF ) Exit Else Cout ( "Installing updates..." & @CRLF ) $installer = $updateSession.CreateUpdateInstaller() $installer.Updates = $updatesToInstall $installationResult = $installer.Install() cout ( "Installation Result: " & $installationResult.ResultCode & @CRLF ) Cout ( "Reboot Required: " & $installationResult.RebootRequired & @CRLF ) Cout ( "Listing of updates installed and individual installation results:" & @CRLF & @CRLF ) For $i = 0 to Int ( $updatesToInstall.Count ) - 1 step 1 Cout ( ( $i + 1 ) & ". " & $updatesToInstall.Item($i).Title & ": " & $installationResult.GetUpdateResult($i).ResultCode & @CRLF ) Next EndIf EndIf Console.au3
    1 point
  2. try for example #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Global $hGraphic, $hPen $hGUI = GUICreate("GDI+", 400, 300) _GDIPlus_Startup() Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hPen = _GDIPlus_PenCreate() OnAutoItExitRegister("_On_Exit") $hTab = GUICtrlCreateTab(20, 10, 350, 280) GUICtrlCreateTabItem("tabitem0") GUICtrlCreateLabel("Test0", 100, 100) GUICtrlCreateTabItem("tabitem1") GUICtrlCreateLabel("Test1", 200, 200) GUISetState() _Drawline() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $hTab If GUICtrlRead($hTab) = 0 Then _Drawline() Else _WinAPI_InvalidateRect($hGUI) EndIf Case $GUI_EVENT_RESTORE If GUICtrlRead($hTab) = 0 Then _Drawline() EndSwitch WEnd Exit Func _Drawline() _GDIPlus_GraphicsDrawLine($hGraphic, 25, 150, 300, 120, $hPen) EndFunc ;==>_Drawline Func _On_Exit() _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>_On_Exit
    1 point
  3. @augumentum: excellent work! It worked like you indicated it would. And by changing one statement, I was able to have a colored backdrop for the PNGs, which was something I was hoping for. _WinAPI_SetLayeredWindowAttributes( $hGUI, 0xABCDEe, 255 ) Granted, I haven't fully explored things in the context of a real application—like having text and JPGs on the layout—but it's a great start. Thanks for posting.
    1 point
  4. Melba23

    Sort by date and type

    rahulsics, The function is indeed slow if you have an extensive folder structure - but you can speed it up by using a negative value for the $iRecur parameter which limits the search to a fixed level below the root. That might speed things up considerably. Without sight of the directory structure it is hard to offer more than such general guidance, but you could do something like this: Search the root folder for just the folders it contains (use the $FLTAR_FOLDERS parameter to do this) Get the date/time of those folders as I described above and sort the array so as to get the latest folders at the top Loop through those first few folders and search for your file within them (using as specific a mask as possible and the $FLTAR_FILES parameter) - you can combine the returned arrays using _ArrayConcatenate. And now you have an array of the instances of your file in only those folders. Give it a go and come back if you run into problems M23
    1 point
  5. @RTFC : with or without the redirection, the System directory is always c:\windows\system32. With a 32 bits script, you can use $FOLDERID_SystemX86 the get x86 system path. But in this case, $FOLDERID_System returns the desired value
    1 point
  6. smartbear is kind of expensive, but just to try and see if I can find it will be great. tnx again
    1 point
  7. For UIAutomation: Inspect from Windows Development Kit and Simple Spy supplied in @junkew's wrapper.
    1 point
  8. @Earthshine UIAutomation might be a more universal alternative for automating GUIs:
    1 point
  9. BrewManNH

    lisview

    Pays me to read the help file myself, should have just the -1 myself.
    1 point
  10. I think i am lucky enough to answer my question. I found a remedy. When you creating controls, write them orderly. Which will give you a tab order.
    1 point
  11. You can with a combination: Use FileInstall to include the file with your executable, then embed it.
    1 point
  12. Melba23

    Sort by date and type

    rahulsics, Welcome to the AutoIt forums. My answer is much as above - except that the functions required are now in the standard include set. Use _FileListToArrayRec to get an array of the required files - you can get them sorted automatically using the $FLTAR_SORT flag. Have a go at coding something yourself and post again if you have problems. M23
    1 point
  13. My computer has been upgraded from Office 2010 to Office 2016. Are there any features of Office 2013 or Office 2016 which you now want to see in the Excel, Word or Outlook UDF?
    1 point
  14. Jos

    How to use FileInstall()

    no worries
    1 point
  15. The explanation on this thread was the clearest at least to me, and I hope it can help someone else. Simple, i am not looking for any trouble, let me know if i should remove it ?
    1 point
  16. UEZ

    GDI+ Image in a Tab Control

    I would do it rather this way: #include <GUIConstantsEx.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Global $NavigationBar _CreateGui() Func _CreateGUI() _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\FF.png") ;<-- your image $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) $MainGUI = GuiCreate("Test GUI", 1000, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $NavigationBar = GuiCtrlCreateTab(20, 10, 960, 480) GUICtrlSetOnEvent(-1, "_NavigationCheck") $GlossaryTab = GuiCtrlCreateTabItem("Glossary") $iPic = GUICtrlCreatePic("", 80, 200, $iWidth, $iHeight) $Item1Tab = GuiCtrlCreateTabItem("Tab 2") GuiCtrlCreateLabel("Test", 200, 200) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject($hGDIBitmap) _GDIPlus_Shutdown() GuiSetState() EndFunc Func _NavigationCheck() $ReadNavigationBar = GUiCtrlRead($NavigationBar) ; Do other stuff if need be later EndFunc Func _Exit() Exit EndFunc While 1 Sleep(10) WEnd Otherwise image will be erased when switching the tabs, GUI is minimized/restored again or GUI will be moved partial outside the screen borders.
    1 point
×
×
  • Create New...