AutoHotkey Community

It is currently May 27th, 2012, 11:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: February 21st, 2010, 2:04 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
GUID was already retrieved in the code of my previous post.
Code:
GUID := COM_String4GUID(pdidi+4)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 3:58 am 
Offline

Joined: February 16th, 2010, 4:01 am
Posts: 60
Sean,

A while back you offered some advice in this other thread: http://www.autohotkey.com/forum/topic18488.html

But it looks like you've changed your code here as your advice doesn't seem to work out quite right anymore. Could you please explain how to use your function to find the process using the most resources? Also, can it return based on memory usage instead of cpu usage? Returning the value of memory used would be ideal. Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 9:20 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Edit/replace the following appropriately.
Code:
"SELECT * FROM " . Class

WorkingSetSize is for memory.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 2:00 pm 
Offline

Joined: February 16th, 2010, 4:01 am
Posts: 60
It appears that I can return good data by just adjusting how I call WMI_Query() and not making any changes to the WMI_Query() function itself. Or is the value I'm getting wrong?

Code:
COM_Init()
UsedMem := WMI_Query("", "Win32_Process WHERE Name='autohotkey.exe'", "WorkingSetSize") ;Returns value with a trailing bad char
StringTrimRight, UsedMem, UsedMem, 1 ;bad char is trimmed out here
   if UsedMem > 300 ;arbitrary for now, will use later
   MsgBox, mem usage is %UsedMem%
COM_Term()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 3:28 pm 
Offline

Joined: February 16th, 2010, 4:01 am
Posts: 60
It might not matter now...found this other function that does what I need and returns the same value as Task Manager. Maybe not the best value to use, but the easiest in terms of verifying what is happening with the script.

http://www.autohotkey.com/forum/topic49199.html


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 5:39 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Your question was not it. Anyway, if you need only the value of single property then you can use as you did (with trailing `n). But, if you want to get multiple properties in a single call, you have to edit the line I mentioned.

tain wrote:
http://www.autohotkey.com/forum/topic49199.html
This code needs an update, for modern OS's, as it lacks more important data than mere working set size.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 8:26 pm 
Offline

Joined: February 16th, 2010, 4:01 am
Posts: 60
Got it. Thanks, Sean :)

Do you have documentation for how to use WMICOM somewhere? I found the COM std lib docs but nothing like that for your WMI stuff.

This other bit of code is for measuring bandwidth. It sorta works but doesn't return values that match what is reported by my other WMI reporting tools (samurize, etc). Can you point out my mistakes, please?

Code:
BandwidthUsage =
Loop{
 If A_Index > 3
    Break

  BandwidthUsage += WMI_Query("\\.\root\cimv2","Win32_PerfRawData_Tcpip_NetworkInterface","BytesReceivedPerSec") ;Returns value with a trailing bad char
StringTrimRight, BandwidthUsage, BandwidthUsage, 1 ;bad char is trimmed out here
     Sleep, 1000
}
BandwidthUsage /= 3 ;average
BandwidthUsage /= 1024 ;convert from bytes to kbytes
MsgBox,, BandwidthUsage Alert, %BandwidthUsage%


I'm steering clear of the uint64 counters since the math gets weird with those. Didn't have my luck with the "formatted" counters, either. Docs here: http://msdn.microsoft.com/en-us/library ... 85%29.aspx


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 1:06 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
tain wrote:
Do you have documentation for how to use WMICOM somewhere?
MSDN is your friend for WMI.
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

First remove the trailing `n in the script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 23rd, 2010, 5:26 pm 
Sean, if I wanted to duplicate the "Scan for Hardware Changes" functionality through AHK, would CM_Reenumerate_DevNode or CM_Reenumerate_DevNode_Ex do what I'm looking for?

The sample script you provided seems designed to grab info, but in this case, I would be looking to execute an action. So how would I use your script to properly call it?


Report this post
Top
  
Reply with quote  
 Post subject: repeat wmi call
PostPosted: October 13th, 2010, 11:41 am 
Code:
Gui, Add, Edit, w200 R5 vEdit
Gui, Show

COM_Init()
wmi:=COM_GetObject("winmgmts:\\.\root\cimv2")
objRefresher := COM_CreateObject("WbemScripting.SWbemRefresher")
colItem := COM_Invoke(COM_Invoke(objRefresher, "AddEnum", "+" wmi, "Win32_Process"), "objectSet")
COM_Invoke(objRefresher, "Refresh")
COM_Invoke(objRefresher, "Refresh")

Loop
{
    penum:=COM_Invoke(colItem, "_NewEnum")
    while (COM_Enumerate(penum, obj)=0)
    {
        If(COM_Invoke(obj, "Name")="AutoHotkey.exe")
            Break
        COM_Release(obj)
    }
    List:=COM_Invoke(obj,"WorkingSetSize")/1024 "`n"
    GuiControl, , edit, %List%
    COM_Invoke(objRefresher, "Refresh")
    COM_Release(obj)
    COM_Release(penm)
    Sleep, 1000
}

This script works. But there is a problem.
Script's memory usage continues to increase. Even more than 100mb.
It seems to be increased by about 60bytes.
If minimize script to Taskbar, memory recoverd.
And then increases again.
COM_Release(obj) no effect?
Otherwise did I make the wrong?


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3

All times are UTC [ DST ]


Who is online

Users browsing this forum: iDrug and 57 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group