Putty Session Management

Get help with using AutoHotkey and its commands and hotkeys
Posts: 2
Joined: 14 Aug 2018, 12:39

Putty Session Management

21 Oct 2019, 05:33

hi all,

I have a script that reads excel file that has 7 columns and it pastes it to putty field by field (A1,B1,C1.... and then A2,B2,C2 and so on..) and then it goes down by row and does it for specified number of times. However I'd like to add one more column at the very beginning for the script to check if: first column is : "BAYH" then open putty session "BAYH" and paste the remaining fields to that session then go down a row and then again check the first column says "BAYH" then stay with the current session (BAYH) and paste the remaining DATA in that row or if its BAYJ to switch to another putty session thats called BAYJ and paste the data from that row there. PLEASE NOTE THAT ALL SESSIONS WILL BE ALREADY OPEN AND THE SCRIPT WILL JUST NEED TO SWITCH BETWEEN SESSIONS / WINDOWS.

Code: Select all

#SingleInstance, Force

loopLen := ""
; Ctrl + F8 Initializing 
	Xl := ComObjCreate("Excel.Application") 				        ;create a handle to a new excel application
	InputBox, excelFile, Path to Excel File, Enter Full Path To Excel File (.xlsx) like C:\abc\data.xlsx 
	Xl_Workbook := Xl.Workbooks.Open(excelFile) 			;open an existing file

	; column header array
	colHeadArray := ["A","B","C","D","E","F","G"]
	InputBox, loopLen, Loop Iterations, Number of Loops
	global loopLen := loopLen

	InputBox, timeToSleep, Sleep Time, Time in ms in between actions

;controlId		:= 0

; Ctrl + F9 start the process
	;MsgBox, global %LoopLen%
	WinGet, active_id, ID, A
	puttyID := active_id
	i := 2
	while(i<=(global loopLen + 1)){
		Send, {F3}
		Send, {Enter}
		Sleep timeToSleep
		Loop % colHeadArray.Length() {
			dummy := colHeadArray[A_Index] . i ; concatenation 
			value := Xl_Workbook.Sheets(1).Range(dummy).Text

			if (A_index == 3 OR A_index == 5 OR A_index == 6){
				Send, {Del 10}
				Send, %value%
			} else {
				Send, %value%
			Sleep timeToSleep
			;ControlSend,, {enter}, ahk_id %puttyID%
			;if (A_index == 6){
			;	continue
			;} else {
				Send, {Enter}
				Sleep timeToSleep
			; skipping an enter after lot
			if (A_index == 3 OR A_index == 2 OR A_index == 5){
			} else {
				Send, {Enter}
				Sleep timeToSleep
			if (A_index == 6){
				Send, y
				Sleep timeToSleep * 4
				Send, 2
				Sleep timeToSleep * 4

; Ctrl + F10 stop the process
	if (A_IsSuspended = 1){
		paused := 0

; Ctrl + q quit the applications

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, boiler, Google [Bot], H_pro1, WeThotUWasAToad and 76 guests