Sign in to follow this  
Followers 0
Leagnus

WinSetState and @SW_MINIMIZE works not as 'minimize' button

10 posts in this topic

#1 ·  Posted (edited)

In PowerPro I use the script to minimize EverestUltimate220 diagnostic program so it shows sensors' data of my PC in the tray

EverestUltimate220 is much easy to use then MotherBoard Monitor I believe

"D:\PfilesNS\infoTools\EverestUltimate220\everest.exe"

wait.for (60000, visiblewindow("EVEREST Ultimate*"))

if (visiblewindow("EVEREST Ultimate*"))

Window Min! "c=TForm1"

if (visiblewindow("EVEREST Ultimate*"))

Window Hide! "c=TApplication"

If i run it not by the script - trayminned or hidden - it occupies about 16 MB of RAM instead of about 1 or 2 MB

Everything's fine but for PP'users... I've tried to write the script in Au3 lang, and unsuccessfully!

WinSetState and @SW_MINIMIZE do not minimize windows as PowerPro does and

my everest.exe proccess occupies about 16 MB of RAM dispite of all my afforts :)

So WinSetState and @SW_MINIMIZE works not as 'minimize' button - is there a way to send a keystroke to 1-st of 3 or "minimize" button of all windows in right top of them?

Edited by Leony

Share this post


Link to post
Share on other sites



ALT+Space+n

Share this post


Link to post
Share on other sites

Thanks! Both methods works fine!

#include <Misc.au3>

Run("everest.exe")

Global Const $WM_SYSCOMMAND = 0x0112

Global Const $SC_MINIMIZE = 0xF020

Opt("WinTitleMatchMode", 4)

WinWaitActive("classname=TForm1")

;$hWnd = WinGetHandle("classname=TApplication")

$hWnd = WinGetHandle("classname=TForm1")

_SendMessage($hWnd, $WM_SYSCOMMAND, $SC_MINIMIZE, 0)

WinSetState("classname=TApplication","", @SW_HIDE)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Sorry for being novice

but now "classname=TApplication" window stays in taskbar and

WinSetState("classname=TApplication","", @SW_HIDE)

doesn't hide it :)

It was always mystery for my how to calculate WM_messages

The MSDN says

I should combine $WM_SYSCOMMAND and $SC_MINIMIZE but where You wise man Zedna took the 0x0112 and 0xF020 numbers?

Sorry for being novice...

Edited by Leony

Share this post


Link to post
Share on other sites

Sorry for being novice

but now "classname=TApplication" window stays in taskbar and

WinSetState("classname=TApplication","", @SW_HIDE)

doesn't hide it :)

It was always mystery for my how to calculate WM_messages

The MSDN says

I should combine $WM_SYSCOMMAND and $SC_MINIMIZE but where You wise man Zedna took the 0x0112 and 0xF020 numbers?

Sorry for being novice...

Google for "define SC_MINIMIZE" is quick.

There are also helper apps with these constants.

Share this post


Link to post
Share on other sites

I've found WINDOWS.H file has the numbers.

it seems MSDN notifications don't have parameters to hide a window...

Share this post


Link to post
Share on other sites

CODE
; it runs and hides EVEREST Ultimate window to tray so that EVEREST uses

; 7 MBytes of RAM max (2-4 usually)

; should be run from root of everest.exe directory

; sheckandar' modified script

; thanks to Zedna for exact _SendMessage code to minimize window because

; native AutoIt @SW_MINIMIZE acts not as "minimize" button for Everest and

; Everest occupies about 16 MB therefore

; to hide Everest again use its new "minimize to tray" button

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 4)

Opt("TrayMenuMode", 1)

; if EVEREST is already running - shows it:

If WinExists("EVEREST Ultimate ") Then WinSetState("EVEREST Ultimate ", "", @SW_Show)

Global $itemnum, $enum, $msg, $num, $proc, $gett, $gettif, $itemnum2, $recountt, $recount2, $bit, $state, $title, $exitc, $proclist, $upcount, $procupcount, $itemnum

Dim $trayitem1[100]

Dim $procitem[100]

Dim $trayrec[100]

Dim $proclist[100][2]

$execpath = @AutoItExe

$string1 = StringInStr($execpath, "\", 0, -1)

$string2 = StringTrimLeft($execpath, $string1)

$proclist = ProcessList($string2)

Do

$upcount = $upcount + 1

If $proclist[$upcount][0] = $string2 Then

$procupcount = $procupcount + 1

EndIf

Until $upcount = $proclist[0][0]

If $procupcount > 1 Then Exit

$trayitem2 = TrayCreateItem("Exit")

TrayCreateItem("")

TraySetState()

#include <Misc.au3>

Opt("WinTitleMatchMode", 4)

Run("everest.exe")

Global Const $WM_SYSCOMMAND = 0x0112

Global Const $SC_MINIMIZE = 0xF020

WinWaitActive("classname=TForm1")

$hWnd = WinGetHandle("classname=TForm1")

_SendMessage($hWnd, $WM_SYSCOMMAND, $SC_MINIMIZE, 0)

WinActivate ("EVEREST Ultimate Edition")

hide()

Func hide() ; <-- To hide active window

$title = ""

$proc = WinGetHandle("classname=TApplication", "")

If $itemnum > 0 Then

Do

$state = WinGetState("classname=TApplication", "")

If Not BitAND($state, 2) Then

Return

EndIf

$num = $num + 1

If $procitem[$num] = $proc Then

$gettif = TrayItemGetText($trayitem1[$num])

TrayItemDelete($trayitem1[$num])

$procitem[$num] = 0

EndIf

Until $num = $itemnum

EndIf

$num = 0

$title = WinGetTitle("classname=TApplication", "")

If @error Or $title = 1 Or $title = "" Then

Return

EndIf

$itemnum = $itemnum + 1

WinSetState($proc, "", @SW_HIDE)

$trayitem1[$itemnum] = TrayCreateItem($title)

$procitem[$itemnum] = $proc

$bit = $bit + 1

EndFunc ; <-- Complete

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

It was always mystery for my how to calculate WM_messages

The MSDN says

I should combine $WM_SYSCOMMAND and $SC_MINIMIZE but where You wise man Zedna took the 0x0112 and 0xF020 numbers?

Sorry for being novice...

Look at API Constants from gafrost

Edited by Zedna

Share this post


Link to post
Share on other sites

chause4,

You already have a thread running on this problem - just stick to one at a time please. :)

It is likely that the code does not work because this thread is nearly 5 years old and the language has moved on considerably - so please do not necro any more old threads. Those files you mention are include files - you add those lines at the top of your script so you can use the functions within the files they reference. And at least one of them is deprecated - which is why using old code is not a very good idea ;)

Finally, when you post code, please use code tags - put [autoit] before and [/autoit] after your posted code. :)

Thanks in advance. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0