Skip to content

Commit

Permalink
Merge v1.4.0 release
Browse files Browse the repository at this point in the history
Merge v1.4.0 release
  • Loading branch information
htcfreek committed Dec 26, 2022
2 parents bf01e99 + 0c57d78 commit be2a40b
Show file tree
Hide file tree
Showing 12 changed files with 471 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ This repository contains useful AutoIT-Scripts.

### Scripts:
```
/src/GetDiskInfoFromWmi : Function to read the disk information form WMI.
/src/GetDiskInfoFromWmi : Function to read the disk information form WMI.
/src/GetInstalledPrinterFromWmi : Function to get a list of installed printers for the current user as array or string.
/src/StatusSplashWindow : Shows a custom status window with progress, description and some nice control features.
/src/WaitForAppWindow : Function to wait for a new window opened by a specified process.
```

## Download
Expand Down
6 changes: 5 additions & 1 deletion src/GetDiskInfoFromWmi/Readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
**********************************************************************
* Name: _GetDiskInfoFromWmi *
* Name: _GetDiskInfoFromWmi *
* Description: Returns disk and partition information from WMI. *
* Author: htcfreek (Heiko) - https://github.com/htcfreek [original] *
**********************************************************************
Expand All @@ -9,6 +9,10 @@ Detailed description:
This function generates two arrays conatining the list of all disks on this computer and all partitions on this computer. The arrays are returned using the output parameters of the function.
There are two more fucntion parameters you can use to control the output: One to decide if the array tables should have a header line and one to control which types of disks are returned.

Function:
---------
_GetDiskInfoFromWmi ( ByRef $aDiskList , ByRef $aPartitionList [, $bAddTableHeader = $DiskInfoWmi_TableHeader_Yes [, $sFilterDiskType = $DiskInfoWmi_DiskType_All]] )

Parameters:
-----------
1. ByRef $aDiskList : Array variable for list of disks returned.
Expand Down
76 changes: 76 additions & 0 deletions src/GetInstalledPrinterFromWmi/GetInstalledPrinterFromWmi.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
; Includes
;----------
#include-once



#cs
===============================================================================================================================
Title ...............: _GetInstalledPrinterFromWmi (GitHub: https://github.com/htcfreek/AutoIt-Scripts)
Version .............: 1.0
License .............: GNU LGPLv3
AutoIt Version ......: 3.3.14.5+
Language ............: English
Description .........: Returns a list of installed printers for the current user as array or string. You can filter the list of printers.
Author ..............: htcfreek (Heiko) - https://github.com/htcfreek [original]
Modified ............:
Required includes ...:
Dll .................:
===============================================================================================================================
CHANGELOG:
2022-12-26 (v1.0)
New: Initial release
#ce



; Global constants
; -----------------
Global Const $InstalledPrinterWmi_ReturnType_Array = "A"
Global Const $InstalledPrinterWmi_ReturnType_String = "S"



; Function
; ---------
Func _GetInstalledPrinterFromWmi($sReturnType = $InstalledPrinterWmi_ReturnType_String, $sPrinterName = "*", $sStringSplitSign = ",")
; Name ...............: _GetInstalledPrinterFromWmi
; Author .............: htcfreek (Heiko) - https://github.com/htcfreek
; Input parameter ....: [$sReturnType = $InstalledPrinterWmi_ReturnType_String] = The return type: Array or String (Possible values: $InstalledPrinterWmi_ReturnType_Array|$InstalledPrinterWmi_ReturnType_String)
; [$sPrinterName = "*"] = A string (Example: "HP*") to filter the printers by name. (You can use * as wildcard character.)
; [$sStringSplitSign = ","] = A sign used as delimiter when returning a string.
; Output .............: Printer list as array or string. If no printer was found, nothing is returned.
; On WMI-Error .......: @error = 1
; Tip ................: Even if you choose array as return type, it can help to change the String delimiter sign if you have problems with printers using that sign.


; Initialize function wide vars
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $sPrinterString

; WMI query and returning the results
Local $sFilter = StringReplace(" Where Name like '" & $sPrinterName & "'", "*", "%")
Local $oWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
If IsObj($oWMIService) And (Not @error) Then
Local $oPrinters = $oWMIService.ExecQuery("Select Name from Win32_Printer" & $sFilter, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If Not IsObj($oPrinters) Then Return
For $oPrinter In $oPrinters
$sPrinterString = $oPrinter.Name & $sStringSplitSign & $sPrinterString
Next
Switch $sReturnType
Case "A"
; Return array
Local $aPrinterArray = StringSplit(StringTrimRight($sPrinterString, 1), $sStringSplitSign, 2)
Return $aPrinterArray
Case "S"
; Return string
Return StringTrimRight($sPrinterString, 1)
EndSwitch
Else
; If WMI-Error then set @error
SetError(1)
EndIf
EndFunc ;==>_GetInstalledPrinterFromWmi
30 changes: 30 additions & 0 deletions src/GetInstalledPrinterFromWmi/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**********************************************************************************************
* Name: _GetInstalledPrinterFromWmi *
* Description: Returns a list of installed printers for the current user as array or string. *
* Author: htcfreek (Heiko) - https://github.com/htcfreek [original] *
**********************************************************************************************

Detailed description:
---------------------
This function returns a list of printers installed for the current user.
You can choose the return type (array or string), filter the list by printer name and change the delimiter sign used for the returned string list.
TIP: Even if you choose array as return type, it can help to change the String delimiter sign if you have problems with printers using that sign.

Function:
---------
_GetInstalledPrinterFromWmi ( [$sReturnType = $InstalledPrinterWmi_ReturnType_String [, $sPrinterName = "*" [, $sStringSplitSign = ","]]] )

Parameters:
-----------
1. $sReturnType (Optional, Default value = $InstalledPrinterWmi_ReturnType_String) : The return type: Array or String (Possible values: $InstalledPrinterWmi_ReturnType_Array|$InstalledPrinterWmi_ReturnType_String)
2. $sPrinterName (Optional, Default value = "*") : A string (Example: "HP*") to filter the printers by name. (You can use * as wildcard character.)
3. $sStringSplitSign (Optional, Default value = ",") : A sign used as delimiter when returning a string.


Output:
-------
The list of installed printers in the specified type or nothing.

Usage example:
--------------
See the file 'UsageExample.au3' in this directory.
33 changes: 33 additions & 0 deletions src/GetInstalledPrinterFromWmi/UsageExample.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "GetInstalledPrinterFromWmi.au3"
#include "Array.au3"


; Usage example 1
;-----------------
MsgBox (0, "Example 1", "No filter and return a string:")
$r1 = _GetInstalledPrinterFromWmi()
MsgBox (0, "Example 1 - Result", $r1)

; Usage example 2
;-----------------
MsgBox (0, "Example 2", "No filter and return a string with ; as delimiter:")
$r2 = _GetInstalledPrinterFromWmi($InstalledPrinterWmi_ReturnType_String,"*",";")
MsgBox (0, "Example 2 - Result", $r2)

; Usage example 3
;-----------------
MsgBox (0, "Example 3", "With filter 'Microsoft*' and return a string:")
$r3 = _GetInstalledPrinterFromWmi($InstalledPrinterWmi_ReturnType_String, "Microsoft*")
MsgBox (0, "Example 3 - Result", $r3)

; Usage example 4
;-----------------
MsgBox (0, "Example 4", "No filter and return an array:")
$r4 = _GetInstalledPrinterFromWmi($InstalledPrinterWmi_ReturnType_Array)
_ArrayDisplay ($r4, "Example 4 - Result")

; Usage example 5
;-----------------
MsgBox (0, "Example 5", "With filter '*Mi*' and return an array:")
$r5 = _GetInstalledPrinterFromWmi($InstalledPrinterWmi_ReturnType_Array, "*Mi*")
_ArrayDisplay ($r5, "Example 5 - Result")
5 changes: 4 additions & 1 deletion src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
This repository contains useful AutoIT-Scripts.

Scripts:
/src/GetDiskInfoFromWmi : Function to read the disk information form WMI.
/src/GetDiskInfoFromWmi : Function to read the disk information form WMI.
/src/GetInstalledPrinterFromWmi : Function to get a list of installed printers for the current user as array or string.
/src/StatusSplashWindow : Shows a custom status window with progress, description and some nice control features.
/src/WaitForAppWindow : Function to wait for a new window opened by a specified process.

Download:
Download the files form this page: http://github.com/htcfreek/AutoIT-Scripts/release/latest
Expand Down
30 changes: 30 additions & 0 deletions src/StatusSplashWindow/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
********************************************************************************************************
* Name: _StatusSplashWindow *
* Description: Shows a custom status window with progress, description and some nice control features. *
* Author: htcfreek (Heiko) - https://github.com/htcfreek [original] *
********************************************************************************************************

Detailed description:
---------------------
Shows a custom status window with progress, description and some nice control features.
You can call the function again to update the window or to close it.

Function:
---------
_StatusSplashWindow ( $iAction [, $sTxtMain = "" [, $iProgressType = "" [, $iProgressPercent = "" [, $sSplashWindowTitle = "" [, $iWindowPosition = $StatusSplashWindow_WindowPos_Top]]]]] )

Parameters:
-----------
1. $iAction : Action to do with the window or its controls. (Possible values: $StatusSplashWindow_Action_Show|$StatusSplashWindow_Action_Update|$StatusSplashWindow_Action_HideBar|$StatusSplashWindow_Action_DeleteWindow)
2. $sTxtMain (Optional, Default value = "") : Information / description text shown to the user.
3. $iProgressType (Optional, Default value = "") : Type of the progress bar. (Possible values: $StatusSplashWindow_ProgressType_Green|$StatusSplashWindow_ProgressType_Red|$StatusSplashWindow_ProgressType_Yellow|$StatusSplashWindow_ProgressType_Marquee)
4. $sSplashWindowTitle (Optional, Default value = "") : Titel of the window. (Required when calling the function for the first time.)
5. $iWindowPosition (Optional, Default value = $StatusSplashWindow_WindowPos_Top) : Position of the window. (Required when calling the function for the first time.; Possible values: $StatusSplashWindow_WindowPos_Center|$StatusSplashWindow_WindowPos_Top)

Output:
-------
The function has no return value or output.

Usage example:
--------------
See the file 'UsageExample.au3' in this directory.
129 changes: 129 additions & 0 deletions src/StatusSplashWindow/StatusSplashWindow.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
; Includes
;----------
#include-once
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>



#cs
===============================================================================================================================
Title ...............: _StatusSplashWindow (GitHub: https://github.com/htcfreek/AutoIt-Scripts)
Version .............: 1.0
License .............: GNU LGPLv3
AutoIt Version ......: 3.3.14.5+
Language ............: English
Description .........: Shows a custom status window with progress, desctiprion and some nice control features.
Author ..............: htcfreek (Heiko) - https://github.com/htcfreek [original]
Modified ............:
Required includes ...:
Dll .................:
===============================================================================================================================
CHANGELOG:
2022-12-26 (v1.0)
New: Initial release
#ce



; Global constants
; -----------------
Global Const $StatusSplashWindow_Action_Show = 0
Global Const $StatusSplashWindow_Action_Update = 1
Global Const $StatusSplashWindow_Action_HideBar = 2
Global Const $StatusSplashWindow_Action_DeleteWindow = -1

Global Const $StatusSplashWindow_ProgressType_Green = 1
Global Const $StatusSplashWindow_ProgressType_Red = 2
Global Const $StatusSplashWindow_ProgressType_Yellow = 3
Global Const $StatusSplashWindow_ProgressType_Marquee = 4

Global Const $StatusSplashWindow_WindowPos_Center = -1
Global Const $StatusSplashWindow_WindowPos_Top = 0



; Function
; ---------
Func _StatusSplashWindow($iAction, $sTxtMain = "", $iProgressType = "", $iProgressPercent = "", $sSplashWindowTitle = "", $iWindowPosition = $StatusSplashWindow_WindowPos_Top)
; Name ...............: _CustomMarqueeProgressWindow
; Author .............: htcfreek (Heiko) - https://github.com/htcfreek
; Input parameter ....: $iAction = Action to do with the window or its controls. (Possible values: $StatusSplashWindow_Action_Show|$StatusSplashWindow_Action_Update|$StatusSplashWindow_Action_HideBar|$StatusSplashWindow_Action_DeleteWindow)
; [$sTxtMain = ""] = Information / description text shown to the user.
; [$iProgressType = ""] = Type of the progress bar. (Possible values: $StatusSplashWindow_ProgressType_Green|$StatusSplashWindow_ProgressType_Red|$StatusSplashWindow_ProgressType_Yellow|$StatusSplashWindow_ProgressType_Marquee)
; [$sSplashWindowTitle = ""] = Titel of the window. (Required when calling the function for the first time.)
; [$iWindowPosition = $StatusSplashWindow_WindowPos_Top] = Position of the window. (Required when calling the function for the first time.; Possible values: $StatusSplashWindow_WindowPos_Center|$StatusSplashWindow_WindowPos_Top)
; Output .............: none


; Static Gui variables
Static $hProgressWindow
Static $idProgress
Static $idLabel


; Create Gui
If Not ($hProgressWindow) Then
$hProgressWindow = GUICreate($sSplashWindowTitle, 400, 80, -1, $iWindowPosition, BitOR($WS_POPUP, $WS_CAPTION, $WS_DISABLED), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetFont(11, 400, 0, "Arial")
;--
$idLabel = GUICtrlCreateLabel($sTxtMain, 20, 10, 360, 40, $SS_CENTER)
;--
if ($iProgressType = "" OR $iProgressType = $StatusSplashWindow_ProgressType_Marquee) Then
$idProgress = GUICtrlCreateProgress(20, 50, 360, 20, $PBS_MARQUEE, -1)
GUICtrlSendMsg($idProgress, $PBM_SETMARQUEE, 1, 50) ; Send the message $PBM_SETMARQUEE and wParam of 1 to start the scrolling marquee.
Else
$idProgress = GUICtrlCreateProgress(20, 50, 360, 20, 1, -1)
GUICtrlSetData($idProgress, $iProgressPercent)
EndIf
EndIf

;Show/Change/Delete Gui
Switch $iAction
Case -1
; Delet Gui
GUIDelete($hProgressWindow)
$hProgressWindow = Null
Case 0 To 2
; Show Gui
GUISetState(@SW_SHOW)
Switch $iAction
Case 0
; Show progress
GUICtrlSetState($idProgress, $GUI_SHOW)
Case 1
; Update properties
if ($sTxtMain <> "") Then
; Set text
GUICtrlSetData($idLabel, $sTxtMain)
EndIf
if ($iProgressType = $StatusSplashWindow_ProgressType_Green AND $iProgressPercent >= 0) Then
; Set green progress bar
GUICtrlSendMsg($idProgress, $PBM_SETMARQUEE, 0, 0)
GUICtrlSetStyle($idProgress, -1)
_SendMessage(GUICtrlGetHandle($idProgress), $PBM_SETSTATE, 1, 0)
GUICtrlSetData($idProgress, $iProgressPercent)
ElseIf ($iProgressType = $StatusSplashWindow_ProgressType_Marquee) Then
; Set marquee progress
_SendMessage(GUICtrlGetHandle($idProgress), $PBM_SETSTATE, 1, 0)
GUICtrlSetStyle($idProgress, $PBS_MARQUEE)
GUICtrlSendMsg($idProgress, $PBM_SETMARQUEE, 1, 50)
ElseIf ($iProgressType <> "" AND $iProgressPercent >= 0) Then
; Set colored progress
GUICtrlSendMsg($idProgress, $PBM_SETMARQUEE, 0, 50)
GUICtrlSetStyle($idProgress, 1)
_SendMessage(GUICtrlGetHandle($idProgress), $PBM_SETSTATE, 1, 0)
GUICtrlSetData($idProgress, $iProgressPercent)
_SendMessage(GUICtrlGetHandle($idProgress), $PBM_SETSTATE, $iProgressType, 0)
EndIf
Case 2
; Hide progress
GUICtrlSetState($idProgress, $GUI_HIDE)
EndSwitch
EndSwitch
EndFunc ;==>_CustomMarqueeProgressWindow
21 changes: 21 additions & 0 deletions src/StatusSplashWindow/UsageExample.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "StatusSplashWindow.au3"


; Usage example
;--------------
MsgBox(0, "StatusSplashWindow Example", "Create progress :")
_StatusSplashWindow($StatusSplashWindow_Action_Show, "Description of the task currently running.", $StatusSplashWindow_ProgressType_Green, 50, "My nice splash progress")
MsgBox(0, "StatusSplashWindow Example", "Update description :")
_StatusSplashWindow($StatusSplashWindow_Action_Update, "Second task is running.")
MsgBox(0, "StatusSplashWindow Example", "Change to marquee :")
_StatusSplashWindow($StatusSplashWindow_Action_Update, "", $StatusSplashWindow_ProgressType_Marquee)
MsgBox(0, "StatusSplashWindow Example", "Change to red progress with 75 :")
_StatusSplashWindow($StatusSplashWindow_Action_Update, "", $StatusSplashWindow_ProgressType_Red, 75)
MsgBox(0, "StatusSplashWindow Example", "Hide progress bar :")
_StatusSplashWindow($StatusSplashWindow_Action_HideBar)
MsgBox(0, "StatusSplashWindow Example", "Show progress bar again:")
_StatusSplashWindow($StatusSplashWindow_Action_Show)
MsgBox(0, "StatusSplashWindow Example", "Change to yellow and 20 percent :")
_StatusSplashWindow($StatusSplashWindow_Action_Update, "", $StatusSplashWindow_ProgressType_Yellow, 20)
MsgBox(0, "StatusSplashWindow Example", "Exit and delete window?")
_StatusSplashWindow($StatusSplashWindow_Action_DeleteWindow)
28 changes: 28 additions & 0 deletions src/WaitForAppWindow/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*********************************************************************
* Name: _WaitForAppWindow *
* Description: Waits until a process opened a new window. *
* Author: htcfreek (Heiko) - https://github.com/htcfreek [original] *
*********************************************************************

Detailed description:
---------------------
This function waits until an application defined by parameter (exe name or exe path) opens a new window.
You can specify a timeout to stop waiting after that time. Without timeout the function waits endless.

Function:
---------
_WaitForAppWindow ( $sAppExePath [, $iTimeout = 0] )

Parameters:
-----------
1. $sAppExePath : Path to the exe file or name of the program executable. (Example: "C:\Windows\Explorer.exe" or "Explorer.exe")
2. $iTimeout (Optional, Default value = 0) : Maximal time to wait for the program window. (If not defined or zero, the code waits endlessly.)

Output:
-------
A boolean value: True if a new window was being found within the timeout and False if the timeout is reached.
(If no timeout is defined and now new windows is found, the function keeps running.)

Usage example:
--------------
See the file 'UsageExample.au3' in this directory.
Loading

0 comments on commit be2a40b

Please sign in to comment.