rwg
New Member
Posts: 49
|
Post by rwg on Sept 7, 2019 1:15:20 GMT -5
the mainwindow suits my particular program's inputs and outputs. i've brought this up before but i can't paste text into my input requests. is there any reason for this ? LB must be the only software that doesn't allow such inputs.
Metro helped me out with an API fix. It works, but plays havoc in certain situations. Hope future versions accommodate this predicament.
|
|
|
Post by tsh73 on Sept 7, 2019 4:29:37 GMT -5
I do not know about reasons (except general "that's probably harder to do then it seems" but then I needed paste-able input in one of my programs, I used magic word. That is, normally I use ordinary INPUT, but then I needed more I entered "edit", and program used PROMPT. With it I could use/edit current value, paste new text, even press ESC and refuse input anything. (if I just needed clipboard I probably would use magic word "clip" instead)
|
|
rwg
New Member
Posts: 49
|
Post by rwg on Sept 7, 2019 19:31:06 GMT -5
thanks tsh73 - i've never used PROMPT ! looks like a way around my predicament. would still be ideal if i could paste directly into mainwindow. thanks
|
|
rwg
New Member
Posts: 49
|
Post by rwg on Sept 7, 2019 19:52:32 GMT -5
sorry to bug you again tsh73 i get the PROMPT solution, but what are the magic words "edit" and "clip" and how do i use them. cheers rwg
|
|
|
Post by metro on Sept 7, 2019 20:45:14 GMT -5
sorry to bug you again tsh73 i get the PROMPT solution, but what are the magic words "edit" and "clip" and how do i use them. cheers rwg
I'm not psychic, so my guess would be something like this. I'm sure Anatoly will have a more polished version. It does seem there is a limit to the number of characters the prompt will accept via copy/paste, have not tested but others may know.
[START] prompt$="Input data else Magic words <clip> or <edit> " input ""; prompt$; dar$
SELECT CASE dar$ CASE "edit" PROMPT "Edit Data ";responceVar$ dar$=responceVar$ CASE "clip" PROMPT "Copy from Clip ";responceVar2$ dar$=responceVar2$ CASE else print dar$ END SELECT
print responceVar$ print responceVar2$
input "Press enter to end or <R> to re-do " ; dar2$ dar2$=UPPER$(dar2$) if dar2$="R" goto [START]
end
|
|
rwg
New Member
Posts: 49
|
Post by rwg on Sept 8, 2019 19:17:55 GMT -5
thanks again Metro - that's working well
|
|
|
Post by tsh73 on Sept 9, 2019 15:53:34 GMT -5
Hello there Yes metro is right magic is provided by programmer Using his clipboard API code I was able to create magic input sub. It recognizes magic words "edit" and "clip"; if text is entered via PROPMPT or clipboard, it is printed next line after input prompt (after >>) so your mainwin log will still make sense. The more I look at it the more I like it. Really, with it I could read from clipboard parts of Excel table and parse it with word$ (lines delimited by CRLF, cells by TAB). Now I wonder if another magic word - medit - for multiline edit will be of use? Here it is 'magic input - LB version 'tsh73 Sept 2019 'input, string, (you can change it) recognizing two magic words ' edit - opens PROMPT (with old value$ so you can edit it) ' clip - pastes from clipboard (using extra window for JB, API for LB)
call magInput "", a$ print "You've entered : >";a$;"<"
'if you enter "edit" it will use old value of a$ call magInput "", a$ print "You've entered : >";a$;"<"
call magInput "input smth", a$ print "You've entered : >";a$;"<"
end
sub magInput prompt$, byRef value$ if prompt$="" then input val2$ 'or "?" is suppressed. Remove this line if you don't need that else input "";prompt$;" "; val2$ end if select case val2$ case "edit" if prompt$="" then prompt$="?" prompt "INPUT"+chr$(13)+prompt$; value$
print ">> ";value$ case "clip" calldll #user32, "OpenClipboard",h as long, result as long calldll #user32, "GetClipboardData",_CF_TEXT as long, txt as long if txt<>0 then value$= winstring(txt) calldll #user32, "CloseClipboard", result as void ' no-API JB version ' open "aux clip window" for text as #clipText ' #clipText "!paste" ' #clipText "!contents? value$" ' close #clipText print ">> (from a clipboard)" print ">> ";value$ case else 'use as it is value$=val2$ end select end sub
Some results - first a line (Just a line), next it is edited to (Next part will be Excel from clipboard), next is actually from Excel. ?Just a line You've entered : >Just a line< ?edit >> Next part will be Excel from clipboard You've entered : >Next part will be Excel from clipboard< input smth clip >> (from a clipboard) >> x y 0 0 0,1 0,099833416646828 0,2 0,198669330795061 0,3 0,29552020666134 0,4 0,38941834230865 You've entered : >x y 0 0 0,1 0,099833416646828 0,2 0,198669330795061 0,3 0,29552020666134 0,4 0,38941834230865 <
|
|
rwg
New Member
Posts: 49
|
Post by rwg on Sept 9, 2019 18:25:42 GMT -5
that's brilliant tsh73. i've gone for the non api version. my mainwin log would be better still if your value$ could be printed on the same line of my INPUT. boiling it down, and using ' as my magic word, I would get say ....
input "Width = ";x$ if x$ <> "'" then goto [Height] open "a" for text as #a #a "!paste" #a "!contents? a$" close #a print a$ [Height] etc ....
can you think of a way i can get my a$ printed on the same line as my input "Width = "
many thanks rwg
|
|
rwg
New Member
Posts: 49
|
Post by rwg on Sept 9, 2019 19:10:20 GMT -5
I can see that the LOCATE command positions the cursor in terms of rows and columns, but i cant find how to find the current position of the cursor.
|
|
|
Post by tsh73 on Sept 10, 2019 17:12:50 GMT -5
I wanted to say that this would involve API calls and I'm bad with API calls but it seems to be not so hard after all so here's my code I tested it only in LB 4.5.1 under Win XP and it does work for me - after INPUT, it sends key UP to a mainwin, then overwrite line with INPUT ("?" or prompt and entered data) with next PRINT (whatever you want). I really should be sleeping 'trying to send some keypresses into opened mainwin 'goal is to move caret one line up (discarded - and to the END of line) 'Have very vague idea about API - (use parts of code by Metro) please do it better
'1) get mainwin CallDLL #user32, "GetActiveWindow",_ hMainwin As uLong 'returns handle of MainWin print "hMainwin", hMainwin
'2) get a texteditor inside a mainwin CallDLL #user32, "FindWindowExA",_ hMainwin As uLong, _ 0 As uLong,_ "VW32ANSI" as ptr,_ "" as ptr,_ hWnd As uLong
print "hWnd", hWnd
i = 0 while 1 i=i+1 print print "Hello there ";i '3) make an input input a$ if a$="q" then end 'else do API trick '4) send control keys to mainwin edit call SendMessageLong hWnd, _WM_KEYDOWN, _VK_UP, 0 call SendMessageLong hWnd, _WM_KEYUP, _VK_UP, 0 'next two lines will preserve input value (like "edit" or whatever) ' line will be appended 'without them, input line will be overtyped 'call SendMessageLong hWnd, _WM_KEYDOWN, _VK_END, 0 'call SendMessageLong hWnd, _WM_KEYUP, _VK_END, 0 '5) do WAIT so control keys got processed timer 50, [nxt] wait
[nxt] timer 0 'somehow timer works for me, but SLEEP did not 'CallDLL #kernel32, "Sleep",_ ' 50 as long,_ ' ret as void
'then '6) overtype INPUT line. I add "?" so it still resembles INPUT 'you can add your input prompt print "? :You've entered: ";a$ 'this supposed to go at line with INPUT, that is, one line up wend
print "-Over-" end
Sub SendMessageLong hWnd,msg,wParam,lParam CallDLL #user32, "SendMessageA",_ hWnd As uLong, _ msg As Long,_ wParam As Long,_ lParam As Long,_ re As Long 'print "re=";re end sub
|
|
rwg
New Member
Posts: 49
|
Post by rwg on Sept 10, 2019 18:22:53 GMT -5
thnx again tsh73 - i'll mull over this. hope you get some sleep
|
|
|
Post by Rod on Sept 14, 2019 2:57:27 GMT -5
Perhaps mainwin is not the correct control? Liberty is designed to place controls like buttons and textboxes in windows. There are lots of easy ways to use those controls once placed. The mainwin was never really intended to be on show except for debugging and testing. So that's why you find it lacking functionality. You should experiment with a few of the contols, your time wont have been wasted.
|
|
|
Post by tsh73 on Sept 14, 2019 14:29:13 GMT -5
Console interface predates GUI. It was with us long ago, no wonder it still useful.
|
|