Bodman Posted September 7, 2009 Share Posted September 7, 2009 Hi, I have posted a couple of probs with this script and with help I seem to have it working except when the ini file doesnt contain all 20 lines data.This is the ini file[sites]Site1=Site Number 1URL1=http://www.url1.comSite2=Site Number 2URL2=http://www.url2.comSite3=URL3=Site4=URL4=etc etc down to 20Now if I populate everyline (1 - 20) with data then the script works fine. but If say i only put data in lines 1 - 5 then as soon as i run the script a internet explorer page opens and I cannot close the script (Without terminating it)I have searched and searched what I have done wrong but I still cant see it.expandcollapse popup#include <GuiConstants.au3> #include <String.au3> Global $menustate ;Enters your 01 details (encrypted) into registry If @Error then $user = InputBox ("enter username", "please enter your 01 username","xxxxxxx01","",10, 5, 300, 20) $pass = InputBox ("enter password", "please enter your 01 password","","*",10, 5, 300, 20) $passenc = _StringEncrypt ( 1, $pass, "passkey" ) RegWrite("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Username", "REG_SZ", "ecdomain\" & $user) RegWrite("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Password", "REG_SZ", $passenc) EndIf ECAP() ;Sends the userid and pass info from registry Func Pass() $usera = RegRead ("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Username") $passenca = RegRead ("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Password") $passdec = _StringEncrypt ( 0, $passenca, "passkey" ) WinWaitActive("Connect to ecap.ecdomain.net", "" ) ControlSend("Connect to ecap.ecdomain.net", "", "Edit2", $usera) ControlSend("Connect to ecap.ecdomain.net", "", "Edit3", $passdec) ControlClick("Connect to ecap.ecdomain.net", "", "Button1") $Menustate = "" EndFunc Func ECAP() ;Read sites and URL's from ini file $site1 = IniRead("ecap.ini", "Sites", "Site1", "") $URL1 = IniRead("ecap.ini", "Sites", "URL1", "") $site2 = IniRead("ecap.ini", "Sites", "Site2", "") $URL2 = IniRead("ecap.ini", "Sites", "URL2", "") $site3 = IniRead("ecap.ini", "Sites", "Site3", "") $URL3 = IniRead("ecap.ini", "Sites", "URL3", "") $site4 = IniRead("ecap.ini", "Sites", "Site4", "") $URL4 = IniRead("ecap.ini", "Sites", "URL4", "") $site5 = IniRead("ecap.ini", "Sites", "Site5", "") $URL5 = IniRead("ecap.ini", "Sites", "URL5", "") $site6 = IniRead("ecap.ini", "Sites", "Site6", "") $URL6 = IniRead("ecap.ini", "Sites", "URL6", "") $site7 = IniRead("ecap.ini", "Sites", "Site7", "") $URL7 = IniRead("ecap.ini", "Sites", "URL7", "") $site8 = IniRead("ecap.ini", "Sites", "Site8", "") $URL8 = IniRead("ecap.ini", "Sites", "URL8", "") $site9 = IniRead("ecap.ini", "Sites", "Site9", "") $URL9 = IniRead("ecap.ini", "Sites", "URL9", "") $site10 = IniRead("ecap.ini", "Sites", "Site10", "") $URL10 = IniRead("ecap.ini", "Sites", "URL10", "") $site11 = IniRead("ecap.ini", "Sites", "Site11", "") $URL11 = IniRead("ecap.ini", "Sites", "URL11", "") $site12 = IniRead("ecap.ini", "Sites", "Site12", "") $URL12 = IniRead("ecap.ini", "Sites", "URL12", "") $site13 = IniRead("ecap.ini", "Sites", "Site13", "") $URL13 = IniRead("ecap.ini", "Sites", "URL13", "") $site14 = IniRead("ecap.ini", "Sites", "Site14", "") $URL14 = IniRead("ecap.ini", "Sites", "URL14", "") $site15 = IniRead("ecap.ini", "Sites", "Site15", "") $URL15 = IniRead("ecap.ini", "Sites", "URL15", "") $site16 = IniRead("ecap.ini", "Sites", "Site16", "") $URL16 = IniRead("ecap.ini", "Sites", "URL16", "") $site17 = IniRead("ecap.ini", "Sites", "Site17", "") $URL17 = IniRead("ecap.ini", "Sites", "URL17", "") $site18 = IniRead("ecap.ini", "Sites", "Site18", "") $URL18 = IniRead("ecap.ini", "Sites", "URL18", "") $site19 = IniRead("ecap.ini", "Sites", "Site19", "") $URL19 = IniRead("ecap.ini", "Sites", "URL19", "") $site20 = IniRead("ecap.ini", "Sites", "Site20", "") $URL20 = IniRead("ecap.ini", "Sites", "URL20", "") ;Create Menu $GUI_Handle = GuiCreate("Ecap", 199, 41,(@DesktopWidth-199)/2, (@DesktopHeight-41)/2) $Combo_1 = GUICtrlCreateCombo("Select", 10, 10, 140, 21) $sCombo = "" For $i = 1 To 20 $j = Eval("site" & $i) If $j <> "" Then $sCombo &= $j & "|" Next StringTrimRight($sCombo, 1) GUICtrlSetData($Combo_1, $sCombo, "Select") ;GUICtrlSetData($Combo_1 , $site1 & "|" & $site2 & "|" & $site3 & "|" & $site4 & "|" & $site5 & "|" & $site6 & "|" & $site7 & "|" & $site8 & "|" & $site9 & "|" & $site10 & "|" & $site11 & "|" & $site12 & "|" & $site13 & "|" & $site14 & "|" & $site15 & "|" & $site16 & "|" & $site17 & "|" & $site18 & "|" & $site19 & "|" & $site20 & "","Select") $Button_2 = GuiCtrlCreateButton("OK", 160, 10, 30, 20) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 $Menustate = GUICtrlRead($Combo_1) MsgBox(4096, "Result", $Menustate) Case $menustate = $site1 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url1 ) pass() Case $menustate = $site2 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url2 ) pass() Case $menustate = $site3 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url3 ) pass() Case $menustate = $site4 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url4 ) pass() Case $menustate = $site5 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url5 ) pass() Case $menustate = $site6 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url6 ) pass() Case $menustate = $site7 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url7 ) pass() Case $menustate = $site8 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url8 ) pass() Case $menustate = $site9 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url9 ) pass() Case $menustate = $site10 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url10 ) pass() Case $menustate = $site11 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url11 ) pass() Case $menustate = $site12 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url12 ) pass() Case $menustate = $site13 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url13 ) pass() Case $menustate = $site14 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url14 ) pass() Case $menustate = $site15 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url15 ) pass() Case $menustate = $site16 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url16 ) pass() Case $menustate = $site17 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url17 ) pass() Case $menustate = $site18 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url18 ) pass() Case $menustate = $site19 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url19 ) pass() Case $menustate = $site20 run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $url20 ) pass() EndSelect WEnd EndFuncanother member showed me how to minimise my script (as it does the same thing over and over) but I couldnt get that to work (and Im too much of a noob to be able to fix it) Thanks in advanceBod Link to comment Share on other sites More sharing options...
Valuater Posted September 7, 2009 Share Posted September 7, 2009 Maybe... expandcollapse popup#include <GuiConstants.au3> #include <String.au3> Global $menustate = "", $sCombo = "" Global $Site[21], $URL[21] ;Enters your 01 details (encrypted) into registry If @error Then $user = InputBox("enter username", "please enter your 01 username", "xxxxxxx01", "", 10, 5, 300, 20) $pass = InputBox("enter password", "please enter your 01 password", "", "*", 10, 5, 300, 20) $passenc = _StringEncrypt(1, $pass, "passkey") ;RegWrite("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Username", "REG_SZ", "ecdomain\" & $user) ;RegWrite("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Password", "REG_SZ", $passenc) EndIf ;Create Menu $GUI_Handle = GUICreate("Ecap", 199, 41, (@DesktopWidth - 199) / 2, (@DesktopHeight - 41) / 2) $Combo_1 = GUICtrlCreateCombo("Select", 10, 10, 140, 21) For $x = 1 To 20 $Site[$x] = IniRead("ecap.ini", "Sites", "Site" & $x, "") $URL = IniRead("ecap.ini", "Sites", "URL" & $x, "") If $Site[$x] <> "" Then $sCombo &= $Site[$x] & "|" Next StringTrimRight($sCombo, 1) GUICtrlSetData($Combo_1, $sCombo, "Select") $Button_2 = GUICtrlCreateButton("OK", 160, 10, 30, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 $menustate = GUICtrlRead($Combo_1) MsgBox(4096, "Result", $menustate) EndSelect If $menustate <> "" Then For $x = 1 To 20 If $Site[$x] = $menustate Then Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $URL[$x]) pass() EndIf Next $menustate = "" EndIf WEnd ;Sends the userid and pass info from registry Func Pass() $usera = RegRead("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Username") $passenca = RegRead("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Password") $passdec = _StringEncrypt(0, $passenca, "passkey") WinWaitActive("Connect to ecap.ecdomain.net", "") ControlSend("Connect to ecap.ecdomain.net", "", "Edit2", $usera) ControlSend("Connect to ecap.ecdomain.net", "", "Edit3", $passdec) ControlClick("Connect to ecap.ecdomain.net", "", "Button1") $menustate = "" EndFunc ;==>Pass 8) Link to comment Share on other sites More sharing options...
Bodman Posted September 9, 2009 Author Share Posted September 9, 2009 Thanks Valuater for that. I really appreciate it and I am now getting closer to making it work. I however get the below error when i run the script. Can anyone help.C:\test.au3 (44) : ==> Subscript used with non-Array variable.: Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $URL[$x]) Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $URL^ ERROR>Exit code: 1 Time: 5.069ThanksBod Link to comment Share on other sites More sharing options...
Manjish Posted September 9, 2009 Share Posted September 9, 2009 Why don't you just simply change your case statements to this: Case $menustate = $site17 and $url17<>"" [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
Spiff59 Posted September 9, 2009 Share Posted September 9, 2009 I don't see the point in having all the overhead to process that simple input data as an .ini file. I was bored, so I tried it as a flat file like this: ; ECAP Sites file. Format: TITLE|URL Site Number 1|http://www.url1.com Site Number 2|http://www.url2.com Site 3|http://www.url3.com Site 4|http://www.url4.com Along with: expandcollapse popup#include <Array.au3> #Include <GuiComboBox.au3> #include <GuiConstants.au3> #include <String.au3> Global $Sites_File = "ecap.sites" Global $Site_Count = 20, $Site[$Site_Count + 1], $URL[$Site_Count + 1] Global $menustate = "" ;=============================================================================== Login() Load_Sites_Table() ;Create GUI $GUI_Handle = GUICreate("Ecap", 199, 71, (@DesktopWidth - 199) / 2, (@DesktopHeight - 41) / 2) GUICtrlCreateLabel("Select Website:", 10, 10, 140, 21) $Combo_1 = GUICtrlCreateCombo("", 10, 30, 140, 21) GUICtrlSetData($Combo_1, "|" & _ArrayToString($Site, "|", 1, $Site_Count), $Site[1]) $Button_2 = GUICtrlCreateButton("OK", 160, 30, 30, 20) GUICtrlCreateLabel("Sites Loaded: " & $Site_Count, 120, 55, 140, 21) GUISetState() ;Main Loop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 $menustate = _GUICtrlComboBox_GetCurSel($Combo_1) + 1 MsgBox(4096, "Result", "Site : " & $menustate & @CRLF & $URL[$menustate]) ; Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE -new " & $URL[$menustate]) ; pass() EndSelect WEnd Exit ;=============================================================================== Func Load_Sites_Table() $file = FileOpen($Sites_File, 0) ; If @error Then ; MsgBox(16, "Fatal Error", "File: " & $Sites_File & " not found.") ; Exit ; EndIf $Site_Count = 0 While 1 $str = FileReadLine($file) If @error Then ExitLoop ; EOF If $str = "" Or StringLeft($str, 1) = ";" Then ContinueLoop ; Bypass blank lines and comments $Site_Count += 1 $str = StringSplit($str,"|") $Site[$Site_Count] = $str[1] $URL[$Site_Count] = $str[2] Wend FileClose($file) EndFunc ;------------------------------------------------------------------------------- Func Login() ;Enters your 01 details (encrypted) into registry If @error Then $user = InputBox("enter username", "please enter your 01 username", "xxxxxxx01", "", 10, 5, 300, 20) $pass = InputBox("enter password", "please enter your 01 password", "", "*", 10, 5, 300, 20) $passenc = _StringEncrypt(1, $pass, "passkey") ;RegWrite("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Username", "REG_SZ", "ecdomain\" & $user) ;RegWrite("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Password", "REG_SZ", $passenc) EndIf EndFunc ;------------------------------------------------------------------------------- Func Pass() ;Sends the userid and pass info from registry $usera = RegRead("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Username") $passenca = RegRead("HKEY_CURRENT_USER\SOFTWARE\Ecap", "Password") $passdec = _StringEncrypt(0, $passenca, "passkey") WinWaitActive("Connect to ecap.ecdomain.net", "") ControlSend("Connect to ecap.ecdomain.net", "", "Edit2", $usera) ControlSend("Connect to ecap.ecdomain.net", "", "Edit3", $passdec) ControlClick("Connect to ecap.ecdomain.net", "", "Button1") EndFunc ;==>Pass You might find something in there worth playing with. Link to comment Share on other sites More sharing options...
Bodman Posted September 10, 2009 Author Share Posted September 10, 2009 Can I just thank everyone for all the help with this. I have bashed my head for days now trying to get it to work Also a big Thanks to Spiff59 //Bod Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now