Jump to content

Some Question & Solution To Optimize


KeyOne
 Share

Recommended Posts

Hi To All

First , Sorry For My English

I'm A Real NewBie In AutoIT & Sure In Programming , But When I Saw AutoIT In A Forum I Loved IT & Decided To Write My First Script With It .. So I Searched And Read A Lot Of Post & Finally Write This Code For My Friends In PCSeven Forum That Needed This Prog ..

MmMmm .. Result Isn't Bad But I've Some Question And I Want Know How Can I Optimize This Code ..

1- How Can I Set An Image As BackGround .. ?! " Whit GUICtrlSetImage (-1 , "RSAcc.jpg") I Can't"

2- How Can I Set An Icon For Status Section In LV .. ?!

3- With Dear Siao CustomDraw Code I Can't Change Text Color In Row That $oStatus = 0 Or $oStatus = 1 After Process ..

I Would Greatly Appreciate Any Suggestion Anyone Might Improve This Code ..

RapidShare Account Checker :

#RequireAdmin
#include <IE.au3>
#include <Array.au3>
#Include <string.au3>
#Include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <ClipBoard.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

Global $userNAME[1], $passWORD[1] , $oStatus , $oTraffic , $oEXPDate , $oMSG , $chkConn , $rsFile , $totACC  , $started , $oIE , $l , $nImpFile = 0 , $regTest = 0 , $RegValue
Global $nExpAcc = 0 , $nVldAcc = 0

#Region ### START Koda GUI section ### Form=C:\Users\Keyvan\Desktop\AutoIT\Koda\Koda 2008-10-03\Forms\Test01.kxf
$RSACForm = GUICreate("PC7 RapidShare Account Checker", 867, 450, 192, 141)

;ListView "GUI"
$ListView1 = GUICtrlCreateListView("Status|Login|PassWord|Traffic (MB)|Expire Date|Message", 0, 0, 945, 408, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS))
$n=GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 80)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 5, 410)
GUICtrlSetImage (-1 , "RSAcc.jpg")

;Menu "GUI"
$FileMenu = GUICtrlCreateMenu("&File")
$ImpoMenu = GUICtrlCreateMenuItem("Import   Ctrl+I", $FileMenu)
$ExpoMenu = GUICtrlCreateMenuItem("Export    Ctrl+E", $FileMenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$ExitMenu = GUICtrlCreateMenuItem("Exit         Ctrl+X", $FileMenu)
$ProcMenu = GUICtrlCreateMenu("&Process")
$StartMenu = GUICtrlCreateMenuItem("Start   Ctrl+S", $ProcMenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$StopMenu = GUICtrlCreateMenuItem("Stop   Ctrl+P", $ProcMenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$CBMenu = GUICtrlCreateMenu("&ClipBoard")
$ICBMenu = GUICtrlCreateMenuItem("Import From ClipBoard   Ctrl+V", $CBMenu)
$HelpMenu = GUICtrlCreateMenu("&Help")
$AboutMenu = GUICtrlCreateMenuItem("About", $HelpMenu)

;StatuBar "GUI"
Dim $StatusBar1_PartsWidth[4] = [120, 240, 360, 510]
$StatusBar1 = _GUICtrlStatusBar_Create($RSACForm, $StatusBar1_PartsWidth, "", BitOR($WS_GROUP,$WS_BORDER))
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar1, "Total Accounts : 0", 0)
_GUICtrlStatusBar_SetText($StatusBar1, "Valid Accouns : 0", 1)
_GUICtrlStatusBar_SetText($StatusBar1, "Expired Accounts : 0", 2)
_GUICtrlStatusBar_SetText($StatusBar1, "Processing : 0/0", 3)
_GUICtrlStatusBar_SetBkColor($StatusBar1, 0xA0A0A0)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 20)

;HotKey "GUI"
Dim $RSACForm_AccelTable[6][2] = [["^i", $ImpoMenu],["^e", $ExpoMenu],["^x", $ExitMenu],["^s", $StartMenu],["^p", $StopMenu],["^v", $ICBMenu]]
GUISetAccelerators($RSACForm_AccelTable)
#EndRegion ### END Koda GUI section ###

$started = 0

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUICtrlSetOnEvent($StartMenu, "StartButton")
GUICtrlSetOnEvent($StopMenu, "StopButton")
GUICtrlSetOnEvent($ExitMenu, "_Exit")
GUICtrlSetOnEvent($ImpoMenu, "_GuIImport")
GUICtrlSetOnEvent($ExpoMenu, "_Export")
GUICtrlSetOnEvent($ICBMenu, "_ToClipBoard")
GUICtrlSetOnEvent($AboutMenu, "")
GUISetState(@SW_SHOW)

While 1
    Sleep(10)
    If $started Then
        _GuIStart()
    EndIf
Wend

Func _Exit()
    $started = 0
    _IEQuit($oIE)
    If $regTest == 1 Then
        RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" , "1609" , "REG_DWORD" , $RegValue)
    EndIf
    Exit
EndFunc

Func StartButton()
    $started = 1
EndFunc

Func StopButton()
    MsgBox(64, "Pc7 RS Account Checker", "stopping pgm")
    $started = 0
EndFunc

Func _ImPortFile ($tAccounts)
    Dim $clnFile[1] , $userNAME[1] , $passWORD[1]
    $clnFile[0] = 0
    
        For $x = 1 to $tAccounts[0]
            
            $aTmp1 = StringLen($tAccounts[$x])
            
            $aTmp2 = StringInStr($tAccounts[$x] , ":" )
            $aMinus1 = $aTmp1 - $aTmp2
            
            $aCheck01 = StringStripWS(StringLower(StringTrimRight($tAccounts[$x] , $aMinus1+1)),8)

            $aTmp3 = StringInStr($tAccounts[$x] , "=" )
            $aMinus2 = $aTmp1 - $aTmp3

            $aCheck02 = StringStripWS(StringLower(StringTrimRight($tAccounts[$x] , $aMinus2 +1)),8)

            if $aCheck01 == "pass" Or $aCheck01 == "password" Or $aCheck01 == "login" Or $aCheck01 == "user" Or $aCheck01 == "username" Or $aCheck01 == "accountid" Or $aCheck02 == "pass" Or $aCheck02 == "password" Or $aCheck02 == "login" Or $aCheck02 == "user" Or $aCheck02 == "username" Or $aCheck02 == "accountid" Then
                
                _ArrayAdd($clnFile, StringStripWS($tAccounts[$x],8))
                
            EndIf
        Next
                _ArrayAdd($clnFile,0)
        For $i = 1 To UBound($clnFile)-2
            $j = $i + 1
            $clnTmp1 = StringLen($clnFile[$i])
            $clnTmp2 = StringInStr($clnFile[$i] , ":" )
            $clnTmp3 = StringInStr($clnFile[$i] , "=" )
            $clnMns1 = $clnTmp1 - $clnTmp2
            $clnMns2 = $clnTmp1 - $clnTmp3
            $clnChck01 = StringLower(StringTrimRight($clnFile[$i] , $clnMns1+1))
            $clnChck02 = StringLower(StringTrimRight($clnFile[$i] , $clnMns2+1))

                $nclnTmp1 = StringLen($clnFile[$j])
                $nclnTmp2 = StringInStr($clnFile[$j] , ":" )
                $nclnTmp3 = StringInStr($clnFile[$j] , "=" )
                $nclnMns1 = $nclnTmp1 - $nclnTmp2
                $nclnMns2 = $nclnTmp1 - $nclnTmp3
                $nclnChck01 = StringLower(StringTrimRight($clnFile[$j] , $nclnMns1+1))
                $nclnChck02 = StringLower(StringTrimRight($clnFile[$j] , $nclnMns2+1))

            If $clnChck01 == "login" Or $clnChck01 == "user" Or $clnChck01 == "username" Or $clnChck01 == "accountid" Or $clnChck02 == "login" Or $clnChck02 == "user" Or $clnChck02 == "username" Or $clnChck02 == "accountid" Then
                
                If $nclnChck01 == "pass" Or $nclnChck01 == "password" Or $nclnChck02 == "pass" Or $nclnChck02 == "password" Then
                    
                    If StringLen($clnChck01) < StringLen($clnChck02) Then
                        _ArrayAdd($userNAME, StringTrimLeft($clnFile[$i],StringLen($clnChck02)+1))
                    Else
                        _ArrayAdd($userNAME, StringTrimLeft($clnFile[$i],StringLen($clnChck01)+1))
                    EndIf
                    
                    If StringLen($nclnChck01) < StringLen($nclnChck02) Then
                        _ArrayAdd($passWORD, StringTrimLeft($clnFile[$j],StringLen($nclnChck02)+1))
                    Else
                        _ArrayAdd($passWORD, StringTrimLeft($clnFile[$j],StringLen($nclnChck01)+1))
                    EndIf
                    GUICtrlSetState($StartMenu, $GUI_ENABLE)
                EndIf
            EndIf
            
        Next
        _ArrayDelete($userNAME, 0)
        _ArrayDelete($passWORD, 0)
        Dim $tAccounts[1]
        $nImpFile = $nImpFile + 1
EndFunc

Func _ISConnected()
$handle_wininet = DllOpen('WinInet.dll')

    $ret = DllCall($handle_wininet, "int", "InternetGetConnectedState", "int*", 0, "int", 0)
    If $ret[0] Then
        ;check to see if Google is online
        If Ping('www.rapidshare.com') Then
            $chkConn = 1
        Else
            $chkConn = 0
        EndIf
    Else
        $sX = "No Internet"
    EndIf
    ;MsgBox(0,"",$chkConn)

  DllClose($handle_wininet)
EndFunc

Func _RSAChecker ($userNAME,$passWORD)
_IENavigate ($oIE, "http://ssl.rapidshare.com/cgi-bin/premiumzone.cgi")
;Get LogIn Form
$oForm = _IEFormGetCollection ($oIE, 0)
$oLogIn = _IEFormElementGetCollection ($oForm,1)
$oForm2 = _IEFormGetCollection ($oIE, 0)
$oPassW = _IEFormElementGetCollection ($oForm2, 2)

;InPut UserName&PassWord
_IEFormElementSetValue($oLogIn, $userNAME)
_IEFormElementSetValue($oPassW, $passWORD)
_IEFormSubmit($oForm)
_IELoadWait($oIE)

;Status Checker
$oParas  = _IETagNameGetCollection ($oIE, "p" , 0)

If $oParas.innerText == "Your Premium Account has not been found." Then
    $oMSG = $oParas.innerText
    $oStatus = 0
    $oEXPDate = ""

    $oTraffic = ""
    $nExpAcc = $nExpAcc + 1

ElseIf $oParas.innerText == "The Account has been found, but the password is incorrect." Then
    $oMSG = $oParas.innerText
    $oStatus = 0
    $oEXPDate = ""
    $oTraffic = ""
    $nExpAcc = $nExpAcc + 1

Else
    $oMSG = $oParas.innerText
    $oStatus = 1
    $oTable = _IETableGetCollection ($oIE, 3)
    $aTableData = _IETableWriteToArray ($oTable)
    
    ;$oEXPTitle = $aTableData[2][0]
    $oEXPDate = $aTableData[3][0]
    ;MsgBox(0,$oEXPTitle,$oEXPDate)

    ;$oTRFTitle = $aTableData[4][0]
    $oTraffic = $aTableData[5][0]
    ;MsgBox(0,$oTRFTitle,$oTraffic)

    $rsFile = _GUICtrlListView_GetItemTextArray($ListView1, $l)
    
    $nVldAcc = $nVldAcc + 1
    $rsFile[2] = "Login : " & $rsFile[2]
    $rsFile[3] = "PassWord : " &$rsFile[3]
    $rsFile[4] = "Traffic : " & $oTraffic
    $rsFile[5] = "ExPire Date : " & $oEXPDate
    ;_ArrayDelete($rsFile, 1)
    _ArrayDelete($rsFile, 1)
    _ArrayDelete($rsFile, 5)
    Sleep(1)
    _IENavigate ($oIE, "http://rapidshare.com/cgi-bin/premium.cgi?logout=1")
    
EndIf
;MsgBox(0, "RapidShare Account Status!" , $oMSG)
Return $oStatus
EndFunc

Func _Export()
    If $nVldAcc > 0 Then
        $oFile = FileOpen ("RSAcc.txt" ,1)
        _FileWriteFromArray("RSAcc.txt", $rsFile & @CRLF, 1)
        FileClose($oFile)
    Else
        MsgBox(64,"PC7 RSAccountChecker" , "There Isn't Any Valid RS Account")
    EndIf
EndFunc

Func _ToListView()
    
    _GUICtrlListView_DeleteAllItems($ListView1)
    
    $totACC = UBound($userNAME)
    
    For $k = 0 To $totACC -1
        GUICtrlCreateListViewItem ("|" & $userNAME[$k]& "|" & $passWORD[$k] & "|" & "|" ,$ListView1 )
    Next
    
    ;StatusBar Part 1 "Total Accounts"
    _GUICtrlStatusBar_SetText($StatusBar1, "Total Accounts :" & $totACC, 0)     
EndFunc

Func _ToClipBoard()
    Dim $icbRecords = StringSplit(StringStripCR(ClipGet()), @LF)
        _ImPortFile ($icbRecords)
        _ToListView()
EndFunc

Func _GuIImport()
        Local $impRecords
        $tFile = FileOpenDialog("Open", @ScriptDir & "\", "Text (*.txt)", 1 + 4 )

        If $tFile Then
            $nLines = _FileCountLines ($tFile)
            ;File's Content To Array
            If $nLines > 1 Then
                If Not _FileReadToArray($tFile, $impRecords) Then
                EndIf
            _ImPortFile ($impRecords)
            _ToListView()
            EndIf
        EndIf       
EndFunc
    
Func _GuIStart()
    Dim $regTest = 0
    _ISConnected()
        If $chkConn = 1 Then ; Check Internet Connection..
            If RegRead ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" , "1609" ) <>    3 Then
                $RegValue = RegRead ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" , "1609")
                RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" , "1609" , "REG_DWORD" , 3)
                $regTest = 1
            Endif

            $oIE = _IECreate ("about:blank",1,1)
            
            For $l = 0 To UBound($userNAME)-1
            
                If $started Then    
                    GUICtrlSetState($StopMenu, $GUI_ENABLE)
                    If StringLen($userNAME[$l]) > 2 Then
                        _GUICtrlListView_ClickItem($ListView1, $l ,"left", False, 2)
                        _GUICtrlStatusBar_SetText($StatusBar1, "Processing : " & $l+1 & "/" & $totACC, 3) ;StatusBar Part4 "Processing!"
                        GUICtrlSetCursor ( $ListView1, 15 ) ;Change Cursor To Wait
                        
                        _RSAChecker ($userNAME[$l],$passWORD[$l])
                        
                        _GUICtrlListView_SetItemText($ListView1,$l, $oStatus & "|" & $userNAME[$l]& "|" & $passWORD[$l] & "|" & $oTraffic & "|" & $oEXPDate & "|" & $oMSG , -1)
                    Else
                        $oMSG = "UserName Filed Is Empty"
                        _GUICtrlListView_SetItemText($ListView1,$l, $oStatus & "|" & $userNAME[$l]& "|" & $passWORD[$l] & "|" & $oTraffic & "|" & $oEXPDate & "|" & $oMSG , -1)
                    
                    EndIf
                    
                    _GUICtrlStatusBar_SetText($StatusBar1, "Valid Accouns : " & $nVldAcc, 1) ;StatusBar Part2 "Valid Accounts"
                    _GUICtrlStatusBar_SetText($StatusBar1, "Expired Accounts : " & $nExpAcc, 2) ;StatusBar Part3 "Expired Accounts"
                EndIf   
            Next

        GUICtrlSetCursor ( $ListView1, 2 ) ;Change Cursor To Normal
        _IEQuit($oIE)

        Else    ;Http Error !
            MsgBox(16,"Warning","Http Error!")
        EndIf
        $started = 0
EndFunc
Link to comment
Share on other sites

Are you trying to set the background of your GUI???

at the moment "GUICtrlSetImage (-1 , "RSAcc.jpg")" is after a ListView control, so you are setting the icons for that.

Use GUICtrlCreatePic to set a back ground image....see helpfile, you will also need to disable it.

Next question..."I've set my background image, but my GUI is unresponsive"

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Are you trying to set the background of your GUI???

at the moment "GUICtrlSetImage (-1 , "RSAcc.jpg")" is after a ListView control, so you are setting the icons for that.

Use GUICtrlCreatePic to set a back ground image....see helpfile, you will also need to disable it.

Next question..."I've set my background image, but my GUI is unresponsive"

Dear andybiochem TnX For Your Reply ...

No I Try Set The BackGround For ListView .. Because ListView Is On Top Layer ...

Link to comment
Share on other sites

Dear andybiochem TnX For Your Reply ...

No I Try Set The BackGround For ListView .. Because ListView Is On Top Layer ...

oh, ok.

ListView controls cannot have a background image set (as far as I'm aware).

[EDIT]

looks like I might be wrong:

_GUICtrlListView_SetBkImage

see helpfile for this one.

Edited by andybiochem
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

oh, ok.

ListView controls cannot have a background image set (as far as I'm aware).

[EDIT]

looks like I might be wrong:

_GUICtrlListView_SetBkImage

see helpfile for this one.

TnX Again ..

I'm Using This Code Too , BuT Not Work .. !

_GUICtrlListView_SetBkImage($ListView1 , "RSAcc.jpg")
Link to comment
Share on other sites

TnX Again ..

I'm Using This Code Too , BuT Not Work .. !

_GUICtrlListView_SetBkImage($ListView1 , "RSAcc.jpg")

you will also need to use the ListView UDF to create the listview:

from helpfile

"At this time this function only works with _GUICtrlListView_Create"

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
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...