flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] I try paste text to fasm IDE But not work.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 11:46
I do
Code:
Invoke FindWindow, "FASMW_IDE32", 0 ;ok find I checked
mov [fasmhwnd], eax ;eax not zero I checked
Invoke Setfocus, [fasmhwnd] 
Invoke SendMessages, [fasmhwnd], WM_PASTE, 0,0
    

I NOT SEE ANY TEXT IN FASMW EDITOR.

BUT MY VARIANT PASTE TEXT TO RICHEDIT WINDOW!
WHERE IS PROBLEM?


Last edited by Roman on 22 Jul 2023, 13:27; edited 1 time in total
Post 22 Jul 2023, 11:46
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 22 Jul 2023, 12:03
Did you try "FEDIT"? That is where "FASMW_IDE32" sends its WM_PASTE message. I don't think "FASMW_IDE32" processes the WM_PASTE message itself.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 22 Jul 2023, 12:03
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 12:04
FEDIT NOT FOUND.
IF I TRY FindWindow, "FEDIT", 0
I get eax=0
Post 22 Jul 2023, 12:04
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 22 Jul 2023, 12:11
Hm, I think, send IDM_PASTE (to "FASMW_IDE32") and it will send the WM_PASTE message for you.
Code:
IDM_PASTE           = 1205    
... having the source code to FASMW.ASM really saves time guessing.
Post 22 Jul 2023, 12:11
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 12:21
I try
Invoke FindWindow, "FASMW_IDE32", 0
Invoke SendMessages, eax, IDM_PASTE, 0,0

I NOT SEE ANY TEXT IN FASMWIDE

But if I pressed ctrl+v I get text from win clipboard in fasmw
Post 22 Jul 2023, 12:21
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 22 Jul 2023, 12:28
The IDE source code is not on github, so here is the code that does the paste:
Code:
wm_paste:
        test    [editor_mode],FEMODE_READONLY
        jnz     ignore
        call    make_undopoint
        cmp     [was_selection],0
        je      paste_secureselection_ok
        test    [editor_style],FES_SECURESEL
        jnz     paste_secureselection_ok
        call    delete_block
    paste_secureselection_ok:
        invoke  OpenClipboard,NULL
        invoke  GetClipboardData,CF_TEXT
        or      eax,eax
        jnz     do_paste
        invoke  CloseClipboard
        jmp     ignore
    do_paste:
        or      [clipboard_opened],-1
        push    eax
        invoke  GlobalLock,dword [esp]
        mov     esi,eax
        call    insert_block
        jc      paste_failed
        pop     ebx
        invoke  GlobalUnlock,ebx
        invoke  CloseClipboard
        mov     [clipboard_opened],0
        test    [editor_style],FES_SECURESEL
        jz      no_selection_after_paste
        mov     eax,[caret_line]
        mov     ecx,[caret_line_number]
        mov     edx,[caret_position]
        xchg    eax,[selection_line]
        xchg    ecx,[selection_line_number]
        xchg    edx,[selection_position]
        mov     [caret_line],eax
        mov     [caret_line_number],ecx
        mov     [caret_position],edx
        jmp     text_changed
    no_selection_after_paste:
        mov     [selection_line],0
        jmp     text_changed
    paste_failed:
        call    undo_changes
        pop     ebx
        invoke  GlobalUnlock,ebx
        invoke  CloseClipboard
        mov     [clipboard_opened],0
        jmp     text_changed    
... in FEDIT.INC. You could set a breakpoint from debugger or INT3, etc. and see what is happening, or maybe you never get there? Maybe it is as simple as not being in format CF_TEXT? Could be many things.
Post 22 Jul 2023, 12:28
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 12:43
Windows 10
I show my video. Fasm not want get text from my program.
When i press ctrl+v fasm get text from win clipboard.


Last edited by Roman on 22 Jul 2023, 20:15; edited 1 time in total
Post 22 Jul 2023, 12:43
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 22 Jul 2023, 12:58
Roman wrote:
But if I pressed ctrl+v I get text from win clipboard in fasmw
... this makes me think it's a process-to-process communication thing. Like, the IDE process doesn't have access to the clipboard at the time you're sending the messages.

Without seeing all the code all I can do is advise double checking the correct steps are followed to put data on the clipboard.

The video doesn't show your application changing the text on the clipboard and I don't want to make that assumption. We would like to see your application changing clipboard text for itself and also for manually pasting into the IDE. That would reinforce the idea that process isolation is blocking clipboard in some way.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 22 Jul 2023, 12:58
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 13:02
Quote:

wm_paste:
test [editor_mode],FEMODE_READONLY
jnz ignore

Where is see FEM_GETMODE ?
I not found FEM_GETMODE value in fasm sources

Code:
;maybe this help
invoke  SendMessage,[FasmHwnd],FEM_GETMODE,0,0
xor eax,FES_SMARTTABS
invoke  SendMessage,[FasmHwnd],FEM_SETMODE,eax,0
invoke  SendMessage,[FasmHwnd],FEM_ISUNMODIFIED,0,0    
Post 22 Jul 2023, 13:02
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 22 Jul 2023, 13:15
FEDIT.ASH is the interface definition for the edit control. It has all the external constants needed to use the control. For "FEDIT" - which you couldn't get a handle for.
Post 22 Jul 2023, 13:15
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 13:22
When i open fasmw editor and run my program.
Fasmw editor closed when i do invoke SendMessage,[FasmHwnd],FEM_GETMODE,0,0
Post 22 Jul 2023, 13:22
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1661
Location: Toronto, Canada
AsmGuru62 22 Jul 2023, 14:31
In today's Windows the sending of a message between two processes (your program is process #1 and FASM IDE is a process #2) is a very strict operation.
The stuff like that was possible in Win95 or Windows XP, but not today.
The better question is why do you need your program to paste the text into FASM IDE?
Why not do it the old way:

1. Switch to program where you 'Copy' the text
2. Switch to FASM IDE and use CTRL+V

I am guessing -- you are writing some kind of code generator and then you want this generated code from your program
to appear inside FASM IDE. Nice, but it will not work with SendMessage API. Unless, you will use WM_COPYDATA message, but
then you will have to make FASM IDE to respond to the WM_COPYDATA and do the paste there. For that you may want to add some code into
FASM IDE and rebuild it.
Post 22 Jul 2023, 14:31
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 14:34
Quote:

1. Switch to program where you 'Copy' the text
2. Switch to FASM IDE and use CTRL+V

I think about this variant.
This variant work fine.

I select and copy text in richedit window , than put this text to FASMWIDE (ctrl+v)
This work fine.
Post 22 Jul 2023, 14:34
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 22 Jul 2023, 15:36
AsmGuru62 wrote:
In today's Windows the sending of a message between two processes (your program is process #1 and FASM IDE is a process #2) is a very strict operation.
The stuff like that was possible in Win95 or Windows XP, but not today.
I've heard you say this before, but is it really true?

Roman, try the attached program.


Description: Paste into FASMW IDE edit control from another process.
Download
Filename: fnote.zip
Filesize: 1.32 KB
Downloaded: 173 Time(s)


_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 22 Jul 2023, 15:36
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2545
Furs 22 Jul 2023, 16:56
AsmGuru62 wrote:
In today's Windows the sending of a message between two processes (your program is process #1 and FASM IDE is a process #2) is a very strict operation.
The stuff like that was possible in Win95 or Windows XP, but not today.
You can send messages just fine even on Windows 11, else stuff like AutoHotkey wouldn't work.

Maybe it won't work if they run under different privilege levels or users, though, but that's not the topic.
Post 22 Jul 2023, 16:56
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 22 Jul 2023, 17:55
Thanks bitRAKE !
Now work WM_PASTE. But PASTE only in first FASMW_IDE window !


Last edited by Roman on 26 Jul 2023, 11:32; edited 1 time in total
Post 22 Jul 2023, 17:55
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 26 Jul 2023, 04:58
Roman wrote:
Now work WM_PASTE. But PASTE only in first FASMW_IDE window !
Using EnumWindows and EnumChildWindows you can have more control over where the message goes. For example, you could have a treeview control which shows the IDE windows and all their children. You would need to implement logic to handle when the destination FEDIT control no longer exists (or hasn't been selected).

How you implement the logic will depend on the intended workflow. I imagine something like refresh the list and gray out all submit buttons (forcing the user to select a new target FEDIT).

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 26 Jul 2023, 04:58
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 26 Jul 2023, 07:39
You can use FASMW's custom messages FM_GETSELECTED and FM_GETHANDLE to get the handle of edit window for currently selected tab:
Code:
FM_SELECT       = WM_USER + 4
FM_ASSIGN       = WM_USER + 5
FM_GETSELECTED  = WM_USER + 6
FM_GETASSIGNED  = WM_USER + 7
FM_GETHANDLE    = WM_USER + 8

        invoke  FindWindow,    "FASMW_IDE32", 0
        test    eax,eax
        jz      .no_ide

        mov     ebx,eax

        invoke  SendMessage,    ebx, FM_GETSELECTED, 0, 0
        invoke  SendMessage,    ebx, FM_GETHANDLE, eax, 0

        invoke  SendMessage,    eax, WM_PASTE, 0, 0    
Post 26 Jul 2023, 07:39
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 26 Jul 2023, 07:59
Thanks Tomasz.
Work perfect!

New update.


Description:
Download
Filename: fasmHlpr.rar
Filesize: 99.22 KB
Downloaded: 180 Time(s)



Last edited by Roman on 04 Sep 2023, 10:09; edited 12 times in total
Post 26 Jul 2023, 07:59
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 31 Jul 2023, 13:03
Problem.
FasmwIDE 1.73 not saved any file with any name , after my program past text.
When I closed my program FasmwIDE 1.73 saved file fine.

My program using win clipboard.
What is wrong ?

My program each 100 Milliseconds do this. This could be problem ?
Code:
invoke  FindWindow,    "FASMW_IDE32", 0
        test    eax,eax
        jz      .no_ide

        mov     ebx,eax

        invoke  SendMessage,    ebx, FM_GETSELECTED, 0, 0
        invoke  SendMessage,    ebx, FM_GETHANDLE, eax, 0
.no_ide:
    

Yes this a problem and fasmIDE not save file for this code. I checked now.

I put this code in wndproc when happened message WM_COMMAND, now work well.
Post 31 Jul 2023, 13:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.