ControlSend

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
BPet102

ControlSend

22 Oct 2017, 09:29

having issue sending "Control ]" to telnet session...any suggestions? It worked in with standard "Send", but I figured "ControlSend" would make it so that the keys can't get directed to any other open windows etc. This is the entire script;

run, cmd.exe /k Telnet 192.168.1.140, , , pid1
WinWait, ahk_pid %pid1%
sleep, 100
ControlSend, ,PO,ahk_pid %PID1%
ControlSend, ,{ENTER},ahk_pid %PID1%
ControlSend, ,{ctrl down}{]}{ctrl up},ahk_pid %PID1%
ControlSend, ,quit {SPACE 4},ahk_pid %PID1%
ControlSend, ,{Enter},ahk_pid %PID1%
ControlSend, ,Exit,ahk_pid %PID1%
sleep, 5000
ControlSend, ,{Enter},ahk_pid %PID1%
wiens
Posts: 26
Joined: 08 Dec 2015, 05:22

Re: ControlSend

10 Jan 2018, 22:21

Option 1 ahk source code:
; On a 64-bit Operating System telnet.exe is used from '%windir%\WinSXS' subdirectory and not from the '%windir%\System32' subdirectory due to the default environment settings.
; To solve the problem select in the AHK compiler the 64-bit option from the list to compile the selected executable to run telnet.exe from within the compiled AHK executable, because telnet.exe is listed as a 64-bit process tab in the tasklist.
; Running the 32-bit telnet.exe from the '%windir%\System32' subdirectory will not run in a 64-bit Operating System. The 64-bit telnet.exe from the '%windir%\WinSXS' in compatibility mode will hang if operated from a 64-bit Operating System.

Run telnet.exe
Process, Exist, telnet.exe
pid := ErrorLevel
WinActivate, % "ahk_pid " pid
Sleep 1000
SendInput open 192.168.0.4{Enter}
Send {Sleep 100}
SendInput root{Enter}
Send {Sleep 100}
SendInput init 6{Enter}
Send {Sleep 50}
SendInput exit{Enter}
Send {Sleep 50}
Send {Enter}
Send {Sleep 50}
SendInput q{Enter}
ExitApp

Option 2 ahk source code when one wants to run in 32-bit Operating System mode:
; Create a shortcut file 'telnet_link.lnk' with this link as target location 'C:\Windows\explorer.exe /C,C:\Windows\System32\telnet.exe'

Run 'telnet_link.lnk
Process, Exist, telnet.exe
pid := ErrorLevel
WinActivate, % "ahk_pid " pid
Sleep 1000
SendInput open 192.168.0.4{Enter}
Send {Sleep 100}
SendInput root{Enter}
Send {Sleep 100}
SendInput init 6{Enter}
Send {Sleep 50}
SendInput exit{Enter}
Send {Sleep 50}
Send {Enter}
Send {Sleep 50}
SendInput q{Enter}
ExitApp
wiens
Posts: 26
Joined: 08 Dec 2015, 05:22

Re: ControlSend

11 Nov 2018, 04:24

In the Control Panel Telnet should be installed as additional software to Windows.

To let the script work in the 64-bit of Windows with option 2 you have to compile the AHK script with base .bin file: Unicode 64-bit.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Dobbythenerd1, Google [Bot] and 320 guests