Jump to content

Currenlty Anime


Recommended Posts

This is my first time trying to write a program so my experience lvl is near to 0...

I wrote the script so far by browsing this Forum (and i have to thank you all for that )

So this is a program ,named "Currently Anime" , to keep track on my Anime (did it just to become fond of Autoit...)

#cs
Currently Anime
Created By Dustov
Ver 0.01
2008
#CE

#include <GUIConstants.au3>
#NoTrayIcon

dim $currenthtml = "skata"
Global $version = "0.01"
_CheckINI ()



$mainGUI = guicreate("Currently Watching",400,570,-1,-1)
GuiSetIcon(@ScriptDir & "\icon.ico", 0)
$menu = guictrlcreatemenu("Options")
$mABOUT = guictrlcreatemenuitem("About",$menu)
guictrlcreatemenuitem("",$menu)
$mEXIT = guictrlcreatemenuitem("Exit",$menu)
$list = guictrlcreatelistview("No  |Anime                                                    |Episodes   |Staus   ",15,15,370,450)
_LISTSHOW ()
$bADD = guictrlcreatebutton("Add",15,470,100)
$bEDIT = guictrlcreatebutton("Edit",15,520,100)
$bDELETE = guictrlcreatebutton("Delete",345,520,50)
$bPLUS = guictrlcreatebutton("+",150,470,100,75)
$bHTML = guictrlcreatebutton("...",360,470,20)
guisetstate(@SW_SHOW)
$ParentWin_Pos = WinGetPos($maingui, "")
$htlmgui = guicreate("Picture",350,500,$ParentWin_Pos[0] + 410,$ParentWin_Pos[1], -1,-1,$maingui)
$IE1 = ObjCreate("Shell.Explorer.2")
$Breaktime = GUICtrlCreateObj($IE1,1,1,350,500)
guisetstate (@SW_SHOW)
guiswitch($maingui)
WinWaitActive("Currently Watching")

while 1
$msg = guigetmsg ()
Select
    case $msg = $bADD
        _Add ()
    case $msg = $bEDIT
        _Edit ()
    Case $msg = $bDELETE
        _Delete ()
    case $msg = $bPLUS
        _Plus ()
    case $msg = $bHTML
        _HTML ()
    case $msg = $mEXIT
        Exit
    case $msg = $mABOUT
        msgbox(64,"About","Version " & $version & @crlf & "Created by Dustov")
EndSelect


_EXPL ()


if $msg = $GUI_EVENT_CLOSE then Exit
WEnd


;***************************************************************************************************

********************************************************************
Func _Add ()
    $addGUI = GUIcreate("Add Anime",350,270,-1,-1,$maingui)
    guictrlcreatelabel("Anime Name:",20,35)
    $addnamein = guictrlcreateinput("",95,31,220)
    GUICtrlSetStyle(-1,$WS_TABSTOP)
    guictrlcreatelabel("Episodes:",20,90)
    $addepsin = guictrlcreateinput("",95,86,100)
    GUICtrlSetStyle(-1,$WS_TABSTOP)
    guictrlcreatelabel("Status:",20,145)
    $addstatusin = guictrlcreateinput("",95,141,100)
    GUICtrlSetStyle(-1,$WS_TABSTOP)
    $addbutt = guictrlcreatebutton("Add",125,200,100)
    GUICtrlSetStyle(-1,$WS_TABSTOP)
    guisetstate(@SW_SHOW)
    GUISwitch($addGUI)
    $x = 0
    while $x = 0
    $msg = guigetmsg (1)
    if $msg[0] = $GUI_EVENT_CLOSE Then
        if $msg[1] = $addgui Then
            GUISwitch($addGUI)
            guidelete()
            $x = 1
        EndIf
    EndIf
    
    if $msg[0] = $addbutt Then
        $addname = guictrlread($addnamein)
        $addeps = guictrlread($addepsin)
        $addstatus = guictrlread($addstatusin)
        if $addstatus = ("") then $addstatus = 0
        $additionnumber = iniread("animecur.ini","Anime0","Count",@error)
        $additionnumber = $additionnumber + 1
        iniwrite("animecur.ini","Anime" & $additionnumber,"Name",$addname)
        iniwrite("animecur.ini","Anime" & $additionnumber,"Episodes",$addeps)
        iniwrite("animecur.ini","Anime" & $additionnumber,"Status",$addstatus)
        iniwrite("animecur.ini","Anime" & $additionnumber,"HTML","http://static.anidb.net/pics/nopic.gif")
        IniWrite("animecur.ini","ANime0","Count",$additionnumber)
        $x = 1
        MsgBox(64,"Success!","Anime added...")
        guidelete($addgui)
    GUICtrlCreateListViewItem($additionnumber & "|" & $addname & "|" & $addeps & "|" & $addstatus,$list)
    EndIf
    
    
    GUISwitch($maingui)
    WEnd
    Return
EndFunc
;-------------------------------------------------------------------------------------------------------
Func _Edit ()
    $editchoice = GUICtrlRead(guictrlread($list),2)
    if $editchoice = "" then 
        msgbox(64,"Error","Please chose an Anime from the list")
        Return
    EndIf
    
    $ParentWin_Pos = WinGetPos($maingui, "")
    
    $editanimenumber = StringRegExp($editchoice,'([1-9])',1)
    $edditgui = GUICreate("Edit",300,190,$ParentWin_Pos[0] + 100,$ParentWin_Pos[1] + 100,-1,-1,$maingui)
    
    $fanimename = iniread("animecur.ini","Anime" & $editanimenumber[0],"Name","")
    $fanimeeps = iniread("animecur.ini","Anime" & $editanimenumber[0],"Episodes","")
    $fanimestatus = iniread("animecur.ini","Anime" & $editanimenumber[0],"Status","")

    $labelname = GUICtrlCreateInput($fanimename,20,40,260,50)
    $newname = Guictrlread($labelname,1)
    GUICtrlCreateLabel("Total Episodes: ",20,100,75,20)
    $oldeps = GUICtrlCreateInput($fanimeeps,95,100,25,20)
    guictrlcreatelabel("Current Episode: ",135,100,80,30)
    $barstatus = GUICtrlCreateCombo("",220,95,45)
    for $i=1 to $fanimeeps
        guictrlsetdata($barstatus,$i,$fanimestatus)
    Next
    $editbchange = guictrlcreatebutton("Change",20,150,100)
    $editbcancel = guictrlcreatebutton("Cancel",180,150,100)
    guisetstate (@SW_SHOW)
    GUISwitch($edditgui)
    $x = 0
    while $x = 0
    $msg = guigetmsg (1)
    if $msg[0] = $GUI_EVENT_CLOSE Then
        if $msg[1] = $edditgui Then
            GUISwitch($edditgui)
            guidelete()
            $x = 1
        EndIf
    EndIf
    Select
        case $msg[0] = $editbchange
            $newname = Guictrlread($labelname,1)
            $neweps = GUICtrlRead($oldeps,1)
            $newstatus = GUICtrlRead($barstatus)
            
            iniwrite("animecur.ini","Anime" & $editanimenumber[0],"Name",$newname)
            iniwrite("animecur.ini","Anime" & $editanimenumber[0],"Episodes",$neweps)
            iniwrite("animecur.ini","Anime" & $editanimenumber[0],"Status",$newstatus)
            
            msgbox(64,"Done!","Change Complete!")
            guidelete($edditgui)
            GUISwitch($maingui)
            $x=1
        case $msg[0] = $editbcancel
            guidelete($edditgui)
            GUISwitch($mainGui)
            Return
            
    EndSelect
    
WEnd
guictrldelete($list)
$list = 0
_LISTSHOW ()

            
    
    Return
EndFunc
;-----------------------------------------------------------------------------------------------
Func _Delete ()
    $delchoice = msgbox(4,"Warning!","Are you sure you want to delete current Anime from the list?")
    Select
        
    
    case $delchoice = "6" 
         $editchoice = GUICtrlRead(guictrlread($list),2)
         if $editchoice = "" then
             msgbox(64,"Error","Please chose an Anime from the list")
             Return
         EndIf
         $editanimenumber = StringRegExp($editchoice,'([1-9])',1)
         $count = iniread("animecur.ini","Anime0","Count","")
          IniDelete("animecur.ini","Anime" & $editanimenumber[0])
        
         for $i = $editanimenumber[0] + 1 to $count
             $name = iniread("animecur.ini","Anime" & $i,"Name","Not Found")
             $eps = iniread("animecur.ini","Anime" & $i,"Episodes","Not Found")
             $status = iniread("animecur.ini","Anime" & $i,"Status","Not Found")
             $shtml = iniread("animecur.ini","Anime" & $i,"HTML","Not Found")
            
             $newnumber = $i - 1
             iniwrite("animecur.ini","Anime" & $newnumber,"Name",$name)
             iniwrite("animecur.ini","Anime" & $newnumber,"Episodes",$eps)
             iniwrite("animecur.ini","Anime" & $newnumber,"Status",$status)
             iniwrite("animecur.ini","Anime" & $newnumber,"HTML",$shtml)
         Next
         inidelete("animecur.ini","Anime" & $count)
         $count = $count -1
         iniwrite("animecur.ini","Anime0","Count",$count)
     case $delchoice = "7" 
         Return
 EndSelect
 GUISwitch($mainGui)
 guictrldelete($list)
 $list = 0
 _LISTSHOW ()

        
    Return
EndFunc
;------------------------------------------------------------------------------------------------
Func _Plus ()
    $editchoice = GUICtrlRead(guictrlread($list),2)
         $callback = $editchoice
         if $editchoice = "" then
             msgbox(64,"Error","Please chose an Anime from the list")
             Return
         EndIf
    $editanimenumber = StringRegExp($editchoice,'([1-9])',1)
    $max = iniread("animecur.ini","Anime" & $editanimenumber[0],"Episodes","NotFound")
    $sttochange = iniread("animecur.ini","Anime" & $editanimenumber[0],"Status","NotFound")
    $stchanged = $sttochange + 1
    if $stchanged > $max then $stchanged = $max
    iniwrite("animecur.ini","Anime" & $editanimenumber[0],"Status",$stchanged)
    GUISwitch($mainGui)
    guictrldelete($list)
    $list = 0
    _LISTSHOW ()
    
         Return
     EndFunc
     
;---------------------------------------------------------------------------------------------------
func _HTML ()
    $editchoice = GUICtrlRead(guictrlread($list),2)
         $callback = $editchoice
         if $editchoice = "" then
             msgbox(64,"Error","Please chose an Anime from the list")
             Return
         EndIf
    $editanimenumber = StringRegExp($editchoice,'([1-9])',1)
    $htmladdgui = guicreate("Html add",250,200,-1,-1,$maingui)
    guictrlcreatelabel("Add picture Html location...",10,10)
    $htmladd = GUICtrlCreateInput("",10,30,180)
;$htmllink = guictrlread($htmladd)
    $addhtmlb = GUICtrlCreateButton("Add Html",80,60) 
    guisetstate ()
    

    
    while 1
        $msg = guigetmsg (1)
        if $msg[0] = $GUI_EVENT_CLOSE Then
            if $msg[1] = $htmladdgui Then
                GUISwitch($htmladdgui)
                guidelete()
                Return
            EndIf
        EndIf
        
        if $msg[0] = $addhtmlb Then
            $htmllink = guictrlread($htmladd)
            if $htmllink = "" then
                GUISwitch($htmladdgui)
                guidelete()
                Return
            Else
                iniwrite("animecur.ini","Anime" & $editanimenumber[0],"HTML",$htmllink)
                msgbox(64,"Success!","HTML Link Added!")
                GUISwitch($htmladdgui)
                guidelete()
                Return
            EndIf
            
        EndIf
    
    WEnd




EndFunc

            
;***************************************************************************************************

***************************************************************
Func _CheckINI ()
    $inicheck = iniread("animecur.ini","Anime0","Count","0")
    if $inicheck = 0 Then
        msgbox(0,"Notice!","This is the first time runnning the program...")
        iniwrite("animecur.ini","Anime0","Count","0")
    EndIf
    Return
EndFunc

Func _LISTSHOW ()
if $list = 0 then $list = guictrlcreatelistview("No  |Anime                                                  |Episodes   |Staus   ",15,15,370,450)
$additionnumber = iniread("animecur.ini","Anime0","Count",@error)
local $listname[$additionnumber + 1] , $listeps[$additionnumber + 1] , $liststatus[$additionnumber + 1]

for $i=1 to $additionnumber
    $listname[$i] = iniread("animecur.ini","Anime" & $i, "Name",@error)
    $listeps[$i] = iniread("animecur.ini","Anime" & $i, "Episodes",@error)
    $liststatus[$i] = iniread("animecur.ini","Anime" & $i, "Status",@error)
    GUICtrlCreateListViewItem($i & "|" & $listname[$i] & "|" & $listeps[$i] & "|" & $liststatus[$i],$list)
next
Return
EndFunc

Func _FindAnimeByNumber ($animeNO)
    $fanimename = iniread("animecur.ini","Anime" & $animeNO,"Name","")
    $fanimeeps = iniread("animecur.ini","Anime" & $animeNO,"Episodes","")
    $fanimestatus = iniread("animecur.ini","Anime" & $animeNO,"Status","")
    Return
endfunc


    
func _EXPL ()
    $editchoice = GUICtrlRead(guictrlread($list),2)
    
    if $editchoice = "" then Return

    $editanimenumber = StringRegExp($editchoice,'([1-9])',1)
    
    $html = iniread("animecur.ini","Anime" & $editanimenumber[0],"HTML","")
;msgbox(0,"x",$html)
    if $html = "" then
        return
    EndIf
    
    if $html = $currenthtml then
    ;guiswitch($maingui)
        Return
    Else
        GUISwitch($htlmgui)
        guisetstate ()
        $IE1.navigate ($html)
       
        $currenthtml = $html
        guiswitch($maingui)
    EndIf
    
    endfunc

It Works 90% for me at the moment...

My known issues are

- When Pressin the Plus (+) button the selected anime is deselected and you have to re-click on its name. I need some advice on how to keep it selected

- When Adding or Editing i cant scroll through the input boxes by tabing

- The html link GUI has scrolling bars that i dont remember having them placed there

These are the problems i see with my amateur eye...please any help will be greatly appreciated...

P.S. If you dont mind cause i intend to enrich my creation can you give me any ideas on how to make it search the anime on a site an automaticaly find its picture?

Thank you Very much....Dustov

Link to comment
Share on other sites

Do you know how to search web page source for words?

Do you know how to search for certain picture on the website? ( _IEImgGetCollection )

Do you know how to use StringRegExp to get a string from that webpage source?

It really depends on the web page. but basically you can use INETGET to get picture

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...