 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
panterafreak
Joined: 21 May 2008 Posts: 6 Location: Michigan, US
|
Posted: Wed May 21, 2008 6:29 pm Post subject: Monitor a Window, on Title change set a new title? |
|
|
Here is my current script which works great for what I am doing, only problem is now at intermittent times the window title will change (reloads the window essentially). It changes it back to "EVE"
| Code: |
#Persistent
Ico :="c:\downloads\AM-117-g12.ico"
Menu,Tray,Icon,%Ico%
WinActivate, ahk_class triuiScreen
WinSetTitle, EVE,, Network Monitor
hIcon := DllCall( "LoadImage", UInt,0, Str,Ico, UInt,1, UInt,0, UInt,0, UInt,0x10 )
SendMessage, 0x80, 0, hIcon ,, ahk_class triuiScreen ; Small Icon
SendMessage, 0x80, 1, hIcon ,, ahk_class triuiScreen ; Big Icon
#IfWinActive ahk_class triuiScreen
+Capslock::Capslock
Capslock::WinMinimize
return
#IfWinActive
return
|
How I can have it monitor the window and when it changes, change the window title back to "Network Monitor" without activating the window? |
|
| Back to top |
|
 |
Extreminador
Joined: 05 May 2008 Posts: 22
|
Posted: Wed May 21, 2008 7:21 pm Post subject: |
|
|
You don´t need to activate the window, you can use the class or the id ot whatever to set the title with out activated.
| Code: |
WinSetTitle, ahk_class triuiScreen, , NetWork Monitor
|
|
|
| Back to top |
|
 |
panterafreak
Joined: 21 May 2008 Posts: 6 Location: Michigan, US
|
Posted: Wed May 21, 2008 7:34 pm Post subject: |
|
|
| That solves the activation thing, thanks, i figured there was a way to do that easily, now how can I monitor that window so when it changes back to "EVE" that it will set it back to "Network Monitor" or is always going to do that since the script will sit in my tray? |
|
| Back to top |
|
 |
Extreminador
Joined: 05 May 2008 Posts: 22
|
Posted: Wed May 21, 2008 7:58 pm Post subject: |
|
|
| WinGetTitle |
|
| Back to top |
|
 |
panterafreak
Joined: 21 May 2008 Posts: 6 Location: Michigan, US
|
Posted: Wed May 21, 2008 8:55 pm Post subject: |
|
|
I've modified my script as below, however I must be missing something with the loop because it isn't constantly changing the window title (messed around in the window to modify it's title by clicking around).
| Code: | #Persistent
Ico :="c:\downloads\AM-117-g12.ico"
Menu,Tray,Icon,%Ico%
Loop
{
WinGetTitle, Title, ahk_class triuiScreen
if Title = EVE
{
WinSetTitle, ahk_class triuiScreen, , Network Monitor
hIcon := DllCall( "LoadImage", UInt,0, Str,Ico, UInt,1, UInt,0, UInt,0, UInt,0x10 )
SendMessage, 0x80, 0, hIcon ,, ahk_class triuiScreen ; Small Icon
SendMessage, 0x80, 1, hIcon ,, ahk_class triuiScreen ; Big Icon
}
else if Title = Network Monitor
Return
}
#IfWinActive ahk_class triuiScreen
+Capslock::Capslock
Capslock::WinMinimize
return
#IfWinActive
return |
This will change the title if I reload the script so the if/then logic seems to be working properly. |
|
| Back to top |
|
 |
panterafreak
Joined: 21 May 2008 Posts: 6 Location: Michigan, US
|
Posted: Thu May 22, 2008 12:54 pm Post subject: |
|
|
| I got the loop to work (used Continue in place of Return on the else if part of the loop). However now autohotkey takes like 24% cpu constantly while the script is active (probably because its constantly looping to check). If this is the correct behavior i guess I don't want a continuous loop, a timer for every x number would reduce the cpu usage? |
|
| Back to top |
|
 |
CannedCheese
Joined: 21 May 2008 Posts: 85
|
Posted: Thu May 22, 2008 3:41 pm Post subject: |
|
|
| try setbatchlines |
|
| Back to top |
|
 |
panterafreak
Joined: 21 May 2008 Posts: 6 Location: Michigan, US
|
Posted: Thu May 22, 2008 5:16 pm Post subject: |
|
|
| I tried setbatchlines to 1 second and 10 second, I assume at the top of the script (right after the #persistant) however that brought usage up to 40-50%. I tried putting a "sleep, 1000" in the loop but that seems to break the loop after it changes the title the first time. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Thu May 22, 2008 10:37 pm Post subject: |
|
|
try setbatchlines -1 _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
panterafreak
Joined: 21 May 2008 Posts: 6 Location: Michigan, US
|
Posted: Fri May 23, 2008 12:16 pm Post subject: |
|
|
| Looks like I at some point messing around with the script put the Return back into the loop which seemed to break it and create that additional cpu load. I set "setbatchlines 1" and replaced the Return with Continue (again) and it seems to be working with low to no cpu load while changing the window. Thanks for all the help guys! |
|
| Back to top |
|
 |
BoBo² Guest
|
Posted: Fri May 23, 2008 1:02 pm Post subject: |
|
|
| Ceck out SetTimer to replace the resource consuming Loop. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|