Jump to content

Recommended Posts

Posted

objective: trying to minimize windows default magnify.exe but can't, any inputs?

#Include <WinAPI.au3>

;~ Global $_CLASS_TITLE_MAGNIFIER = '[CLASS:MagUIIconClass; TITTLE:Magnifier]'   ; <--- fails to get hWnd
  Global $_CLASS_TITLE_MAGNIFIER = '[CLASS:MagUIIconClass]'

  RunWait(@ComSpec &' /c '& 'magnify.exe', @UserProfileDir, @SW_HIDE)
  WinWaitActive($_CLASS_TITLE_MAGNIFIER, '', 3)
  Local $hWnd = WinGetHandle($_CLASS_TITLE_MAGNIFIER)
  Local $phWnd = WinActivate(_WinAPI_GetParent($hWnd))

;~ MsgBox(0, @ScriptLineNumber&': Magnifier hWnd', _
;~              '$hWnd  - '& $hWnd  &@CRLF& _
;~              '$phWnd - '& $phWnd)

  ToolTip('1st try')
  WinSetState($_CLASS_TITLE_MAGNIFIER, '', @SW_MINIMIZE)
  sleep(3000)
  ToolTip('2nd try')
  WinSetState($hWnd, '', @SW_MINIMIZE)
  sleep(3000)
  ToolTip('3rd try')
  WinSetState($phWnd, '', @SW_MINIMIZE)
  sleep(3000)
  ToolTip('')

 

Posted

@Nine cool, thanks but this won't work for me bc it's part of an automation task and uac popup break this

any explanations as to why admin is required for this simple task?

Posted

Not sure why.  It needs more investigation that I am not ready to do right now.  Maybe, look at authorizations? It definitely means that there is a credential conflict between Autoit script and the exe.

Posted (edited)

Got some time to look into it, still not quite sure why WinSetState does not work with this exe, but found a solution that is doing fine for me both Win7 and Win10 :

#include <SendMessage.au3>
#include <MenuConstants.au3>
#include <WindowsConstants.au3>

Run(@ComSpec & ' /c magnify.exe', "", @SW_HIDE)
$hWnd = WinWait ("[CLASS:MagUIClass]")
ConsoleWrite ($hWnd & @CRLF)
Sleep (2000)
_SendMessage ($hWnd, $WM_SYSCOMMAND, $SC_MINIMIZE)

 

Edited by Nine
Posted (edited)

awesome thanks @Nine, works fine on win8 here

plus didn't catch win-classes are different for default gui and floating magnifier icon

I read a little into it, and it has something to do with parent instance where uac is triggered. hence only this work with #RequireAdmin

  ToolTip('3rd try')
  WinSetState($phWnd, '', @SW_MINIMIZE)
Edited by zeenmakr

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...