 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jtuttle
Joined: 06 Nov 2008 Posts: 26
|
Posted: Tue Jun 09, 2009 3:32 pm Post subject: IdleTorrent |
|
|
Just an idea I cooked up on the fly last night after looking for a torrent program that would run as a screen saver, the purpose of that being to always be seeding when the system is idle. Composed largely of snippets obtained from these very forums!
| Code: | Loop1:
;for when UT isn't running - wait for the system to go 15 minutes idle, then fire it up
Loop {
Sleep, 10000
if (A_TimeIdlePhysical > (15*60*1000))
goto RunUT
}
Loop2:
;for when UT has been started - watch for activity to prompt user to kill it
Loop {
Sleep, 10000
if (A_TimeIdlePhysical < 11000)
goto KillUT
}
Loop3:
;for when UT closure has been canceled by the user - wait for the system to go idle again and kick into loop1
Loop {
Sleep, 10000
if (A_TimeIdlePhysical > (15*60*1000))
goto Loop1
}
RunUT:
Run, "C:\Program Files\uTorrent\uTorrent.exe"
Goto Loop2
Return
KillUT:
Gui, Add, Text, x2 y2 w240 h20 , Good morning! Do you want to exit uTorrent now?
Gui, Add, Button, x12 y32 w90 h30 Default gYes, &Yes!
Gui, Add, Button, x122 y32 w90 h30 gNo, &No!
Gui, Show, x484 y224 h74 w244, IMPORTANT QUESTION
Return
GuiClose:
goto No
Yes:
Gui, Submit
DetectHiddenWindows, On
Process, Exist, utorrent.exe
WinGet, W, List, ahk_pid %ErrorLevel%
Loop %W%
{
WinGetClass, Class, % "ahk_id" W%A_Index%
If InStr( Class, "µTorrent" ) {
hWnd := W%A_Index%
Break
}}
MouseGetPos, X, Y
MouseMove, A_ScreenWidth, A_ScreenHeight, 0
PostMessage, 0x8001, 0,0x204,, ahk_id %hWnd% ; Right Click down
PostMessage, 0x8001, 0,0x205,, ahk_id %hWnd% ; Right Click Up
ControlSend,,{Up 1}{Enter},ahk_id %hWnd%
MouseMove, X, Y, 0
goto Loop1
No:
Gui, Submit
goto Loop3
;following hotkeys for testing purposes, feel free to snip out
#U::
goto KillUT
#T::
goto RunUT |
Optimizations and comments welcome, I know it's very rough. |
|
| Back to top |
|
 |
Z_Gecko Guest
|
|
| Back to top |
|
 |
jtuttle
Joined: 06 Nov 2008 Posts: 26
|
Posted: Tue Jun 09, 2009 5:31 pm Post subject: |
|
|
I don't want a screen saver specifically (monitor's set to shut off before the screen saver kicks in, anyway), I just want it to act like one, in that it turns on when the system is idle, and turns off when I start to use it again.
Normally I'd just start utorrent before I go to sleep, but I always forget. |
|
| Back to top |
|
 |
TheLeO
Joined: 11 Jun 2005 Posts: 264 Location: England ish
|
Posted: Fri Jun 19, 2009 3:59 pm Post subject: |
|
|
Nice idea here, never thought of this./ _________________ ::
I Have Spoken
:: |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Sat Jun 20, 2009 3:15 pm Post subject: |
|
|
Here is a very simplefied version without any special feature. It just waits until idle is detected and starts the application. After that, the script execution ends. Thats all.
| Code: | #NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
; Settings
ProgramPath = C:\Program Files\uTorrent\uTorrent.exe
IdleTime = 15 ; minutes
Main:
IdleTime := IdleTime * 60 * 1000
While Not A_TimeIdlePhysical > IdleTime
Sleep, 10000
Run(ProgramPath)
Return
Run(_FilePath)
{
Run, %_FilePath%
Return
}
|
|
|
| Back to top |
|
 |
Gauss
Joined: 10 Sep 2009 Posts: 203
|
Posted: Wed Sep 30, 2009 11:21 pm Post subject: |
|
|
jtuttle:
This is so useful, thank you, just one thing, can you make one that will close newsleecher same way? and not kill process?
I tried this but it doesn't work:
| Code: | 7::
DetectHiddenWindows, On
Process, Exist, Newsleecher.exe
WinGet, W, List, ahk_pid %ErrorLevel%
Loop %W%
{
WinGetClass, Class, % "ahk_id" W%A_Index%
If InStr( Class, "Newsleecher" ) {
hWnd := W%A_Index%
Break
}}
MouseGetPos, X, Y
MouseMove, A_ScreenWidth, A_ScreenHeight, 0
PostMessage, 0x8001, 0,0x204,, ahk_id %hWnd% ; Right Click down
PostMessage, 0x8001, 0,0x205,, ahk_id %hWnd% ; Right Click Up
ControlSend,,{Up 1}{Enter},ahk_id %hWnd%
MouseMove, X, Y, 0 |
|
|
| Back to top |
|
 |
widow Guest
|
Posted: Thu Oct 01, 2009 1:18 pm Post subject: |
|
|
just rename the torrentprogram to
"whatever.SCR" |
|
| Back to top |
|
 |
Gauss
Joined: 10 Sep 2009 Posts: 203
|
Posted: Thu Oct 01, 2009 1:54 pm Post subject: |
|
|
| widow wrote: | just rename the torrentprogram to
"whatever.SCR" |
ehh!.. Not sure what your talking about |
|
| Back to top |
|
 |
widow Guest
|
Posted: Thu Oct 01, 2009 3:16 pm Post subject: |
|
|
| Gauss wrote: | | widow wrote: | just rename the torrentprogram to
"whatever.SCR" |
ehh!.. Not sure what your talking about | Sorry, you have to put the renamed file in to the window folder. I.e "c:\windows\"
Then you go to display propertiers. Choose your filename. It will start automaticly because of not handling the "preview funktion" correct.
It could be done with ahk tough. It is simply commandline.
It closes when your computer goes online again. I.e you move your mouse..
Why make it harder then it is? |
|
| Back to top |
|
 |
Gauss
Joined: 10 Sep 2009 Posts: 203
|
Posted: Thu Oct 01, 2009 4:23 pm Post subject: |
|
|
| Dude, your talking about something else, totally. I asked for a way to close a program called "Newsleecher" via right click on system tray, lol |
|
| Back to top |
|
 |
widow Guest
|
Posted: Thu Oct 01, 2009 10:12 pm Post subject: |
|
|
| Gauss wrote: | | Dude, your talking about something else, totally. I asked for a way to close a program called "Newsleecher" via right click on system tray, lol | Ah sorry. I responded to this thread.
I guess i should be more clear what responding to.
As for your problem i think you can't send messages that are not supposed for the tray(window).
| Quote: |
PostMessage, 0x8001, 0,0x204,, ahk_id %hWnd% ; Right Click down
PostMessage, 0x8001, 0,0x205,, ahk_id %hWnd% ; Right Click Up |
Have you looked up them when you clicked on tray, or when the full window was open? |
|
| Back to top |
|
 |
widow Guest
|
Posted: Thu Oct 01, 2009 10:16 pm Post subject: |
|
|
nvm, it looked like i missunderstood again
Maybe you can start the .exe file? Often that opens up the main dialog. |
|
| Back to top |
|
 |
HiddenKnowledge
Joined: 30 Sep 2009 Posts: 5
|
Posted: Thu Oct 01, 2009 10:30 pm Post subject: |
|
|
| widow wrote: | just rename the torrentprogram to
"whatever.SCR" |
Would that work?
I don't think that works. |
|
| Back to top |
|
 |
widow Guest
|
Posted: Thu Oct 01, 2009 11:07 pm Post subject: |
|
|
| ImageSave wrote: | | widow wrote: | just rename the torrentprogram to
"whatever.SCR" |
Would that work?
I don't think that works. | Why should it not?
Or.. if you dont wont to waste valuable brainwork. Just test it. |
|
| Back to top |
|
 |
jtuttle
Joined: 06 Nov 2008 Posts: 26
|
Posted: Sat Feb 13, 2010 9:49 pm Post subject: |
|
|
Well, I ressurrected this idea after ignoring it for months. I think it works quite a bit better now.
| Code: | #notrayicon
If 0 = 0 ;== command-line arguments
ExitApp
Else
{
Loop, %0%
{
param := %A_Index%
if param contains s,S
{
Goto Butts
Break
}
if param contains c,C
{
MsgBox, , Idle Torrent, No options here`, duderino!
ExitApp
Break
}
if param contains p,P,l,L
{
ExitApp
Break
}
}
}
Butts:
;running the program twice is the only way to make sure the window's open and not trayed
;this is necessary for the process close function to work, otherwise it doesn't.
Run, "C:\Program Files\uTorrent\uTorrent.exe" /BRINGTOFRONT
Sleep, 2000
Run, "C:\Program Files\uTorrent\uTorrent.exe" /BRINGTOFRONT
Sleep, 2000
Run, "C:\Windows\System32\Mystify.scr" /s
;for when UT has been started - watch for activity to prompt user to kill it
Loop {
Sleep, 1000
if (A_TimeIdlePhysical < 1100)
goto Buttes
}
Buttes:
Gui, Add, Text, x2 y2 w240 h20 , Good morning! Do you want to exit uTorrent now?
Gui, Add, Button, x12 y32 w90 h30 Default gYes, &Yes!
Gui, Add, Button, x122 y32 w90 h30 gNo, &No!
Gui, Show, h74 w244, IMPORTANT QUESTION
;uncomment the following to have it default to closing utorrent, or change it to "goto no" to default to leaving it running
;Goto Yes
Return
Yes:
Gui, Submit
Process, Exist, utorrent.exe
PostMessage, 0x12, , , , ahk_pid %ErrorLevel%
ExitApp
No:
Gui, Submit
ExitApp |
compile, rename .exe to .scr, drop in /system32, and set it as your screen saver. assumes utorrent to be in its default location in program files.
Stuff to be added: Usable settings dialog that'll let you change where utorrent is, and what normal screensaver it runs on top of itself. |
|
| 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
|