flat assembler
Message board for the users of flat assembler.

Index > Windows > SendKeys() --> How to?

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Hi! I was for a long time whithout posting. Now I'm back, after learning something about asm programming. And FASM is the best assembler, so time to do some work.

I have a question:
* How to use Win32 API to send text to a program, for example notepad? I need to use some API (I think SendMessage(), don't know...) to do something like SendKeys() does on VB. Something like this:
invoke MySendKeysFunc, the_text
.
.
.
the_text db "Hi! I'm the text that gets written to notepad editbox!',0

Please post some code.
Sorry for my bad english.

Thanks!
Post 09 Mar 2005, 20:29
View user's profile Send private message Reply with quote
rambo



Joined: 28 Feb 2005
Posts: 22
Location: posen, poland
rambo
yO!

i think, that you should to know, that there is something like "winapi reference". it`s help-file with all functions explained..

anyway.

as you said, there is SendMessage function:
Code:
invoke SendMessage,hwnd,message,wparam,lparam
    

so, simply:
Code:
invoke SendMessage,window_hwnd,WM_SETTEXT,0,the_text
    

i think Smile i`m not winapi master.
Post 09 Mar 2005, 20:52
View user's profile Send private message Visit poster's website Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Yeah! I know about "winapi reference", I have it. And I also know about SendMessage API and WM_SETTEXT... but the problem is:
I tried to use FindWindow to get the handle to notepad and the use
Code:
invoke SendMessage,window_hwnd,WM_SETTEXT,0,the_text
    

to send the text... but it change the title of notepad and not the editbox text... So, I need to know how to get the handle of the editbox of notepad... That's my problem... I don't know how to do it!

Any ideas?

Thanks!
Post 09 Mar 2005, 21:04
View user's profile Send private message Reply with quote
drs



Joined: 20 Jan 2005
Posts: 17
Location: Southern California, USA
drs
I can tell you right now that you will end up having to use some kind of COM interface to do what you want. I'm not sure what the object is you will need but later I can probably find out. I have seen an example of what you want to do being done in many VBScript programs.

I know for a fact also that the ActiveState Perl distrobution includes a script that also does it.

I don't think you can use the standard Win32API SendMessage calls here.
Post 09 Mar 2005, 22:41
View user's profile Send private message ICQ Number Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
use FindWindowEx for the child. i did not check if the class names were correct:
Code:
hwndnotepad dd ?
hwndedit dd ?

pad db 'Notepad',0
edit db 'edit',0
sz db 0

invoke   FindWindow,pad,sz
mov      [hwndnotepad],eax
invoke   FindWindowEx,hwndnotepad,0,edit,sz
mov      [hwndedit],eax
invoke   SendMessage,[hwndedit],WM_SETTEXT,0,edit
    
Post 09 Mar 2005, 22:57
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.