cmoir Posted March 6, 2015 Share Posted March 6, 2015 Hi All, I am looking for some advice regarding an AutoIt script I have downloaded. In work we use a piece of software called Radmin to remotely connect to our site-PC's at various locations around the UK. I am trying to import a list of IP's into this software and the providers have advised using an AutoIt script as per link's below http://support.radmin.com/index.php?/Knowledgebase/Article/View/47/35/How-to-automatically-add-PCs-to-Radmin-Viewer-Phonebook- http://www.radmin.com/support/forum/index.php?PAGE_NAME=read&FID=30&TID=15954&TITLE_SEO=15954 The script that has been provided is below expandcollapse popup; get file name $saFile = FileOpenDialog( "Select file with computer names", @WorkingDir & "\", "All (*.*)", 1 ) If @error Then MsgBox( 0, "Error","No file selected" ) Exit EndIf ; open file with list of computer names $oFile = FileOpen( $saFile, 0 ) ; Check if file opened for reading OK If $oFile = -1 Then MsgBox( 0, "Error", "Unable to open specified file" ) Exit EndIf ; Read in lines of text until the EOF is reached While 1 $saLine = FileReadLine( $oFile ) If @error = -1 Then ExitLoop EndIf ; Activate Radmin Viewer window WinActivate( "Radmin Viewer" ) ; send 'Insert' key ( 'Add new connection' ) to Radmin Viewer Send( "{INSERT}" ) ; wait for the 'New Connection' window WinWait( "New Connection" ); ; add computer name / IP address ControlSetText( "New Connection", "", "Edit2", $saLine ) ; send 'Enter' key to add computer Send( "{ENTER}" ) Wend ; close file FileClose( $ofile ) What I am trying to do is get the IP address under "IP", and the Connection Name under "Connection Name" however with this script when i try to import from Excel it just puts the text inside the IP text box as "NAME,IP" (e.g. connection1,10.1.1.1). As you can see from the links above the providers have said "just edit it" however I have zero scripting experience and wouldnt know what to change! (I have tried fiddling about with it however been unsuccessful). The excel file i have is not complicated, it is a list of connection names and IP's as per the below. Any help at all with this would be much appreciated!!! Thanks! Link to comment Share on other sites More sharing options...
water Posted March 6, 2015 Share Posted March 6, 2015 Welcome to AutoIt and the forum! You should use the Excel UDF that comes with AutoIt to read the Excel file into an array. Check the examples in the help file for _Excel_RangeRead (when you run AutoIt 3.3.12.0) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2015 Share Posted March 6, 2015 (edited) Easiest way (leaving most of that crappy code in tact)... expandcollapse popup; get file name $saFile = FileOpenDialog("Select file with computer names", @WorkingDir & "\", "All (*.*)", 1) If @error Then MsgBox(0, "Error", "No file selected") Exit EndIf ; open file with list of computer names $oFile = FileOpen($saFile, 0) ; Check if file opened for reading OK If $oFile = -1 Then MsgBox(0, "Error", "Unable to open specified file") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $saLine = FileReadLine($oFile) If @error = -1 Then ExitLoop EndIf ; Activate Radmin Viewer window WinActivate("Radmin Viewer") ; send 'Insert' key ( 'Add new connection' ) to Radmin Viewer Send("{INSERT}") ; Split string $aID_IP = StringSplit($saLine, ",", 2) If Not IsArray($aID_IP) Then MsgBox(0, "Error", "Splitting line") Exit EndIf ; wait for the 'New Connection' window WinWait("New Connection"); ; add computer name ControlSetText("New Connection", "", "Edit2", $aID_IP[0]) ; add computer IP address ControlSetText("New Connection", "", "whatever the control is.", $aID_IP[1]) ; send 'Enter' key to add computer Send("{ENTER}") WEnd ; close file FileClose($oFile) Edited March 6, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cmoir Posted March 8, 2015 Author Share Posted March 8, 2015 Hi John, Many thanks for your reply and help!! The script you have modified is unfortunately only giving me the IP/Connection Name depending which is first in the spreadsheet. Is there any way for the script (below) to do the following: Open New Connection, Copy Cell A1, Paste into Radmin THEN Alt-Tab, Copy Cell B1, then paste into Radmin, then save connection. Then repeat for A2/B2 so on and so forth. The script currently does up until the Alt-Tab stage. expandcollapse popup; get file name $saFile = FileOpenDialog("Select file with computer names", @WorkingDir & "\", "All (*.*)", 1) If @error Then MsgBox(0, "Error", "No file selected") Exit EndIf ; open file with list of computer names $oFile = FileOpen($saFile, 0) ; Check if file opened for reading OK If $oFile = -1 Then MsgBox(0, "Error", "Unable to open specified file") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $saLine = FileReadLine($oFile) If @error = -1 Then ExitLoop EndIf ; Activate Radmin Viewer window WinActivate("Radmin Viewer") ; send 'Insert' key ( 'Add new connection' ) to Radmin Viewer Send("{INSERT}") ; Split string $aID_IP = StringSplit($saLine, ",", 2) If Not IsArray($aID_IP) Then MsgBox(0, "Error", "Splitting line") Exit EndIf ; wait for the 'New Connection' window WinWait("New Connection"); ; add computer name ControlSetText("New Connection", "", "Edit2", $aID_IP[0]) ; add computer IP address ControlSetText("New Connection", "", "whatever the control is.", $aID_IP[1]) ; send 'Enter' key to add computer Send("{ENTER}") WEnd ; close file FileClose($oFile) Any help appreciated Thanks!! Link to comment Share on other sites More sharing options...
JohnOne Posted March 8, 2015 Share Posted March 8, 2015 I had to assume all your lines where in format of "NAME,IP" as that is all the info you gave.To do that, you should really take water's advice, and use _Excel_* functions. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Solution Zedna Posted March 8, 2015 Solution Share Posted March 8, 2015 (edited) Here is my solution, I installed RAdmin Viewer to test it and it works fine also with IP containing custom port :-) so you can use: connection1,10.1.2.3 or connection1,10.1.2.3:8000 Note: As input file use TXT file saved from Excel using File/SaveAs (TXT delimited with comma) expandcollapse popup; get file name $saFile = FileOpenDialog( "Select file with computer names", @WorkingDir & "\", "All (*.*)", 1 ) If @error Then MsgBox( 0, "Error","No file selected" ) Exit EndIf ; open file with list of computer names $oFile = FileOpen( $saFile, 0 ) ; Check if file opened for reading OK If $oFile = -1 Then MsgBox( 0, "Error", "Unable to open specified file" ) Exit EndIf ; Read in lines of text until the EOF is reached While 1 $saLine = FileReadLine( $oFile ) If @error = -1 Then ExitLoop EndIf $Line = StringSplit( $saLine , ',' ) ; name,ip on each line for example: connection1,10.1.1.1 or connection1,10.1.1.1:8000 ; beware: here is no checking of correct syntax on each line! each line must be: name,ip or name,ip:port $name = $Line[1] $ip = $Line[2] $port = '' If StringInStr($ip,':') Then ; IP contains also port $ip_port = StringSplit( $ip , ':' ) ; ip:port for example: 10.1.1.1:8000 $ip = $ip_port[1] ; no checking here! $port = $ip_port[2] EndIf ; Activate Radmin Viewer window WinActivate( "Radmin Viewer" ) ; send 'Insert' key ( 'Add new connection' ) to Radmin Viewer Send( "{INSERT}" ) ; wait for the 'New Connection' window WinWait( "New Connection" ); ; add computer name / IP address ControlSetText( "New Connection", "", "Edit1", $name ) ControlSetText( "New Connection", "", "Edit2", $ip ) If $port <> '' Then ; IP contains also port ControlCommand( "New Connection", "", "Button3", "UnCheck", "" ) ; uncheck checkbox of default port ControlSetText( "New Connection", "", "Edit3", $port ) ; Port EndIf ; send 'Enter' key to add computer Send( "{ENTER}" ) Wend ; close file FileClose( $ofile ) Edited March 8, 2015 by Zedna cmoir 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
cmoir Posted March 8, 2015 Author Share Posted March 8, 2015 Thank you VERY much Zedna!! I have tested too and this works a treat I was beginning to lose hope and thought I would have to enter all these entries manually (over 1000 of them!) I can't thank you enough for the amount of time you have saved me Link to comment Share on other sites More sharing options...
Zedna Posted March 8, 2015 Share Posted March 8, 2015 You are welcome :-) I'm glad I could help with useful script. Next time use more descriptive title of topic ;-) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
lilpenny10 Posted April 4, 2017 Share Posted April 4, 2017 This thread has been great. I'm also not experienced in scripting and trying to import Name, IP and port number from separate excel cells into Radmin Test.xlsx Link to comment Share on other sites More sharing options...
kylomas Posted April 4, 2017 Share Posted April 4, 2017 lilpenny10, Did you have a question/issue? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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