Script help needed. Read data from clipboard and insert into this script.

Get help with using AutoHotkey and its commands and hotkeys
musiclover7
Posts: 1
Joined: 22 Jun 2018, 12:23

Script help needed. Read data from clipboard and insert into this script.

22 Jun 2018, 12:36

Looking to get some help with this script. Essentially, I want to setup a script on my box that will automatically login to our DB server and execute a few lines of SQL, inserting what I currently have copied to the windows clipboard into a specific line in the script. The spot I want to insert into, is inside of quotes, and I want to preserve the quotes. I will list the script below with the spot where I want to add what is on the clipboard, listed as CLIPBOARD Any help appreciated!!

Code: Select all

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <[email protected]>
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
run C:\Putty\putty.exe -telnet 10.48.128.112

Sleep, 5000

Send sybase{Return}

Sleep, 2000

Send ahjgn13#{Return}


Sleep, 2000

Send isql -Usa -w300 -Dims -P`cat /etc/.sapassword`{Return}

Sleep 2000

Send select data_ckey into #b from examination where data_item='[b]CLIPBOARD[/b]'{Return}

Send go{Return}

Sleep, 1000

Send delete from data_item where data_ckey in(select data_ckey from #b){Return}

Send go{Return}

Sleep, 1000

Send exit{Return}

Send exit{Return}
Last edited by joedf on 22 Jun 2018, 14:00, edited 1 time in total.
Reason: code tags
User avatar
Cerberus
Posts: 169
Joined: 12 Jan 2016, 15:46

Re: Script help needed. Read data from clipboard and insert into this script.

24 Jun 2018, 22:24

You can use the clipboard (or any other variable) by enclosing it in percentage signs, like so: %Clipboard%

By the way, are you aware that #b acts like pressing b while holding down the Windows key? If you want to send the actual hash symbol, do {#} instead of #.

If there is a chance that the clipboard might contain # or things in braces or other symbols that are special to Autohotkey, then you will probably want to do the clipboard in a SendRaw:

Code: Select all

Send select data_ckey into {#}b from examination where data_item='
SendRaw %CLIPBOARD%
Send '{Return}
P.S. SendRaw also sends # as an actual hash rather than the windows key. SendRaw will also send {Return} as a brace then the letters r e t u r n then another brace, rather than pressing the return key. Autohotkey has very good documentation where you can look up all commands and other things, like the Send command:
https://autohotkey.com/docs/commands/Send.htm
Using the clipboard:
https://autohotkey.com/docs/misc/Clipboard.htm

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, artur1884, ashiruk, hasantr, Rohwedder, Xeo786 and 45 guests