Sign in to follow this  
Followers 0
motionman95

Help hiding a window...

9 posts in this topic

Hello! I'm trying to hide a window that I'm anticipating will open up, before it opens. I'm using the Run command to open and hide 7-Zip, and then I use WinMenuSelectItem to open the "About 7-Zip" window. The only problem I'm having is that I know that the "About 7-Zip" will open when I use WinMenuSelectItem, but I want to hide it before or/when it opens. I'm using this to do that, but there is always a flicker. Is there a way to hide it without the flicker?

;Open the "About 7-Zip" prompt...
    WinMenuSelectItem("[CLASS:FM]", "", "&Help", "&About 7-Zip...")

;Loop until the prompt is open...
    While Not WinExists("About 7-Zip")
    ;Wait...
    WEnd

      ;Quick, hide the prompt!
    WinSetState("About 7-Zip", "", @SW_HIDE)

Thanks in advance!


Share this post


Link to post
Share on other sites



Hello! I'm trying to hide a window that I'm anticipating will open up, before it opens. I'm using the Run command to open and hide 7-Zip, and then I use WinMenuSelectItem to open the "About 7-Zip" window. The only problem I'm having is that I know that the "About 7-Zip" will open when I use WinMenuSelectItem, but I want to hide it before or/when it opens. I'm using this to do that, but there is always a flicker. Is there a way to hide it without the flicker?

;Open the "About 7-Zip" prompt...
     WinMenuSelectItem("[CLASS:FM]", "", "&Help", "&About 7-Zip...")
 
;Loop until the prompt is open...
     While Not WinExists("About 7-Zip")
    ;Wait...
     WEnd
 
      ;Quick, hide the prompt!
     WinSetState("About 7-Zip", "", @SW_HIDE)

Thanks in advance!

Maybe this approach would do what you want.

;WinSetState("About 7-Zip", "", @SW_SHOW)
;Open the "About 7-Zip" prompt...
#include <windowsconstants.au3>
#include <ScreenCapture.au3>
$x = @DesktopWidth / 2 - 250
$y = @DesktopHeight / 2 - 250

_ScreenCapture_CaptureWnd("tempCover.bmp", WinGetHandle("Program Manager"), $x, $y, $x + 500, $y + 500);$gui)
$hidew = GUICreate("", 500, 500, $x, $y, $WS_POPUP)

$coverpic = GUICtrlCreatePic("tempCover.bmp", 0, 0, 500, 500)
WinSetTrans($hidew, "", 0)
GUISetState()
For $n = 10 To 255 Step 5
    WinSetTrans($hidew, "", $n)
Next

WinSetOnTop($hidew, "", 1)


WinMenuSelectItem("[CLASS:FM]", "", "&Help", "&About 7-Zip...")


;Loop until the prompt is open...
While Not WinExists("About 7-Zip")
   ;Wait...
WEnd

Sleep(4000)
msgbox(262144,"You can't see it", "..but it's there!" & @CRLF & "Press OK to see it.")
;Quick, hide the prompt!
;WinSetState("About 7-Zip", "", @SW_HIDE);perhaps WInClose would be better.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks martin! You rock!


Share this post


Link to post
Share on other sites

With the great help of Rover

#include "WinEventHook.au3"
HotKeySet('{ESC}', '_EXIT')

Global $hFunc, $pFunc
Global $hWinHook

$hFunc = DllCallbackRegister('_WinEventProc', 'none', 'ptr;uint;hwnd;int;int;uint;uint')
$pFunc = DllCallbackGetPtr($hFunc)

$hWinHook = _SetWinEventHook($EVENT_MIN, $EVENT_MAX, 0, $pFunc, 0, 0, _
                BitOR($WINEVENT_SKIPOWNPROCESS, $WINEVENT_OUTOFCONTEXT))
                
If $hWinHook = 0 Then Exit MsgBox(0x10, 'Error', 'Could not register callback procedure')

While 1
    Sleep(20)
WEnd

Func _EXIT()
    Exit
EndFunc

Func OnAutoItExit()
    _UnhookWinEvent($hWinHook)
    DllCallbackFree($hFunc)
EndFunc

Func _WinEventProc($hHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iEventThread, $imsEventTime)
    Switch $iEvent
        Case $EVENT_SYSTEM_DIALOGSTART
            ConsoleWrite('A dialog has started: "' & WinGetTitle($hWnd) & '"' & @LF)
        Case $EVENT_SYSTEM_DIALOGEND
            ConsoleWrite('A dialog has closed: ' & $hWnd & @LF)
    EndSwitch
EndFuncoÝ÷ Ùh§÷§´z(«·jëh×6Global Const $EVENT_MIN = 0x00000001
Global Const $EVENT_MAX = 0x7FFFFFFF

Global Const $WINEVENT_OUTOFCONTEXT = 0x0000
Global Const $WINEVENT_SKIPOWNTHREAD = 0x0001
Global Const $WINEVENT_SKIPOWNPROCESS = 0x0002
Global Const $WINEVENT_INCONTEXT = 0x0004

Global Const $EVENT_SYSTEM_SOUND = 0x0001
Global Const $EVENT_SYSTEM_ALERT = 0x0002
Global Const $EVENT_SYSTEM_FOREGROUND = 0x0003
Global Const $EVENT_SYSTEM_MENUSTART = 0x0004
Global Const $EVENT_SYSTEM_MENUEND = 0x0005
Global Const $EVENT_SYSTEM_MENUPOPUPSTART = 0x0006
Global Const $EVENT_SYSTEM_MENUPOPUPEND = 0x0007
Global Const $EVENT_SYSTEM_CAPTURESTART = 0x0008
Global Const $EVENT_SYSTEM_CAPTUREEND = 0x0009
Global Const $EVENT_SYSTEM_MOVESIZESTART = 0x000A
Global Const $EVENT_SYSTEM_MOVESIZEEND = 0x000B
Global Const $EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C
Global Const $EVENT_SYSTEM_CONTEXTHELPEND = 0x000D
Global Const $EVENT_SYSTEM_DRAGDROPSTART = 0x000E
Global Const $EVENT_SYSTEM_DRAGDROPEND = 0x000F
Global Const $EVENT_SYSTEM_DIALOGSTART = 0x0010
Global Const $EVENT_SYSTEM_DIALOGEND = 0x0011
Global Const $EVENT_SYSTEM_SCROLLINGSTART = 0x0012
Global Const $EVENT_SYSTEM_SCROLLINGEND = 0x0013
Global Const $EVENT_SYSTEM_SWITCHSTART = 0x0014
Global Const $EVENT_SYSTEM_SWITCHEND = 0x0015
Global Const $EVENT_SYSTEM_MINIMIZESTART = 0x0016
Global Const $EVENT_SYSTEM_MINIMIZEEND = 0x0017
Global Const $EVENT_OBJECT_CREATE = 0x8000
Global Const $EVENT_OBJECT_DESTROY = 0x8001
Global Const $EVENT_OBJECT_SHOW = 0x8002
Global Const $EVENT_OBJECT_HIDE = 0x8003
Global Const $EVENT_OBJECT_REORDER = 0x8004
Global Const $EVENT_OBJECT_FOCUS = 0x8005
Global Const $EVENT_OBJECT_SELECTION = 0x8006
Global Const $EVENT_OBJECT_SELECTIONADD = 0x8007
Global Const $EVENT_OBJECT_SELECTIONREMOVE = 0x8008
Global Const $EVENT_OBJECT_SELECTIONWITHIN = 0x8009
Global Const $EVENT_OBJECT_STATECHANGE = 0x800A
Global Const $EVENT_OBJECT_LOCATIonchange = 0x800B
Global Const $EVENT_OBJECT_NAMECHANGE = 0x800C
Global Const $EVENT_OBJECT_DESCRIPTIonchange = 0x800D
Global Const $EVENT_OBJECT_VALUECHANGE = 0x800E
Global Const $EVENT_OBJECT_PARENTCHANGE = 0x800F
Global Const $EVENT_OBJECT_HELPCHANGE = 0x8010
Global Const $EVENT_OBJECT_DEFACTIonchange = 0x8011
Global Const $EVENT_OBJECT_ACCELERATORCHANGE = 0x8012


Func _SetWinEventHook($ieventMin, $ieventMax, $hMod, $pCallback, $iProcID, $iThreadID, $iFlags)
    Local $aRet
    
    $aRet = DllCall('user32.dll', 'ptr', 'SetWinEventHook', 'uint', $ieventMin, 'uint', $ieventMax, _
                'hwnd', $hMod, 'ptr', $pCallback, 'dword', $iProcID, 'dword', $iThreadID, 'uint', $iFlags)
    
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc

Func _UnhookWinEvent($hWinEventHook)
    Local $aRet
    
    $aRet = DllCall('user32.dll', 'int', 'UnhookWinEvent', 'ptr', $hWinEventHook)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc

Test and see if you get notified about the new window. You won't see any message boxes, it's all outputs to the console.

Share this post


Link to post
Share on other sites

Excellent, I didn't know about that type of hooking. Very powerful, I will investigate more soon.

Share this post


Link to post
Share on other sites

Thanks, but sorry guys! I've found a better way to reach my ultimate goal. But hopefully, this will help anyone else who has these problems. :)


Share this post


Link to post
Share on other sites

Thanks, but sorry guys! I've found a better way to reach my ultimate goal. But hopefully, this will help anyone else who has these problems. :)

Nothing beats global hooks ! :party:

Share this post


Link to post
Share on other sites

Thanks, but sorry guys! I've found a better way to reach my ultimate goal. But hopefully, this will help anyone else who has these problems. :)

Can you tell us you did it?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

My ultimate goal was to read from a label in the about prompt...:) But I've found a better way that doesn't involve using the about 7-zip prompt.


Share this post


Link to post
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
Sign in to follow this  
Followers 0