Sign in to follow this  
Followers 0
KeshHERE

JARVIS !!?

1 post in this topic

#1 ·  Posted (edited)

#include <Array.au3>
#include <WinAPIFiles.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#Include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <StringConstants.au3>

HotKeySet("{ESC}", "MyExit")
HotKeySet ("{F9}", "Pause")

Global $voice = ObjCreate("SAPI.SpVoice")
$sFilePath = @ScriptDir & "\Data.ini"
Global $Paused

If FileExists($sFilePath) Then
   Sleep(50)
Else
   $string="[General]"&@CRLF&"google=google"&@CRLF&"youtube=youtube"&@CRLF&"time=time"&@CRLF&"date=date"&@CRLF&"torrent=torrent"&@CRLF&"google images=google images"
   $file=FileOpen($sFilePath,1)
   FileWrite($file,$string)
   FileClose($file)
EndIf

$gui1=GUICreate("JARVIS", 250   , 150)
$input1 = GUICtrlCreateInput("", 75, 40, 100, 25)
$OK1 = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW,$gui1)
speak('How may i help you?')

While 1
   ;getting all commands for perticular func
   $google=IniRead($sFilePath, "General", 'google', "")
   $youtube=IniRead($sFilePath, "General", 'youtube', "")
   $torrent=IniRead($sFilePath, "General", 'torrent', "")
   $time=IniRead($sFilePath, "General", 'time', "")
   $date=IniRead($sFilePath, "General", 'date', "")
   $Gimages=IniRead($sFilePath, "General", 'google images', "")

   $googleJ=StringSplit($google,",")
   $timeJ=StringSplit($time,",")
   $dateJ=StringSplit($date,",")
   $youtubeJ=StringSplit($youtube,",")
   $torrentJ=StringSplit($torrent,",")
   $GimagesJ=StringSplit($Gimages,",")

   Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         Exit
      Case $ok1
         ;checking if given command exist in any of the func
         $i=_ArraySearch($googleJ,GUICtrlRead ($input1), 0, 0, 0, 0, 1)
         $k=_ArraySearch($torrentJ,GUICtrlRead ($input1), 0, 0, 0, 0, 1)
         $j=_ArraySearch($youtubeJ,GUICtrlRead ($input1), 0, 0, 0, 0, 1)
         $l=_ArraySearch($timeJ,GUICtrlRead ($input1), 0, 0, 0, 0, 1)
         $m=_ArraySearch($dateJ,GUICtrlRead ($input1), 0, 0, 0, 0, 1)
         $n=_ArraySearch($GimagesJ,GUICtrlRead ($input1), 0, 0, 0, 0, 1)

         If $i<>-1 Then
            google()
         ElseIf $j<>-1 Then
            youtube()
         ElseIf $k<>-1 Then
            torrent()
         ElseIf $l<>-1 Then
            speak('time')
         ElseIf $m<>-1 Then
            speak('date')
         ElseIf $n<>-1 Then
            Gimages()
         Else
            speak("command not found, would you like to add?")
            edit()
         EndIf
   EndSwitch
WEnd


Func Gimages()
   $guin = GUICreate("JARVIS:Gimages",250,150)
   $inputn=  GUICtrlCreateInput("", 25, 40, 200, 25)
   $OKn = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
   GUISetState(@SW_SHOW,$guin)
   speak("what would you like to search?")
   While 2
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
               ExitLoop
            Case $okn
               Sleep(1000)
               $search= GUICtrlRead($inputn)
               ShellExecute("https://images.google.com/?q="&$search)
               Sleep(4000)
               Send("{ENTER}")
               Sleep(1000)
               GUIDelete($guin)
               Sleep(1000)
               speak("search is complete sir.")
               ExitLoop
         EndSwitch
   WEnd
EndFunc

Func torrent()
   $gui3 = GUICreate("JARVIS:torrent",250,150)
   $input3=  GUICtrlCreateInput("", 25, 40, 200, 25)
   $OK3 = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
   GUISetState(@SW_SHOW,$gui3)
   speak("what would you like to search?")
   While 4
   Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         ExitLoop
      Case $ok3
         $string= GUICtrlRead($input3)
         $search=StringReplace($string," ","{+}")
         ShellExecute("https://kat.cr/usearch/"&$string&"/")
         Sleep(2000)
         Send("^t")

         Send("https://isohunt.to/torrents/?ihq="&$search)
         Send("{ENTER}")
         Sleep(2000)
         Send("^t")

         Send("http://www.torrentz.eu/search?q="&$search)
         Send("{ENTER}")
         Sleep(2000)
         GUIDelete($gui3)
         Sleep(2000)
         speak("search is complete sir.")
         ExitLoop
   EndSwitch

   WEnd
EndFunc

Func youtube()
   $gui8 = GUICreate("JARVIS:youtube",250,150)
   $input8=  GUICtrlCreateInput("", 25, 40, 200, 25)
   $OK8 = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
   GUISetState(@SW_SHOW,$gui8)
   speak("which video sir?")
   While 8
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
               ExitLoop
         Case $ok8
               $search= GUICtrlRead($input8)
               ShellExecute("https://www.youtube.com/results?search_query="&$search)
               Sleep(3000)
               GUIDelete($gui8)
               speak("search is complete sir.")
               ExitLoop

         EndSwitch

   WEnd
EndFunc

Func google()
   $gui2 = GUICreate("JARVIS:google",250,150)
   $input2=  GUICtrlCreateInput("", 25, 40, 200, 25)
   $OK2 = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
   GUISetState(@SW_SHOW,$gui2)
   speak("what would you like to search?")
   While 2
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
               ExitLoop
            Case $ok2
               Sleep(1000)
               $search= GUICtrlRead($input2)
               ShellExecute("https://www.google.co.in/search?q="&$search)
               Sleep(1000)
               GUIDelete($gui2)
               Sleep(1000)
               speak("search is complete sir.")
               ExitLoop
         EndSwitch
      WEnd

EndFunc


Func edit()
    $gui = GUICreate("JARVIS-EDIT_COMMAND_PROTOCOL",250,150)
    $yes = GUICtrlCreateRadio("YES", 10, 10, 120, 20)
    $no = GUICtrlCreateRadio("NO", 10, 40, 120, 20)
    GUICtrlSetState($yes, $GUI_CHECKED)
    $OK = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
    GUISetState(@SW_SHOW,$gui)

    Local $idMsg

    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $idMsg = $OK And BitAND(GUICtrlRead($yes), $GUI_CHECKED) = $GUI_CHECKED
                  GUIDelete($gui)
                  yes()
                  ExitLoop

            Case $idMsg = $OK And BitAND(GUICtrlRead($no), $GUI_CHECKED) = $GUI_CHECKED
                GUIDelete($gui)
                ExitLoop
        EndSelect
    WEnd
 EndFunc


Func yes()
   $guia = GUICreate("JARVIS-EDIT_COMMAND_PROTOCOL",250,150)
   $OKa = GUICtrlCreateButton("Done", 100, 120, 55, 20)
   $inputa=GUICtrlCreateInput("",10,25,200,30)
   GUICtrlCreateLabel("COMMAND",10,5,200,20)
   GUICtrlCreateLabel("FUNC",10,65,200,20)
   $inputb=GUICtrlCreateInput("",10,90,200,30)
   GUISetState(@SW_SHOW,$guia)
    Local $idMsg

    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                ExitLoop
             Case $idMsg = $OKa
                $type=IniRead($sFilePath, "General", GUICtrlRead($inputb), "")

                  $value=$type&","&GUICtrlRead($inputa)
                  IniWrite($sFilePath, "General",GUICtrlRead($inputb) , $value)
                  Local $sRead = IniRead($sFilePath, "General", GUICtrlRead($inputb), "")
                  speak("command successfully added to "& GUICtrlRead($inputb))
                  GUIDelete($guia)
                  ExitLoop
        EndSelect
    WEnd

EndFunc








Func MyExit()
   sleep(100)
   ToolTip('Script is "terminated"',0,0)
   sleep(500)
   Exit
EndFunc

Func Pause ()
   $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
 EndFunc



 Func speak($speak)
   If $speak='time' Then
      $t='speaks=hour(time) & "hour" & minute(time) & "minutes" & second(time) & "seconds"'&@CRLF&'set speech= CreateObject("sapi.spvoice")'&@CRLF&'speech.Rate = -3'&@CRLF&'speech.Speak speaks'
      FileWrite("t.vbs",$t)
      RunWait('cscript.exe "t.vbs"',"",@SW_MINIMIZE)
      FileDelete('t.vbs')
   ElseIf $speak='date' Then
      $d='speaks=date'&@CRLF&'set speech= CreateObject("sapi.spvoice")'&@CRLF&'speech.Rate = -3'&@CRLF&'speech.Speak speaks'
      FileWrite("d.vbs",$d)
      RunWait('cscript.exe "d.vbs"',"",@SW_MINIMIZE)
      FileDelete('d.vbs')
   Else
      $Voice.Speak($speak,11)
      Sleep(500)
   EndIf
EndFunc

Well, not exactly as Ironman of course, and still in progress.

SAPI included so use speaker or earphone/headphone to hear. For input you have to type it.

Any ideas, Suggestions are welcomed.

Included FUNC: -google

                           -youtube

                          -google images

                          -torrent

                          -time

                         -date

Command to access each func is FUNC name itself..

If you enter wrong command like"Search" instead of "google", then it will ask you if you want to add that command in any of FUNC. Say yes and add COMMAND "Search" in FUNC "google", so that you can now excess FUNC "google", using "Search" COMMAND.

JARVIS.au3

Edited by KeshHERE
1 person likes this

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0