Jump to content

Recommended Posts

Posted (edited)

There is an interesting situation
This code does not work alone, my operating system is Windows 10.

#RequireAdmin
If ProcessExists("IDMan.exe") Then
    ProcessClose("IDMan.exe")
    ShellExecute(@ProgramFilesDir & "\Internet Download Manager\IDMan.exe")
    If ProcessWait("IDMan.exe") Then
        Local $aWinList = WinList("[REGEXPTITLE:(?i)(.*Internet Download Manager*)]")
        For $i = 1 To $aWinList[0][0]
            $title = $aWinList[$i][0]
            ;Sleep(100);Trying to sleep here still doesn't work
            WinSetState($title, "", @SW_HIDE)
        Next
    EndIf
EndIf

 

But if I use it with that code, then it's no problem.

#RequireAdmin
#include <WinAPISysWin.au3>
If ProcessExists("IDMan.exe") Then
    ProcessClose("IDMan.exe")
    ShellExecute(@ProgramFilesDir & "\Internet Download Manager\IDMan.exe")
    If ProcessWait("IDMan.exe") Then
        Local $aWinList = WinList("[REGEXPTITLE:(?i)(.*Internet Download Manager*)]")
        For $i = 1 To $aWinList[0][0]
            $title = $aWinList[$i][0]
            ;Sleep(100);Trying to sleep here still doesn't work
            WinSetState($title, "", @SW_HIDE)
        Next
    EndIf
EndIf

_WinAndParentSetState("Internet Download Manager", @SW_HIDE)

Func _WinAndParentSetState($title, $state)
    $childHandle = WinGetHandle($title)
    $parentLong = _WinAPI_GetWindowLong($childHandle, $GWL_HWNDPARENT)
    $parentHandle = HWnd($parentLong)
    WinSetState($parentHandle, '', $state)
    WinSetState($childHandle, '', $state)
EndFunc   ;==>_WinAndParentSetState

Can't the program window be closed in a shorter and simpler way?

Or my codes are wrong :)

https://prnt.sc/otqpzk

Edited by youtuber
Posted (edited)

@Nine Not exactly regex I think.

I tried windows 7 too smoothly but windows 10 failed
because now I've tried with Sleep(2000) is working.

This is exactly the code that works, but isn't Sleep(2000) standby time too much?

#RequireAdmin
If ProcessExists("IDMan.exe") Then
    ProcessClose("IDMan.exe")
    ShellExecute(@ProgramFilesDir & "\Internet Download Manager\IDMan.exe")
    If ProcessWait("IDMan.exe") Then
        Local $aWinList = WinList("[REGEXPTITLE:(?i)(.*Internet Download Manager*)]")
        ;$aWinList = WinList("[REGEXPTITLE:(?i)(.*Internet Download Manager.*)]")
        For $i = 1 To $aWinList[0][0]
            $title = $aWinList[$i][0]
            If @OSVersion = "WIN_10" Then
                Sleep(2000)
            EndIf
            WinSetState($title, "", @SW_HIDE)
        Next
    EndIf
EndIf

 

Edited by youtuber

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
  • Recently Browsing   0 members

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