Jump to content

WinAPIEx UDF


Yashied
 Share

Recommended Posts

Hi Yashied, maybe this is interesting for the library?

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3>

$hgui = GUICreate("_Winapi_GetGUIThreadInfo Example", 400, 400)
$cEdit = GUICtrlCreateEdit("", 10, 10, 380, 380)
GUISetState(@SW_SHOW)
WinSetOnTop($hgui, "", 1)

$timer = TimerInit()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect

    If TimerDiff($timer) > 500 Then
        $timer = TimerInit()

        GUISetState(@SW_LOCK, $hgui)
        GUICtrlSetData($cEdit, "")

        $hwnd = WinGetHandle("[ACTIVE]", "")
        $aRet = _WinApi_GetGUIThreadInfo($hwnd)

        $sText = "ProcessId" & @TAB & @TAB & @TAB & WinGetProcess($hwnd) & @CRLF
        $sText &= "ProcessName" & @TAB & @TAB & _WinAPI_GetProcessName(WinGetProcess($hwnd)) & @CRLF & @CRLF
        $sText &= "ThreadID" & @TAB & @TAB & @TAB & $aRet[0] & @CRLF
        $sText &= "ThreadStateFlags" & @TAB & @TAB & $aRet[1] & @CRLF
        $sText &= "GUI_CARETBLINKING" & @TAB & $aRet[2] & @CRLF
        $sText &= "GUI_INMOVESIZE" & @TAB & @TAB & $aRet[3] & @CRLF
        $sText &= "GUI_INMENUMODE" & @TAB & $aRet[4] & @CRLF
        $sText &= "GUI_SYSTEMMENUMODE" & @TAB & $aRet[5] & @CRLF
        $sText &= "GUI_POPUPMENUMODE" & @TAB & $aRet[6] & @CRLF
        $sText &= "hwndActive" & @TAB & @TAB & $aRet[7] & @CRLF
        $sText &= "hwndFocus" & @TAB & @TAB & $aRet[8] & @CRLF
        $sText &= "hwndMenuOwner" & @TAB & @TAB & $aRet[9] & @CRLF
        $sText &= "hwndMoveSize" & @TAB & @TAB & $aRet[10] & @CRLF
        $sText &= "hwndCaret" & @TAB & @TAB & $aRet[11] & @CRLF
        $sText &= "RectLeft" & @TAB & @TAB & @TAB & $aRet[12] & @CRLF
        $sText &= "RectTop" & @TAB & @TAB & @TAB & $aRet[13] & @CRLF
        $sText &= "RectRight" & @TAB & @TAB & $aRet[14] & @CRLF
        $sText &= "RectBottom" & @TAB & @TAB & $aRet[15] & @CRLF & @CRLF & @CRLF

        $sText &= WinGetTitle($aRet[7],"") & @CRLF
        $sText &= WinGetClassList($aRet[7],"") & @CRLF & @CRLF

        $sText &= WinGetTitle($aRet[8],"") & @CRLF
        $sText &= WinGetClassList($aRet[8],"") & @CRLF

        GUICtrlSetData($cEdit, $sText)
        GUISetState(@SW_UNLOCK)

    EndIf

WEnd


Func _WinApi_GetGUIThreadInfo($hwnd)

    Local $aReturn[16]

    If Not IsHWnd($hwnd) Then Return SetError(1, 0, $aReturn)

    Local Const $GUI_CARETBLINKING = 0x00000001 ; The caret's blink state. This bit is set if the caret is visible.
    Local Const $GUI_INMOVESIZE = 0x00000002 ; The thread's move state. This bit is set if the thread is in a move or size loop.
    Local Const $GUI_INMENUMODE = 0x00000004 ; The thread's menu state. This bit is set if the thread is in menu mode.
    Local Const $GUI_SYSTEMMENUMODE = 0x00000008; The thread's system menu state. This bit is set if the thread is in a system menu mode.
    Local Const $GUI_POPUPMENUMODE = 0x00000010 ; The thread's pop-up menu state. This bit is set if the thread has an active pop-up menu.

    Local $sGUITHREADINFO = "DWORD cbSize;DWORD flags;HWND hwndActive;HWND hwndFocus;HWND hwndCapture;HWND hwndMenuOwner;HWND hwndMoveSize;HWND hwndCaret;LONG RectLeft;LONG RectTop;LONG RectRight;LONG RectBottom;"
    Local $tGUITHREADINFO = DllStructCreate($sGUITHREADINFO)
    DllStructSetData($tGUITHREADINFO, "cbSize", DllStructGetSize($tGUITHREADINFO))

    Local $iPID = WinGetProcess($hwnd)
    Local $iThreadID = _WinAPI_GetWindowThreadProcessId($hWnd, $iPID)
    If Not $iThreadID Then Return SetError(2, 0, $aReturn)

    $iRet = DllCall("user32.dll", "DWORD", "GetGUIThreadInfo", "DWORD", $iThreadID, "ptr", DllStructGetPtr($tGUITHREADINFO))
    If Not $iRet[0] Then Return SetError(3, 0, $aReturn)

    $aReturn[0] = $iThreadID ; ThreadID
    $aReturn[1] = DllStructGetData($tGUITHREADINFO, "flags") ; Thread State Flags
    If BitAND($GUI_CARETBLINKING, DllStructGetData($tGUITHREADINFO, "flags")) Then $aReturn[2] = "GUI_CARETBLINKING"
    If BitAND($GUI_INMOVESIZE, DllStructGetData($tGUITHREADINFO, "flags")) Then $aReturn[3] = "GUI_INMOVESIZE"
    If BitAND($GUI_INMENUMODE, DllStructGetData($tGUITHREADINFO, "flags")) Then $aReturn[4] = "GUI_INMENUMODE"
    If BitAND($GUI_SYSTEMMENUMODE, DllStructGetData($tGUITHREADINFO, "flags")) Then $aReturn[5] = "GUI_SYSTEMMENUMODE"
    If BitAND($GUI_POPUPMENUMODE, DllStructGetData($tGUITHREADINFO, "flags")) Then $aReturn[6] = "GUI_POPUPMENUMODE"
    $aReturn[7] = DllStructGetData($tGUITHREADINFO, "hwndActive") ; A handle to the active window within the thread.
    $aReturn[8] = DllStructGetData($tGUITHREADINFO, "hwndFocus") ; A handle to the window that has the keyboard focus.
    $aReturn[9] = DllStructGetData($tGUITHREADINFO, "hwndMenuOwner") ; A handle to the window that has captured the mouse.
    $aReturn[10] = DllStructGetData($tGUITHREADINFO, "hwndMoveSize") ; A handle to the window that owns any active menus.
    $aReturn[11] = DllStructGetData($tGUITHREADINFO, "hwndCaret") ; A handle to the window in a move or size loop.
    $aReturn[12] = DllStructGetData($tGUITHREADINFO, "RectLeft") ; The caret's bounding rectangle, in client coordinates, relative to the window specified by the hwndCaret member.
    $aReturn[13] = DllStructGetData($tGUITHREADINFO, "RectTop")
    $aReturn[14] = DllStructGetData($tGUITHREADINFO, "RectRight")
    $aReturn[15] = DllStructGetData($tGUITHREADINFO, "RectBottom")

    Return $aReturn

EndFunc   ;==>_WinApi_GetGUIThreadInfo
Link to comment
Share on other sites

I'm surprised this isn't here already...

Global Const $TME_CANCEL = 0x80000000
Global Const $TME_HOVER = 0x1
Global Const $TME_LEAVE = 0x2
Global Const $TME_NONCLIENT = 0x10
Global Const $TME_QUERY = 0x40000000

Global Const $HOVER_DEFAULT = 0xFFFFFFFF

; #STRUCTURE# ===================================================================================================================
; Name...........: $tagTRACKMOUSEEVENT
; Description ...: Used by the TrackMouseEvent function to track when the mouse pointer leaves a window or hovers over a window
;                  for a specified amount of time.
; Fields ........: Size                 - The size of the $tagTRACKMOUSEEVENT structure, in bytes.
;                  Flags                - The services requested. This member can be a combination of the following values:
;                                       |TME_CANCEL - The caller wants to cancel a prior tracking request. The caller should also
;                                                     specify the type of tracking that it wants to cancel. For example, to
;                                                     cancel hover tracking, the caller must pass the TME_CANCEL and TME_HOVER
;                                                     flags.
;                                       |TME_HOVER  - The caller wants hover notification. Notification is delivered as a
;                                                     WM_MOUSEHOVER message. If the caller requests hover tracking while hover
;                                                     tracking is already active, the hover timer will be reset. This flag is
;                                                     ignored if the mouse pointer is not over the specified window or area.
;                                       |TME_LEAVE  - The caller wants leave notification. Notification is delivered as a
;                                                     WM_MOUSELEAVE message. If the mouse is not over the specified window or
;                                                     area, a leave notification is generated immediately and no further
;                                                     tracking is performed.
;                                       |TME_NONCLIENT - The caller wants hover and leave notification for the nonclient areas.
;                                                        Notification is delivered as WM_NCMOUSEHOVER and WM_NCMOUSELEAVE
;                                                        messages.
;                                       |TME_QUERY  - The function fills in the structure instead of treating it as a tracking
;                                                     request. The structure is filled such that had that structure been passed
;                                                     to _WinAPI_TrackMouseEvent, it would generate the current tracking. The
;                                                     only anomaly is that the hover time-out returned is always the actual
;                                                     time-out and not $HOVER_DEFAULT, if $HOVER_DEFAULT was specified during
;                                                     the original _WinAPI_TrackMouseEvent request. You can call
;                                                     _WinAPI_SystemParametersInfo and use $SPI_GETMOUSEHOVERTIME to retrieve
;                                                     the default hover time-out.
;                  WndTrack             - The handle to the GUI to track.
;                  HoverTime            - The hover time-out (if $TME_HOVER was specified in dwFlags), in milliseconds. Can be
;                                         $HOVER_DEFAULT, which means to use the system default hover time-out.
; Author ........: Matt Diesel (Mat)
; Remarks .......:
; ===============================================================================================================================
Global Const $tagTRACKMOUSEEVENT = "dword Size; dword Flags; hwnd WndTrack; dword HoverTime"

; #FUNCTION# ====================================================================================================================
; Name ..........: _WinAPI_TrackMouseEvent
; Description ...: Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time.
; Syntax ........: _WinAPI_TrackMouseEvent( $hWnd [, $iFlags [, $iTime ]] )
; Parameters ....: $hWnd                - The handle to the GUI to track.
;                  $iFlags              - [optional] The services requested. This member can be a combination of the following
;                                         values:
;                                       |TME_CANCEL - The caller wants to cancel a prior tracking request. The caller should also
;                                                     specify the type of tracking that it wants to cancel. For example, to
;                                                     cancel hover tracking, the caller must pass the TME_CANCEL and TME_HOVER
;                                                     flags.
;                                       |TME_HOVER  - The caller wants hover notification. Notification is delivered as a
;                                                     WM_MOUSEHOVER message. If the caller requests hover tracking while hover
;                                                     tracking is already active, the hover timer will be reset. This flag is
;                                                     ignored if the mouse pointer is not over the specified window or area.
;                                       |TME_LEAVE  - The caller wants leave notification. Notification is delivered as a
;                                                     WM_MOUSELEAVE message. If the mouse is not over the specified window or
;                                                     area, a leave notification is generated immediately and no further
;                                                     tracking is performed.
;                                       |TME_NONCLIENT - The caller wants hover and leave notification for the nonclient areas.
;                                                        Notification is delivered as WM_NCMOUSEHOVER and WM_NCMOUSELEAVE
;                                                        messages.
;                  $iTime               - [optional] The hover time-out (if $TME_HOVER was specified in $iFlags), in
;                                         milliseconds. -1 (default) means to use the system default hover time-out.
; Return values .: Success              - True
;                  Failure              - False and sets the @error flag
; Author(s) .....: Matt Diesel (Mat)
; Modified ......:
; Remarks .......: Not that TME_QUERY, although a valid flag, cannot be used with this function.
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _WinAPI_TrackMouseEvent($hWnd, $iFlags = -1, $iTime = -1)
    Local $tTrackMouseEvent, $aResult

    If $iFlags = -1 Then $iFlags = $TME_HOVER
    If $iTime = -1 Then $iTime = $HOVER_DEFAULT

    $tTrackMouseEvent = DllStructCreate($tagTRACKMOUSEEVENT)
    DllStructSetData($tTrackMouseEvent, "Size", DllStructGetSize($tTrackMouseEvent))
    DllStructSetData($tTrackMouseEvent, "Flags", $iFlags)
    DllStructSetData($tTrackMouseEvent, "WndTrack", $hWnd)
    DllStructSetData($tTrackMouseEvent, "HoverTime", $iTime)

    $aResult = DllCall("User32.dll", "int", "TrackMouseEvent", "ptr", DllStructGetPtr($tTrackMouseEvent))
    If @error Then Return SetError(@error, @extended, False)

    Return $aResult[0] <> 0
EndFunc   ;==>_WinAPI_TrackMouseEvent

Example:

#include<WinAPI.au3>
#include<TrackMouseEvent.au3> ; Posted above.
#include<WindowsConstants.au3>

Global Const $WM_MOUSEHOVER = 0x2A1

Global Const $MK_CONTROL = 0x8
Global Const $MK_LBUTTON = 0x1
Global Const $MK_MBUTTON = 0x10
Global Const $MK_RBUTTON = 0x2
Global Const $MK_SHIFT = 0x4
Global Const $MK_XBUTTON1 = 0x20
Global Const $MK_XBUTTON2 = 0x40

Global $hGUI

$hGUI = GUICreate("WM_MOUSEHOVER")

GUISetState()
GUIRegisterMsg($WM_MOUSEHOVER, "WM_MOUSEHOVER")

Local $iMsg, $fHovered = False
While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case -3
            ExitLoop
        Case Else
            $tPos = _WinAPI_GetMousePos()

            If _WinAPI_WindowFromPoint($tPos) <> $hGUI And $fHovered Then
                $fHovered = False
            ElseIf _WinAPI_WindowFromPoint($tPos) = $hGUI And Not $fHovered Then
                If Not _WinAPI_TrackMouseEvent($hGUI) Then Exit
                $fHovered = True
            EndIf
    EndSwitch
WEnd

Func WM_MOUSEHOVER($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam

    Local $iKeys = _WinAPI_LoWord($wParam)
    Local $iHoverDelta = _WinAPI_HiWord($wParam)
    Local $iX = _WinAPI_LoWord($lParam)
    Local $iY = _WinAPI_HiWord($lParam)

    Local $sKeys = ""
    If BitAND($iKeys, $MK_CONTROL) = $MK_CONTROL Then $sKeys &= "CONTROL & "
    If BitAND($iKeys, $MK_LBUTTON) = $MK_LBUTTON Then $sKeys &= "LBUTTON & "
    If BitAND($iKeys, $MK_MBUTTON) = $MK_MBUTTON Then $sKeys &= "MBUTTON & "
    If BitAND($iKeys, $MK_RBUTTON) = $MK_RBUTTON Then $sKeys &= "RBUTTON & "
    If BitAND($iKeys, $MK_SHIFT) = $MK_SHIFT Then $sKeys &= "SHIFT & "
    If BitAND($iKeys, $MK_XBUTTON1) = $MK_XBUTTON1 Then $sKeys &= "XBUTTON1 & "
    If BitAND($iKeys, $MK_XBUTTON2) = $MK_XBUTTON2 Then $sKeys &= "XBUTTON2 & "

    If $sKeys = "" Then
        $sKeys = "No keys"
    Else
        $sKeys = StringTrimRight($sKeys, 3)
    EndIf

    ConsoleWrite(StringFormat("Mouse hovered delta %d with %s pressed at (%d, %d).\n", $iHoverDelta, $sKeys, $iX, $iY))

    If Not _WinAPI_TrackMouseEvent($hWnd) Then Exit 1
    Return 0
EndFunc   ;==>WM_MOUSEHOVER
Link to comment
Share on other sites

Bug report for _WinAPI_ShellQueryRecycleBin :P. On a 64bit system it returns correct results if run as a 32bit process, but fails if run as a 64bit process. The structure seems somewhat wrong, but the structure as defined on MSDN only works for 64bit processes and not 32bit ones :x. Added a workaround below.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WinAPIEx.au3>

; On a 64bit system returns correct results if run as a 32bit process, fails if run as a 64bit process
$aRes = _WinAPI_ShellQueryRecycleBin("")
if not @error then
    MsgBox(0,"WinAPIEx","_WinAPI_ShellQueryRecycleBin" & @crlf & @crlf & $aRes[0] & @crlf & $aRes[1])
Else
    MsgBox(0,"WinAPIEx","_WinAPI_ShellQueryRecycleBin" & @crlf & @crlf & @error & @crlf & @extended)
EndIf

; On a 64bit system returns correct results for 32&64bit processes, but structure workaround is kind of ugly :)
$aRes = _WinAPI_ShellQueryRecycleBinEx("")
if not @error then
    MsgBox(0,"WinAPIEx","_WinAPI_ShellQueryRecycleBinEx" & @crlf & @crlf & $aRes[0] & @crlf & $aRes[1])
Else
    MsgBox(0,"WinAPIEx","_WinAPI_ShellQueryRecycleBinEx" & @crlf & @crlf & @error & @crlf & @extended)
EndIf



Func _WinAPI_ShellQueryRecycleBinEx($sRoot)
    If @AutoItX64 Then
        Local $tSHQUERYRBINFO = DllStructCreate("DWORD cbSize;int64 i64Size;int64 i64NumItems")
    Else
        Local $tSHQUERYRBINFO = DllStructCreate("align 1;int;int64;int64")
    EndIf

    DllStructSetData($tSHQUERYRBINFO, 1, DllStructGetSize($tSHQUERYRBINFO))

    Local $Ret = DllCall('shell32.dll', 'uint', 'SHQueryRecycleBinW', 'wstr', $sRoot, 'ptr', DllStructGetPtr($tSHQUERYRBINFO))

    If @error Then
        Return SetError(1, 0, 0)
    Else
        If $Ret[0] Then
            Return SetError(1, $Ret[0], 0)
        EndIf
    EndIf

    Local $Result[2]

    $Result[0] = DllStructGetData($tSHQUERYRBINFO, 2)
    $Result[1] = DllStructGetData($tSHQUERYRBINFO, 3)

    Return $Result
EndFunc   ;==>_WinAPI_ShellQueryRecycleBin
Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

I ran the examples from the help-file:

_WinAPI_GetCDType returns for D: (a real DVD-RW containing a DVD) and N: (a virtual BD-ROM drive containing no media)

@ 32bit:

D: => DVD-ROM

N: => No media

@ 64bit:

D: => Unknown

N: => Unknown

_WinAPI_GetOutlineTextMetrics returns

@ 32bit:

Family name: Arial

Typeface name: Arial

Style name Standard

Full name: Monotype:Arial Regular:Version 5.06 (Microsoft)

@ 64bit:

Family name: Arial

Typeface name: U

Style name Arial

Full name: U

_WinAPI_IsDoorOpen returns

@ 32bit:

Open... => opens

Tray is open: 1 => is open

Close... => closes & starts autorun

Tray is open: 0 => is closed

@ 64bit:

Open... => opens

Tray is open: 0 => is open

Close... => closes & starts autorun

Tray is open: 0 => is closed

Edit: I'll check the structures when I find some spare time :x...

Edited by KaFu
Link to comment
Share on other sites

  • 3 weeks later...

_WinAPI_ShellQueryRecycleBin()

Maybe a note worth for the documentation. I removed it from SMF, as I think I tracked it down to be the reason for unpredictable freezes. I found following statement on the function:

"The problem is that each drive has its own recycle bin folder and SHQueryRecycleBin does not return until all drives have been scanned. If you have a drive that is 'sleeping' when the function is called, the call will NOT return until that drive (and all others in the same situation) has spun up. A drive can take 20-30 seconds to spin up, and, until SHQueryRecycleBin returns, the program will appear 'frozen'."

Link to comment
Share on other sites

The library has been updated.

v3.2

Changes

  • Added the following functions.

    _WinAPI_AddIconOverlay

    _WinAPI_AddIconTransparency

    _WinAPI_Create32BitHICON

    _WinAPI_ExtractIcon

    _WinAPI_GetExitCodeProcess

    _WinAPI_GetGUIThreadInfo (Thanks KaFu)

    _WinAPI_GetIconInfoEx

    _WinAPI_GetProcessUser

    _WinAPI_LoadIndirectString

    _WinAPI_LockWindowUpdate

    _WinAPI_PathCompactPathEx

    _WinAPI_PathIsRoot

    _WinAPI_PathIsSystemFolder

    _WinAPI_PathMakeSystemFolder

    _WinAPI_PathRemoveBackslash

    _WinAPI_PathRemoveExtension

    _WinAPI_PathRemoveFileSpec

    _WinAPI_PathSkipRoot

    _WinAPI_PathStripPath

    _WinAPI_PathStripToRoot

    _WinAPI_PathUnmakeSystemFolder

    _WinAPI_ShellExecute

    _WinAPI_StrFormatByteSize

    _WinAPI_StrFormatKBSize

    _WinAPI_StrFromTimeInterval

    _WinAPI_TrackMouseEvent (Thanks Mat)

  • Added examples for the functions above.
  • _WinAPI_GetOutlineTextMetrics() and _WinAPI_ShellQueryRecycleBin() functions now works correctly within 64-bit systems. (Thanks KaFu)
  • Fixed some examples to work properly within 64-bit systems.
  • Fixed a bug in the _WinAPI_PathCompactPath() function which could cause crash the script.
  • Fixed a bug in the _WinAPI_GetFileAttributes() function that returns a wrong error code if an error occurred.
  • Fixed description of some functions.
  • Updated documentation.

Link to comment
Share on other sites

Another addition perhaps? :)

Func _WinAPI_PathIsHTMLFile($sPath)

    Local $Ret = DllCall('shlwapi.dll', 'int', 'PathIsHTMLFileW', 'wstr', $sPath)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_PathIsHTMLFile

Plus, your last update was pretty awesome. _WinAPI_PathStripPath() - I had no idea this could be done with the Windows API, I was using this >>

Func _GetFilename($gf_Path)
    Return StringRegExpReplace($gf_Path, "^.*\\", "")
EndFunc   ;==>_GetFilename
Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Another addition perhaps? :)

Func _WinAPI_PathIsHTMLFile($sPath)

    Local $Ret = DllCall('shlwapi.dll', 'int', 'PathIsHTMLFileW', 'wstr', $sPath)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_PathIsHTMLFile

Plus, your last update was pretty awesome. _WinAPI_PathStripPath() - I had no idea this could be done with the Windows API, I was using this >>

Func _GetFilename($gf_Path)
    Return StringRegExpReplace($gf_Path, "^.*\\", "")
EndFunc   ;==>_GetFilename

Why it return 0 on my system (win7pro)?
Link to comment
Share on other sites

Why it return 0 on my system (win7pro)?

Because PathIsHTMLFile() function does not exported. PathIsHTMLFile() is equivalent to PathIsContentType() with "text/html" as the content type.

Func _WinAPI_PathIsContentType($sPath, $sType)

    Local $Ret = DllCall('shlwapi.dll', 'int', 'PathIsContentTypeW', 'wstr', $sPath, 'wstr', $sType)

    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_PathIsContentType

ConsoleWrite(_WinAPI_PathIsContentType('Test.html', 'text/html') & @CR)
Link to comment
Share on other sites

Ahhh! Maybe MSDN and WinAPI is a little out of my depth after all, thanks Yashied. I will have a look at the MSDN entry and decipher why I didn't pick up on the Content Type.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

OK, this works... :) Determines if a Path is a Network Path.

Func _WinAPI_PathIsNetworkPath($sPath)

    Local $Ret = DllCall('shlwapi.dll', 'int', 'PathIsNetworkPathW', 'wstr', $sPath)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_PathIsNetworkPath
Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

OK, this works... :) Determines if a Path is a Network Path.

Func _WinAPI_PathIsNetworkPath($sPath)

    Local $Ret = DllCall('shlwapi.dll', 'int', 'PathIsNetworkPathW', 'wstr', $sPath)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_PathIsNetworkPath

The usefulness of this function makes me doubt, since it cannot recognize a network drive mapped to a drive letter.
Link to comment
Share on other sites

OK, didn't test with a Network Drive, only tried a Network Share mapped to a Drive Letter e.g. K:\ and it worked. But obviously I trust your judgment.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...