JD Community
 

Reply
 
Thread Tools Display Modes
  #1  
Old 12.09.2010, 14:58
CHRONOMASTER CHRONOMASTER is offline
Junior Loader
 
Join Date: Nov 2009
Posts: 13
Talking Captcha Sound Alert for JDownloader [AutoIt - Script Code] (Updated 9/20/2010)

Hello Everyone,


Today I'm bringing you a useful AutoIt script that should help out a few JDownloader users.

What this script does is it creates a sound alert that repeats every 5 seconds
until the alert is canceled when a captcha window in JDownloader pops up.

Requirements:
  • AutoIt v3
  • Windows XP/Vista/7

v1.1 (9/20/2010)
  • Added $Title variable to "Settings" to help non-English JDownloader users set captcha window detection.
  • Changed the default $SoundFile variable to a audio file available to all XP/Vista/7 users.

Code:
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         CRONOMASTER

 Script Function:
    Captcha Sound Alert for JDownloader

 Script Version: 1.1

 Script Date: 9/20/2010

#ce ----------------------------------------------------------------------------



; ----------- Settings ------------- ;

; Set Captcha Window Title
; English Example: "fileserve.com: Please enter" -> "Please enter"
; Italian Example: "fileserve.com: Inserire" -> "Inserire"
; Spanish Example: "fileserve.com: Por favor ingresar" -> "Por favor ingresar"
; German  Example: "fileserve.com: Bitte eingeben!" -> "Bitte eingeben!"

; Already set for English. Don't add the Colon and Space in front as it will be added automatically. 
$Title = "Please enter"  

; Set the sound intervals in milliseconds (1000 milliseconds = 1 second)
$SoundDelay = 5000

; Set path of the audio file (Example "C:\Users\USERNAME\Music\Somefile.wav")
$SoundFile = @WindowsDir & "\media\notify.wav"

; Do not change this unless needed
$DetectWindow = "[TITLE:: " & $Title & "; CLASS:SunAwtDialog]"

; When enabled it displays the current(not realtime) line number and command in the system tray icon tooltip.
$Debug = False

; -------- Settings  End ----------- ;



#include <ButtonConstants.au3>
#include <GUIButton.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

TraySetToolTip("Captcha Sound Alert for JDownloader")
If $Debug = True Then Opt("TrayIconDebug",1)
Opt("TrayAutoPause",0)
Opt("WinTitleMatchMode",2)

If Not FileExists($SoundFile) Then
    MsgBox(262144,"Script Error - Captcha Sound Alert for JDownloader", 'The file "' & $SoundFile & '" was not found.' & @CRLF & 'Please set a valid audio file in the script.')
    Exit
EndIf

While 1
    While 1
        If WinExists($DetectWindow) Then
            ExitLoop
        Else
            Sleep(250)
        EndIf
    WEnd

    $Timer = TimerInit()
    SoundPlay($SoundFile)

    $FormMain = GUICreate("Captcha Sound Alert for JDownloader", 291, 91, 367, 575, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    $ButtonOK = GUICtrlCreateButton("OK", 96, 56, 97, 25, $WS_GROUP)
    $LabelMessage = GUICtrlCreateLabel("Press OK to stop this alert.", 24, 16, 244, 27)
    GUICtrlSetFont(-1, 15, 400, 0, "Arial")
    GUICtrlSetState($ButtonOK, $GUI_FOCUS)
    GUISetState(@SW_SHOW)

    While 1
        $Msg = GUIGetMsg()

        Switch $Msg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $ButtonOK
                ExitLoop
        EndSwitch

        If TimerDiff($Timer) >= $SoundDelay Then
            SoundPlay($SoundFile)
            $Timer = TimerInit()
        EndIf
    WEnd
    GUIDelete()
    Sleep(60000)
WEnd

Last edited by CHRONOMASTER; 02.12.2010 at 16:51. Reason: Updated Script to v1.1
Reply With Quote
  #2  
Old 12.09.2010, 15:31
willemijns willemijns is offline
JD VIP
 
Join Date: Mar 2010
Posts: 354
Default

i only know autohotkey script, you detect a foreground windows change ?
__________________
list of file hosters at hxxp://www.willemijns.com/backup.htm
Reply With Quote
  #3  
Old 12.09.2010, 15:56
CHRONOMASTER CHRONOMASTER is offline
Junior Loader
 
Join Date: Nov 2009
Posts: 13
Default

Quote:
Originally Posted by willemijns View Post
i only know autohotkey script, you detect a foreground windows change ?
It will look for a window with the title "[somesite]: Please enter" with the class "SunAwtDialog" every 250ms, once the criteria is met weather in foreground or background the alert will trigger.
Reply With Quote
  #4  
Old 12.09.2010, 16:01
willemijns willemijns is offline
JD VIP
 
Join Date: Mar 2010
Posts: 354
Default

ok tks
__________________
list of file hosters at hxxp://www.willemijns.com/backup.htm
Reply With Quote
  #5  
Old 13.09.2010, 01:44
george2002 george2002 is offline
JD Alpha
 
Join Date: Jul 2010
Location: Poland
Posts: 22
Default

First i wanted to say:Great Work CHRONOMASTER !
But i have question - is there somewhere same program for linux ? i'm using puppy linux and jdownloader and i wanted to have same sound notification on linux - is there any chance for that ? or is there any trick for linux that it can play sound after popup of window ?

Thx for any answer and sorry for my poor English
george2002
Reply With Quote
  #6  
Old 13.09.2010, 04:02
CHRONOMASTER CHRONOMASTER is offline
Junior Loader
 
Join Date: Nov 2009
Posts: 13
Default

@george2002

I don't know of any, but you should be able to run JDownloader(Windows), Java, AutoIt and this script
under Wine to get it working on your Linux box.

This is only a guess as I have not tried this combo before.
Reply With Quote
  #7  
Old 13.09.2010, 08:10
drbits's Avatar
drbits drbits is offline
JD English Support (inactive)
 
Join Date: Sep 2009
Location: Physically in Los Angeles, CA, USA
Posts: 4,473
Default

For Linux, I would suggest checking the PS output for something with the specified name. You can even use wildcards.

I think there is a beep command in Linux.
Reply With Quote
  #8  
Old 13.09.2010, 20:14
george2002 george2002 is offline
JD Alpha
 
Join Date: Jul 2010
Location: Poland
Posts: 22
Default

@CHRONOMASTER thx for that suggestion but i have HP Thin Client T5520 @ 800MHz/128MB RAM + external USB HDD and Puppy linux works great on this configuration, i tried windows xp and it was too slow and took too much RAM (when RAM goes above 128MB then windows started write on HDD as RAM and that was annoying because HDD worked all time )
In Linux i configured everything:SAMBA, UPnP,WIFI to act as AP, and jdownloader to start automaticly and now i wanted to have sound on popup window when jdownloader asks for type the captcha, and this question goes for drbits
Could you expand your idea more and describe how i can do that in linux with this ,,PS output" or ,,wildcards" ot somthing else, because i'm novice in linux and i I do not understand what you mean by ,,PS output" and ,,Wildcards"
Could you give here some examples or links to pages with some examples how to enable sound when window from jdownloader popups ?

PS.
Beep command is smallest problem

thank you in advance for your reply
george2002
Reply With Quote
  #9  
Old 14.09.2010, 05:00
CHRONOMASTER CHRONOMASTER is offline
Junior Loader
 
Join Date: Nov 2009
Posts: 13
Default

@george2002

All I can do is suggest that you give Wine a try.

http://puppylinux.org/wikka/Wine
http://en.wikipedia.org/wiki/Wine_(software)
Reply With Quote
  #10  
Old 14.09.2010, 09:46
drbits's Avatar
drbits drbits is offline
JD English Support (inactive)
 
Join Date: Sep 2009
Location: Physically in Los Angeles, CA, USA
Posts: 4,473
Default

The PS command (with the appropriate parameters) allows you to list information about all of the processes (and I think threads). If you grep the output of ps -e (I think) grep will return a different value when it finds an occurrence than when it does not.

It has been years since I did this, so this is probably not right (the parameters changed) You are looking for a script something like:

Code:
while (`ps -e | grep "java.*"') {
    if (`ps -e --windowtitle | grep "*.?\Please Enter"') beep 700 2
    sleep 2
    }
sleep sleeps up to that number of seconds. It is like cron in that it uses the end of a second to update, rather than the passage of time. So `sleep 2` should sleep 1 to 2 seconds.

If the beep parameters are as I remember them, this is a request for a 2 second beep at 700Hz (A above middle C). That is the same frequency as most beeping alarm clocks. Almost nobody can sleep through it. We used to play songs by using beep followed by pairs of numbers.

Note that the conditionals are enclosed in accent characters ` ` so that they will be interpreted each time. This would be more efficient in TEMACS or AWK, but a lot harder to write.

As to regular expressions, they have changed a little over the years. Look at the documentation in the JDownloader Wiki.

I have been locked in the Windows world almost full time since 1996. Every so often, I get a chance to work in *nix for things like build scripts.

Last edited by drbits; 14.09.2010 at 09:49.
Reply With Quote
  #11  
Old 14.09.2010, 18:49
george2002 george2002 is offline
JD Alpha
 
Join Date: Jul 2010
Location: Poland
Posts: 22
Default

Quote:
Originally Posted by CHRONOMASTER View Post
@george2002

All I can do is suggest that you give Wine a try.

**External links are only visible to Supporters**
http://en.wikipedia.org/wiki/Wine_(software)
Thx for that suggestion but i rather stay on linux in this case but of course everyday i use windows XP but in this case linux is more tailored to my needs
It will act only as a media centre: AP,SAMBA,FTP,and jdownloader.

Quote:
Originally Posted by drbits View Post
The PS command (with the appropriate parameters) allows you to list information about all of the processes (and I think threads). If you grep the output of ps -e (I think) grep will return a different value when it finds an occurrence than when it does not.

It has been years since I did this, so this is probably not right (the parameters changed) You are looking for a script something like:

Code:
while (`ps -e | grep "java.*"') {
    if (`ps -e --windowtitle | grep "*.?\Please Enter"') beep 700 2
    sleep 2
    }
sleep sleeps up to that number of seconds. It is like cron in that it uses the end of a second to update, rather than the passage of time. So `sleep 2` should sleep 1 to 2 seconds.

If the beep parameters are as I remember them, this is a request for a 2 second beep at 700Hz (A above middle C). That is the same frequency as most beeping alarm clocks. Almost nobody can sleep through it. We used to play songs by using beep followed by pairs of numbers.

Note that the conditionals are enclosed in accent characters ` ` so that they will be interpreted each time. This would be more efficient in TEMACS or AWK, but a lot harder to write.

As to regular expressions, they have changed a little over the years. Look at the documentation in the JDownloader Wiki.

I have been locked in the Windows world almost full time since 1996. Every so often, I get a chance to work in *nix for things like build scripts.
So this is only a theory ? as i wroted 1 post elier i'm novice in linux and things about operating on scripts overwhelm me :D if you could place a final solution for my problem from beggining to end i would be very thankful and of course other users that have same problem
Of course if someone other have a idea how to beat that problem i would be grateful for help in solving this problem


thx for any working solution
george2002
Reply With Quote
  #12  
Old 15.09.2010, 09:43
drbits's Avatar
drbits drbits is offline
JD English Support (inactive)
 
Join Date: Sep 2009
Location: Physically in Los Angeles, CA, USA
Posts: 4,473
Default

Please read http://board.jdownloader.org/showthread.php?t=15749
Reply With Quote
  #13  
Old 15.09.2010, 12:20
remi remi is offline
JD Legend
 
Join Date: Mar 2009
Location: Absurdistan
Posts: 16,373
Cool

Quote:
Originally Posted by george2002 View Post
So this is only a theory ? as i wroted 1 post elier i'm novice in linux and things about operating on scripts overwhelm me :D if you could place a final solution for my problem from beggining to end i would be very thankful and of course other users that have same problem
I admire drbits' efforts to put you on the right track with his script. You cannot expect from supporters that they write programs/scripts for you instantly.

Either you go to a linux scripting forum where scripting wizards will start discussing your problem and provide an optimal solution, or you wait until jD's devs have designed and programmed a more generic solution.
Reply With Quote
  #14  
Old 15.09.2010, 22:53
george2002 george2002 is offline
JD Alpha
 
Join Date: Jul 2010
Location: Poland
Posts: 22
Default

Quote:
Originally Posted by remi View Post
I admire drbits' efforts to put you on the right track with his script. You cannot expect from supporters that they write programs/scripts for you instantly.

Either you go to a linux scripting forum where scripting wizards will start discussing your problem and provide an optimal solution, or you wait until jD's devs have designed and programmed a more generic solution.
Hello again and thx for so quick reply but:

As i see this problem is longer than half year - in my opinion adding this future as: checkmark in options menu with link to audio file when windows with captcha appear can be done in one - maximum two days (of course, without unnecessary options) (if someone use firefox addon called download Statusbar - there is a checkmark option in options of that plugin that plays sound when downloading of file is finished - I think it should be enough and not so difficult to done) because jD's dev team are professionals in programming in my opinion and they could know that option is critical for large amount of users of jdownloader (many of them don't write here on this forum but i can bet that they would be very grateful for this option) and more users will use jdownloader then there be more $ support from them for upgrades etc
I wroted that suggestion about checkmark in options because this will resolve problems with external programs and operating systems problems - all will work on the go from jdownloader side without other programs/scripts.
This can be done faster before adding whole eventmanager

PS
Or i'm wrong and service of sounds/links to files in java is very hard to code ?
As i said i don't have programmer skills and if I am wrong then please accept my apology
And of course I could go to another forum/ programmers for solution but i think this friendly forum is for such needs
I do not expect that someone write this solution in 5 minutes but in 3-7 days is enough time for that - dodn't you agree with this ? whether there are other inhibition to do that ?
As i said:this problem is not just about me - it concerns a large number of users

Best Regards
George2002

Last edited by george2002; 15.09.2010 at 23:07.
Reply With Quote
  #15  
Old 16.09.2010, 11:20
drbits's Avatar
drbits drbits is offline
JD English Support (inactive)
 
Join Date: Sep 2009
Location: Physically in Los Angeles, CA, USA
Posts: 4,473
Default

It is not the difficulty, but the lack of development volunteers makes it take much longer before these convenience features are implemented.

Besides, an update of this kind would not be released in an update (those are for Host Plugins), but would be included in a Major release. Since I don't expect this in the next major release, it will probably be early next year before it is part of JDownloader. That is why we have been trying to find external files to solve your problem.

One of the things you should be aware of is that Linux scripting is not intended to be user friendly, just very powerful. I used to be a unix expert, but I have been stuck in Windows since 1985. The man pages are a good resource for finding out about features (start with "man tsh"). I also recommend books by O'Reilly such as Linux in a nutshell.
Reply With Quote
  #16  
Old 16.09.2010, 12:00
remi remi is offline
JD Legend
 
Join Date: Mar 2009
Location: Absurdistan
Posts: 16,373
Cool

Quote:
Originally Posted by george2002 View Post
they could know that option is critical for large amount of users of jdownloader
A year ago there was a possibility to set a sound theme in earlier versions of jD, but that feature was taken out because the devs thought it wasn't used. I'm not sure there was a sound for pop-up windows though. You see that the world can change quickly.

I think it's better to integrate such features in a more generic function such as an event/task manager, but nothing forbids you to find a good java developer to develop it now.
Reply With Quote
  #17  
Old 16.09.2010, 22:24
george2002 george2002 is offline
JD Alpha
 
Join Date: Jul 2010
Location: Poland
Posts: 22
Default

Thx for drbits and remi for reply
So there is no chance to have that wish done until next christmas... :(
Maybe there will be someone who will provide this function before next year
It would be awesome

Regards
George2002
Reply With Quote
  #18  
Old 17.09.2010, 11:37
remi remi is offline
JD Legend
 
Join Date: Mar 2009
Location: Absurdistan
Posts: 16,373
Default

As I said nothing is impossible if you can find a good java programmer. It depends on how much you want to invest in it. A few bottles of wine might be sufficient.
Reply With Quote
  #19  
Old 19.09.2010, 19:10
arsenic0 arsenic0 is offline
Modem User
 
Join Date: Sep 2010
Posts: 3
Default

Hi to all! I've a problem: script don't work!
I have copied the script code with correct variable sound file for my operating system (Windows xp SP3) into SciTE Script Editor (AutoIT v3) and saved without errors. After I open script, it's open in TrayIcon, but the sound don't work when a captcha window in JDownloader pops up.

Excuse for bad english!
Reply With Quote
  #20  
Old 20.09.2010, 10:37
CHRONOMASTER CHRONOMASTER is offline
Junior Loader
 
Join Date: Nov 2009
Posts: 13
Default

@arsenic0

Does the message "Press OK to stop this alert." pop up when the captcha window is displayed?

If it does, then maybe the sound file format is incompatible and is not being played.

I will test it in Windows XP to check compatibly, although I don't anticipate a problem other than the audio file not existing.

Last edited by CHRONOMASTER; 20.09.2010 at 10:46.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 10:28.
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.