htopmini v0.8.3

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
MasterFocus
Posts: 146
Joined: 01 Oct 2013, 09:47
Location: Rio de Janeiro - RJ - Brasil
Contact:

Re: htop mini ?!

15 Oct 2013, 03:21

Suggestion: allow the user to toggle on/off the percentage (%) of things in the center of the respective bars.
Antonio França - git.io | github.com | ahk4.net | sites.google.com
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: htop mini ?!

15 Oct 2013, 06:54

update: v0.6.3
- Toggle Percentage in Progressbar
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
gregster
Posts: 9034
Joined: 30 Sep 2013, 06:48

Re: htop mini ?!

15 Oct 2013, 08:28

Cant reproduce your Scite problem but changed something so test it pls
The problem persists, although it changed a little bit. Now I can also hide my Scite when htopmini is already hidden (but I can't bring Scite back) and I can toggle transparency on Scite when htopmini is hidden.

But I noticed, that only happens under special circumstances: When Scite's window title starts with 'htopmini'. (But when I test a program, such circumstances aren't so unlikely. ;) )

Of course, now I know how to avoid these problems, but perhaps it is possible to finetune the title matching.
Thanks again for your efforts.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: htop mini ?!

15 Oct 2013, 08:38

Alt+TAB puzzle persists... issue of move/drag drags on... :lol:
gregster
Posts: 9034
Joined: 30 Sep 2013, 06:48

Re: htop mini ?!

15 Oct 2013, 08:54

Guest10 wrote:Alt+TAB puzzle persists... issue of move/drag drags on... :lol:
Move/drag actually works for me. But I just noticed that the RAM percentage is always like 200-350% (or even more) on my machine (but the bar is green most of the time...). The drives look fine, though...

jNizM, we are not complaining, just testing and reporting ;)


Edit: I am pretty sure, you are dividing Used/Free instead of Used/Total for the RAM percentage.
User avatar
MasterFocus
Posts: 146
Joined: 01 Oct 2013, 09:47
Location: Rio de Janeiro - RJ - Brasil
Contact:

Re: htop mini ?!

15 Oct 2013, 22:35

Hey jNizM...

TL;DR VERSION:
Here's the paste of my current version (will expire in 30 days): http://pastebin.com/1ibmmq1M
Search the code for "[MF]" to find what I've changed.
Feel free to create a v0.6.4 with my modifications or whatever you wish. :)

DETAILED VERSION:

------ {{{ 1 }}} ------

I suppose some stuff is unnecessarily slow in your code.

GlobalMemoryStatusEx() is called more than once with the same input.
You could simply store that in a variable instead of calling the function again.

In fact, GlobalMemoryStatusEx() itself can be improved.
One possibility is to make it return an object contaning all information gathered by the DllCall.
Even if you don't want to deal with objects, you could still return all that info as a delimited string or anything like that.

Code: Select all

UpdateMemory:
    GlobMemStat1 := GlobalMemoryStatusEx(1)
    GlobMemStat2 := GlobalMemoryStatusEx(2)
    GlobMemStat3 := GlobalMemoryStatusEx(3)
    GuiControl,, RAM1, % Round(GlobMemStat2 - GlobMemStat3, 2) " MB"
    GuiControl,, RAM2, % GlobMemStat3 " MB"
    GuiControl,, RAM3, % GlobMemStat2 " MB"
    GuiControl, % (GlobMemStat1 <= "75") ? "+c00FF00" : (GlobMemStat1 <= "90") ? "+cFFA500" : "+cFF0000", RAM4
    GuiControl,, RAM4, % GlobMemStat1
    GuiControl,, RAM5, % (varPerc = "1") ? Round((GlobMemStat2 - GlobMemStat3) / GlobMemStat3 * 100, 2) " %" : ""
    SetTimer, UpdateMemory, 2000
return
------ {{{ 2 }}} ------

I added some Menu, Tray, ToggleCheck calls:

Code: Select all

TogPerc:
    varPerc := (varPerc = "0") ? "1" : "0"
    Menu, Tray, ToggleCheck, Toggle Percentage
return

Transparency:
    WinGet, ct, Transparent, htopmini
    WinSet, Transparent, % ct = "150" ? "Off" : "150", htopmini
    Menu, Tray, ToggleCheck, Toggle Transparency
return

OnTop:
    WinSet, AlwaysOnTop, Toggle, htopmini
    Menu, Tray, ToggleCheck, Toggle AlwaysOnTop
return
(with this, you're supposed to use Menu, Tray, ToggleCheck, Toggle Transparency once in the auto-exec part of the script)

------ {{{ 3 }}} ------

If you add the +E0x08000000 ExStyle to your GUI, you can still click on it, but it never gets activated.
( reference: http://www.autohotkey.com/board/topic/5 ... clickable/ )
It forces you to use PostMessage, 0xA1, 2,,, htopmini instead of PostMessage, 0xA1, 2,,, A.
This causes a problem with the Show/Hide routine, so it's necessary to rewrite it:

Code: Select all

ShowHide:
    WinGet, winStyle, Style, htopmini
    If (winStyle & 0x10000000)
        WinHide, htopmini
    else
        WinShow, htopmini
return
( reference: http://www.autohotkey.com/board/topic/5 ... ntry318484 )


------ {{{ 4 }}} ------

Final notes:

[4.1] It's worth mentioning that, after all these modifications, moving the GUI around seems to misbehave sometimes - the GUI keeps getting updated but only appears at the new position when I release the mouse button. Possibly caused by the +E0x08000000 ExStyle, but I'm not quite sure.

[4.2] Another problem is that, as I modified, the Show/Hide routine only really makes sense if you're using AlwaysOnTop.
Antonio França - git.io | github.com | ahk4.net | sites.google.com
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
User avatar
MasterFocus
Posts: 146
Joined: 01 Oct 2013, 09:47
Location: Rio de Janeiro - RJ - Brasil
Contact:

Re: htop mini ?!

16 Oct 2013, 00:11

The following changes are not present in the version I previously pasted above.

A possible workaround for the Show/Hide problem is calling WinSet, AlwaysOnTop, Toggle, htopmini twice right after WinShow:

Code: Select all

ShowHide:
    WinGet, winStyle, Style, htopmini
    If (winStyle & 0x10000000)
        WinHide, htopmini
    else
    {
        WinShow, htopmini
        WinSet, AlwaysOnTop, Toggle, htopmini
        WinSet, AlwaysOnTop, Toggle, htopmini
    }
return
And here's my current UpdateMemory routine:

Code: Select all

UpdateMemory:
    GlobMemStat2 := GlobalMemoryStatusEx(2) ; total memory in MB
    GlobMemStat3 := GlobalMemoryStatusEx(3) ; free memory in MB
    GlobMemStat1 := Round(GlobMemStat2-GlobMemStat3,2) ; used memory in MB
    GuiControl,, RAM1, % GlobMemStat1 " MB"
    GlobMemStat1 := Round((GlobMemStat2-GlobMemStat3)*100/GlobMemStat2,2) ; percentage of used memory
    GuiControl,, RAM2, % GlobMemStat3 " MB"
    GuiControl,, RAM3, % GlobMemStat2 " MB"
    GuiControl, % (GlobMemStat1 <= "75") ? "+c00FF00" : (GlobMemStat1 <= "90") ? "+cFFA500" : "+cFF0000", RAM4
    GuiControl,, RAM4, % GlobMemStat1
    GuiControl,, RAM5, % (varPerc = "1") ? GlobMemStat1 " %" : ""
    SetTimer, UpdateMemory, 2000
return
I'd also like to say that it would be awesome to have the GUI update itself automatically when drives are added/removed, but I know it's not trivial to add this feature.
And, once again, thanks jNizM for this script! :)
Antonio França - git.io | github.com | ahk4.net | sites.google.com
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: htop mini ?!

16 Oct 2013, 03:33

Hi Masterfocus,

Problems with style +E0x08000000 and that PostMessage code to drag the Gui have been documented before in the old forum. The following drag-no-activate strategy by Learning one works perfectly for me on Gui's with style +E0x08000000:
http://www.autohotkey.com/board/topic/6 ... /?p=429015
User avatar
DataLife
Posts: 454
Joined: 29 Sep 2013, 19:52

Re: htop mini ?!

16 Oct 2013, 07:56

TL;DR VERSION:
Here's the paste of my current version (will expire in 30 days): http://pastebin.com/1ibmmq1M
MasterFocus, I get an error when running your version. See image below.
Attachments
htopmini_MasterFocusVersion.jpg
htopmini_MasterFocusVersion.jpg (31.58 KiB) Viewed 6944 times
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: htop mini ?!

16 Oct 2013, 08:53

because his line breaks
ill upload new version in few hours
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: htop mini ?!

16 Oct 2013, 09:25

in jNizM i trust! :lol:
jNizM wrote:because his line breaks
ill upload new version in few hours
User avatar
MasterFocus
Posts: 146
Joined: 01 Oct 2013, 09:47
Location: Rio de Janeiro - RJ - Brasil
Contact:

Re: htop mini ?!

16 Oct 2013, 12:17

lblb wrote:The following drag-no-activate strategy by Learning one works perfectly for me on Gui's with style +E0x08000000:
http://www.autohotkey.com/board/topic/6 ... /?p=429015
Thanks for pointing that out.
This method requires a hotkey to be created. ~*LButton is probably the best option, although it may interfere depending on what other scripts you're running.

I suppose there's a way of using OnMessage() to move the GUI by clicking "anywhere" on it, but I can't find it right now.
Antonio França - git.io | github.com | ahk4.net | sites.google.com
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: htop mini ?!

16 Oct 2013, 13:28

Hi Masterfocus,

You could perhaps use it as a g-label (on a picture/button or maybe a background picture?):

Label:
If Getkeystate("LButton","p")
DragNotActivate(hGui1)
Return
User avatar
MasterFocus
Posts: 146
Joined: 01 Oct 2013, 09:47
Location: Rio de Janeiro - RJ - Brasil
Contact:

Re: htop mini ?!

17 Oct 2013, 02:00

I tried using WinSet, Redraw,, the_gui_title_here but it doesn't seem to work always.

Anyway, this script made me hate my sidebar.exe for how much memory it consumes.
I've found other solutions out there with smaller memory footprints, such as Rainmeter and Samurize, but I think an AHK alternative is great.
I'm trying to modify it and create a "htopmicro" version. Here's how it looks so far (just a quick preview, really):

Image
Antonio França - git.io | github.com | ahk4.net | sites.google.com
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
User avatar
DataLife
Posts: 454
Joined: 29 Sep 2013, 19:52

Re: htop mini ?!

17 Oct 2013, 07:41

MasterFocus wrote:
lblb wrote:The following drag-no-activate strategy by Learning one works perfectly for me on Gui's with style +E0x08000000:
http://www.autohotkey.com/board/topic/6 ... /?p=429015
Thanks for pointing that out.
This method requires a hotkey to be created. ~*LButton is probably the best option, although it may interfere depending on what other scripts you're running.

I suppose there's a way of using OnMessage() to move the GUI by clicking "anywhere" on it, but I can't find it right now.

Code: Select all

; Allow moving the GUI by dragging any point in its client area.
OnMessage(0x201, "WM_LBUTTONDOWN")
WM_LBUTTONDOWN()
{
    if A_gui
      PostMessage, 0xA1, 2 ; WM_NCLBUTTONDOWN
}
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: htop mini ?!

17 Oct 2013, 08:20

where can i find MasterFocus's FULL VERSION for RAW DATA download?
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: htop mini ?!

17 Oct 2013, 08:53

Hi DataLife, this should be better:

Code: Select all

; Allow moving the GUI by dragging any point in its client area.
Gui, +hwndhMain
OnMessage(0x201, "WM_LBUTTONDOWN")
WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) 
{
	global hMain
	If (hwnd = hMain)
		PostMessage, 0xA1, 2 ; WM_NCLBUTTONDOWN
}
If use A_Gui, then click anywhere (like edit/button) inside GUI will execute that PostMessage.
kidbit
Posts: 168
Joined: 02 Oct 2013, 16:05

REMOVEME

17 Oct 2013, 09:38

[-]
Last edited by kidbit on 21 Oct 2013, 18:28, edited 1 time in total.
question := (2b) || !(2b) © Shakespeare.
User avatar
DataLife
Posts: 454
Joined: 29 Sep 2013, 19:52

Re: htop mini ?!

17 Oct 2013, 10:00

tmplinshi wrote:Hi DataLife, this should be better:

Code: Select all

; Allow moving the GUI by dragging any point in its client area.
Gui, +hwndhMain
OnMessage(0x201, "WM_LBUTTONDOWN")
WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) 
{
	global hMain
	If (hwnd = hMain)
		PostMessage, 0xA1, 2 ; WM_NCLBUTTONDOWN
}
If use A_Gui, then click anywhere (like edit/button) inside GUI will execute that PostMessage.
thank you, much better
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
lblb
Posts: 190
Joined: 30 Sep 2013, 11:31

Re: htop mini ?!

17 Oct 2013, 12:24

Maybe a mod could move this part of the thread in the help section has it is a good discussion but it's really taking the emphasis away from jNizM's great script...

In any case, Datalife and tmplinshi:
Your strategies work well to move the Gui but they don't address Masterfocus' point:
If you give the Gui a style of +E0x08000000 (which makes it clickable without stealing the focus away from the active window), then you can still use your code to move the Gui but you won't see it move in real time: it will only move once you release the mouse button. I think Learning one's code that I pointed to (maybe you can try to adapt it similarly to your code) is the most efficient solution that has been posted on the old forum to move a +E0x08000000 Gui in real time.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Bing [Bot], ewerybody, mcd, sanmaodo and 198 guests