I was hoping to get help with two questions.
Question 1
I've created a very basic script to send a variable to Notepad without giving Notepad focus. The script is working fine, but the text is typed out one letter at a time (I'm using ControlSend) and I would like to have it all appear at once, as when you do a regular paste. Is that possible? It's key to keep focus on my main program and not give focus to Notepad.
This is my script (apologies in advance as it must look very inelegant to all the experts, I put this together taking bits and pieces from several places):
Code: Select all
#IfWinActive, ahk_exe SDLTradosStudio.exe
~!q::
OriginalCb := ClipboardAll ;~ back up current clipboard content
Clipboard := "" ;~ Empty clipboard
SendInput, {F6}^+{Down} ;activate source and select all text
SendInput, ^c
ClipWait, 3 ;~ Wait for content to appear on clipboard; after 3 seconds, give error message
If ErrorLevel = 1
{
ToolTip, Error`nNo text was copied to the clipboard.
SetTimer, ToolTipOff, 3000
Return
}
Source := Clipboard ;~ copy source text to variable "Source"
Clipboard := ""
SendInput, {Left}
SendInput, {F6}
Clipboard := OriginalCb ;~ restore original clipboard content
ControlSend, ,^a{Delete}, ahk_class Notepad ; delete contents of Notepad before pasting the new text
ControlSend, ,`n%Source%, ahk_class Notepad ; paste the contents of the Source variable
Return
I have a second script, also assembled from things I've found in different places, that I'm using to make Notepad stay always on top, remove the title bar and menu bar. I activate this with a hotkey when the program is active, but I'm wondering if these actions could be incorporated into the above script so I don't have to run two separate scripts. This is the script I'm currently using:
Code: Select all
^SPACE::
Winset, Alwaysontop, , A
WinSet, Style, -0xC00000, A ; Remove the active window's title bar (WS_CAPTION)
WinWait Untitled - Notepad
DllCall("SetMenu", uint, WinExist(), uint, 0) ; Remove menu bar of "last found window".
Return
Nora