AutoHotkey Community

It is currently May 27th, 2012, 2:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: IdleTorrent
PostPosted: June 9th, 2009, 4:32 pm 
Offline

Joined: November 6th, 2008, 7:43 pm
Posts: 26
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 9th, 2009, 4:39 pm 
Nice,
mybe you are willing to create a "real" screensaver out of this,
then this could be of help: http://www.autohotkey.com/forum/post-79973.html#79973


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 9th, 2009, 6:31 pm 
Offline

Joined: November 6th, 2008, 7:43 pm
Posts: 26
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2009, 4:59 pm 
Offline

Joined: June 11th, 2005, 9:34 am
Posts: 264
Location: England ish
Nice idea here, never thought of this./

_________________
::
I Have Spoken
::


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 4:15 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 12:21 am 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 2:18 pm 
just rename the torrentprogram to
"whatever.SCR"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 2:54 pm 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
widow wrote:
just rename the torrentprogram to
"whatever.SCR"


ehh!.. Not sure what your talking about


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 4:16 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 5:23 pm 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 11:12 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 11:16 pm 
nvm, it looked like i missunderstood again :lol:

Maybe you can start the .exe file? Often that opens up the main dialog.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 11:30 pm 
Offline

Joined: September 30th, 2009, 2:24 pm
Posts: 5
widow wrote:
just rename the torrentprogram to
"whatever.SCR"

Would that work?
I don't think that works.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2009, 12:07 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 10:49 pm 
Offline

Joined: November 6th, 2008, 7:43 pm
Posts: 26
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.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 9 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