Jump to content

Recommended Posts

Posted (edited)

Wouldn't

link_value = https://www.google.ro/#safe=active&q=test

be more sensible?

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Moderators
Posted (edited)

stefionesco,

When I test I get:

Row |Col 0                           |Col 1
[1] |https://www.google.ro/#safe     active&q=test = link_value

which is what I would expect.

If you create the ini files as part of your script, why not reverse the key/value pairs so as to avoid the problem?

M23

Edit: Hi water - great minds, eh?

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Hi Melba,

I do my very best to - sometimes - be one step ahead of you ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Hi, there

I'm trying to make an application that search for subtitle for some movies, on Romanian subtitle site.
It seems to be an error in my script but I can't figure where. I think it's something about the fact that the value in every section contains equal sign.
I put in every section of INI file a link with both, English and Romanian subtitle, and a link that doesn't have none of them. Every search I made result positive with both subtitles in both links.
Where is the error?

Here is the script and the data.ini file.

 

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE
Local $sSection1;Audrey Hepburn
Local $sSection2;Sean Connery
Local $sSection3;Rita Hayworth
Local $sLanguage
Local $sResult = ("Result.ini")
Local $aSection1 = IniReadSection('data.ini', 'Section1')
Local $aSection2 = IniReadSection('data.ini', 'Section2')
Local $aSection3 = IniReadSection('data.ini', 'Section3')
Local $aLanguage = IniReadSection('data.ini', 'Language')


Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("SUB Tracker", 220, 180, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

Local $idRadio1 = GUICtrlCreateRadio("Audrey Hepburn", 10, 10, 200, 20)
Local $idRadio2 = GUICtrlCreateRadio("Sean Connery", 10, 40, 200, 20)
Local $idRadio3 = GUICtrlCreateRadio("Rita Hayworth", 10, 70, 200, 20)

Local $searchbutton = GUICtrlCreateButton("SEARCH", 60, 100, 100, 25)
Local $resultbutton = GUICtrlCreateButton("SHOW RESULT", 50, 140, 120, 25)

GUICtrlSetOnEvent($resultbutton, "_Result")
GUICtrlSetOnEvent($searchbutton, "_Search")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Result()
        ShellExecute ("Result.ini")
EndFunc

Func _Search()
            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection1[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection1[$i][0])
                        $oIE = _IECreate($aSection1[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection1 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection1, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection1[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                    MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection2[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection2[$i][0])
                        $oIE = _IECreate($aSection2[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection2 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection2, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection2[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                    MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection3[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection3[$i][0])
                        $oIE = _IECreate($aSection3[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection3 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection3, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection3[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                    MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

Respect

Stef Ionesco

data.ini

Posted

There is absolutely no error checking in your script. Example: When data.ini is not available your script crashes.
Add error checking after each function call and your script will show where you hit an error.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

But data.ini is always available. 

Only the results is:

  Quote

[My Fair Lady (1964)]
Romana=Romanian
Engleza=English
[Sauce Tartare (1949)]
Romana=Romanian
Engleza=English

Expand  


and should be only this:

  Quote

[My Fair Lady (1964)]
Romana=Romanian
Engleza=English

Expand  

 

 

Posted

That was just an example. I wanted to tell you that if an error occurs it goes unnoticed.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

You mean this:

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE
Local $sSection1;Audrey Hepburn
Local $sSection2;Sean Connery
Local $sSection3;Rita Hayworth
Local $sLanguage
Local $sResult = ("Result.ini")
Local $aSection1 = IniReadSection('data.ini', 'Section1')
Local $aSection2 = IniReadSection('data.ini', 'Section2')
Local $aSection3 = IniReadSection('data.ini', 'Section3')
Local $aLanguage = IniReadSection('data.ini', 'Language')


Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("SUB Tracker", 220, 180, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

Local $idRadio1 = GUICtrlCreateRadio("Audrey Hepburn", 10, 10, 200, 20)
Local $idRadio2 = GUICtrlCreateRadio("Sean Connery", 10, 40, 200, 20)
Local $idRadio3 = GUICtrlCreateRadio("Rita Hayworth", 10, 70, 200, 20)

Local $searchbutton = GUICtrlCreateButton("SEARCH", 60, 100, 100, 25)
Local $resultbutton = GUICtrlCreateButton("SHOW RESULT", 50, 140, 120, 25)

GUICtrlSetOnEvent($resultbutton, "_Result")
GUICtrlSetOnEvent($searchbutton, "_Search")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Result()
        ShellExecute ("Result.ini")
EndFunc

Func _Search()
            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection1[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection1[$i][0])
                        $oIE = _IECreate($aSection1[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection1 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection1, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection1[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf

                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        If @error Then
                            msgbox(0,"failed",@error)
                        Else
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
                        EndIf

            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection2[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection2[$i][0])
                        $oIE = _IECreate($aSection2[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection2 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection2, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection2[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        If @error Then
                            msgbox(0,"failed",@error)
                        Else
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
                        EndIf
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection3[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection3[$i][0])
                        $oIE = _IECreate($aSection3[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection3 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection3, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection3[$i][0], $aLanguage[$j][0], $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        If @error Then
                            msgbox(0,"failed",@error)
                        Else
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
                        EndIf
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

Anyhow, the results is the same, as I said before. It marks me in the Result file ALL the links, not only the links which satisfied the condition.

The example I made before is for the first section (Radio1 - Audrey Hepburn) but didn't work well for any of the other sections.

Edit: And I don't get any error message.

Edited by stefionesco
Posted
#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE
Local $sSection1;Audrey Hepburn
Local $sSection2;Sean Connery
Local $sSection3;Rita Hayworth
Local $sLanguage
Local $sResult = ("Result.ini")
Local $aSection1 = IniReadSection('data.ini', 'Section1')
Local $aSection2 = IniReadSection('data.ini', 'Section2')
Local $aSection3 = IniReadSection('data.ini', 'Section3')
Local $aLanguage = IniReadSection('data.ini', 'Language')

Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("SUB Tracker", 220, 180, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

Local $idRadio1 = GUICtrlCreateRadio("Audrey Hepburn", 10, 10, 200, 20)
Local $idRadio2 = GUICtrlCreateRadio("Sean Connery", 10, 40, 200, 20)
Local $idRadio3 = GUICtrlCreateRadio("Rita Hayworth", 10, 70, 200, 20)

Local $searchbutton = GUICtrlCreateButton("SEARCH", 60, 100, 100, 25)
Local $resultbutton = GUICtrlCreateButton("SHOW RESULT", 50, 140, 120, 25)

GUICtrlSetOnEvent($resultbutton, "_Result")
GUICtrlSetOnEvent($searchbutton, "_Search")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Result()
        ShellExecute ("Result.ini")
EndFunc

Func _Search()

            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection1[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection1[$i][0])
                        $oIE = _IECreate($aSection1[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection1 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection1, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection1[$i][0], "", $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection2[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection2[$i][0])
                        $oIE = _IECreate($aSection2[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection2 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection2, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection2[$i][0], "", $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                SplashTextOn("Searching", "Search...", 600, 50)
                    For $i = 1 To $aSection3[0][0]
                        ControlSetText("Searching", "", "Static1", "Searching the SUB for " & $aSection3[$i][0])
                        $oIE = _IECreate($aSection3[$i][1], 1)
                        _IELoadWait($oIE)
                        $sSection3 = _IEBodyReadText($oIE)
                    For $j = 1 To $aLanguage[0][0]
                        If StringInStr($sSection3, $aLanguage[$j][0]) Then
                            IniWrite($sResult, $aSection3[$i][0], "", $aLanguage[$j][1])
                        EndIf
                    Next
                        _IEQuit($oIE)
                    Next
                        SplashOff()
                        MsgBox($MB_ICONINFORMATION, "SUB Tracker", "Done", 0)
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

I found the error. As Water said:

  On 4/17/2017 at 10:51 AM, water said:

There is absolutely no error

Expand  

Every link open a page that contain a drop-down menu that contains the word I've search, so the result was always positive. I change with some other word and now work just fine.

Now I'm thinking if it is possible to unify in some way all the "if"s in one unique "If", using something like Radio-X where X=1, or 2, or 3? The same for the Section-X. 

This example I use here have only 3 Radio buttons, but the final script will have about 40 radio buttons and I'm trying to minimize the script. Do you think it's possible?

Thanks.

 

Stef Ionesco

data.ini

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
  • Recently Browsing   0 members

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