Thanks, Eros!
The answer in one word is "SENDKEYS".
Here is code, based upon both of ours, to do the narrowly-defined
task that I had in mind.
[code=thinbasic]uses "UI" '---Load user interface module
uses "OS"
'testqubejb.tbasic - Jonathan Berry 2007 hereby released into the public domain
'UI code by Eros Olmi
'exports a column (of numbers) from the clipboard to qubecalc, started from the
'command prompt with a batch file qu [filename]. So look for "qu " in the win handle
'runs rather more slowly than the sendkeys-only program sample of Eros Olmi
'but faster and less error prone than retyping the numbers !!!
dim clip as string = "empty"
dim newclip as string = "empty"
dim pars as integer
dim i as integer
clip = ClipBoard_GetText
dim sTitleToFind as string value "...qu ..." '"...\QUBECALC.COM..." '---This is the string to find in window caption
DIM whndl AS dword
dim Counter as long
'---Find QUBECALC window ...
whndl = win_FindByTitle(sTitleToFind)
'---If not found ...
IF whndl = 0 THEN
msgbox 0, _
"Not able to find QUBECALC window." & $crlf & _
"Please be sure QUBECALC window is opened and " & $CRLF & _
"ready to receive input before executing this script."
else
'---If you are here, correct window was found
msgbox 0, "Found at " & whndl
'---Set QUBECALC window as foreground window (give it current focus)
WIN_SETFOREGROUND(whndl)
'---Pay attention to give some time to DOS application to perform requested operation
' giving SENDKEY some sleep time. 100 to 300 mSecs seems ok. Make your tests
pars = parsecount (clip, $crlf)
for i = 1 to pars
newclip = parse$ (clip, $crlf, i)
newclip = remove$ (newclip, ANY "$, ") & "{down}"
sendkeys (newclip, 10)
' newclip = remove$ (newclip, ANY "$, ")
' sendkeys (newclip & "{down}", 10)
' using 10. It's slow no matter what number one uses. But slightly faster than sendkeys (newclip & "{down}", 10)
next ' note next i produces an error message!
msgbox 0, "All done. Bye"
END IF[/code]
Yes, it is very powerfulThe answer in one word is "SENDKEYS".
Strange initialization here, unless it is exactly what you wantdim clip as string = "empty"
In many BASIC languages (especially old ones) it is necessary to repeat the name of the variable controlling FOR/NEXT loops. thinBasic keep track of all FOR/NEXT nested loops so it is able to increment/decrement the relevant variable when a NEXT is encountered.next ' note next i produces an error message!
I'm happy I could help.
Ciao
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks