News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Autotype demo

Started by Vortex, August 17, 2008, 09:22:11 AM

Previous topic - Next topic

Vortex

Here is a revised version of the Autotype demo :


.386
.model flat,stdcall
option casemap:none

include     \GeneSys\include\windows.inc
include     \GeneSys\include\kernel32.inc
include     \GeneSys\include\user32.inc

includelib  \GeneSys\lib\kernel32.lib
includelib  \GeneSys\lib\user32.lib

AutoType PROTO :DWORD,:DWORD

.data

message     db  'Hello GeneSys user', 13, 10
            db  'This is an autotyping example.', 0
app         db  'C:\windows\notepad.exe', 0
WndClass    db  'Notepad', 0
ChildClass  db  'Edit', 0

.data?

startinfo STARTUPINFO <?>
processinfo PROCESS_INFORMATION <?>

.code

start:

invoke CreateProcess,ADDR app,0,0,0,0,0,0,0,\
ADDR startinfo,ADDR processinfo
invoke Sleep,500 ; wait for the process to be created
    invoke  FindWindow,ADDR WndClass,0
    invoke  FindWindowEx,eax,0,ADDR ChildClass,0
invoke AutoType,eax,ADDR message
    invoke  ExitProcess, 0

AutoType PROC USES esi hWnd:DWORD,_msg:DWORD

    mov     esi,_msg
@@:
    movzx   eax,BYTE PTR [esi]
    test    eax,eax
    jz      @f
    invoke  SendMessage,hWnd,WM_CHAR,eax,0
    invoke  Sleep,200
add esi,1
    jmp     @b
@@:
ret

AutoType ENDP

END start




[attachment deleted by admin]

jj2007

works fine. I would have tried this:
    movzx   edi,BYTE PTR [esi]
    test    edi,edi
    jz      @f
    invoke  SendMessage,hWnd,WM_KEYDOWN,edi,0
    invoke  SendMessage,hWnd,WM_CHAR,edi,0
    invoke  SendMessage,hWnd,WM_KEYUP,edi,0

Astonishing that Notepad does not check the WM_KEY messages.

RuiLoureiro

Quote from: Vortex on August 17, 2008, 09:22:11 AM
Here is a revised version of the Autotype demo

Vortex,
            Thanks, it works fine !!

Rui

PBrennick

JJ,
I am certain (because I was a ghostwriter,myself) that it probably was not written by anyone from MS. It is not using RichEdit and probably as litlle of the other APIs as they could get away with. Hence, the size boundary, for example. Your editor is much better and you think on a very different level than those guys!

Vortex,
I just uploaded the amended 2008 version to deal with the problem Hutch found and to deal with a bug in the Tools option. This example will be a part of the next one or perhaps a service pack.

As always, very nice work, I am glad to see WinExec removed.

BTW: The new upload is available from SkyDrive using the links on my site. As soon as Ghirai copies it to the main repository, I will make an announcement.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

jj2007

Quote from: PBrennick on August 17, 2008, 01:26:57 PM
JJ,
I am certain (because I was a ghostwriter,myself) that it probably was not written by anyone from MS. It is not using RichEdit and probably as litlle of the other APIs as they could get away with. Hence, the size boundary, for example.
Notepad was always very "basic" in comparison to real editors, but I had always assumed it came from the makers of the OS and respected the rules to the letter. Notepad looks like a "hey, this is an example of what you can do with Windows" toy. Not sure what the rules say about processing WM_KEY messages, though. By the way, afaik they removed the size limited some time ago.

Quote
Your editor is much better and you think on a very different level than those guys!
That is extremely kind of you, Paul, thanks! For Masm sources, I work exclusively with RichMasm nowadays, but occasionally it plays tricks on me, so I cannot recommend it for serious work yet.

PBrennick

JJ,
I consider the work of my editor to be VERY serious and I hear all these claims about RichEdit being cranky. I suppose it is as is anything that needs to be so 'all encompassing.' I have never had any serious problems with RichEdit and it has NEVER caused me to have an unstable product. In fact, most others here are now using it, even those who have had developmental tools for some timehave recently made the change to RichEdit and I feel it is because they 'see' the stability of my editor. Any problems that my editor has EVER had were/are self-inflicted and I can blame no one else but myself when they are discovered.

As you continue your work in progress, I hope you will continue to support RichEdit and stop bashiing it. I say that as a friend, please do not get on 'that' bandwagon.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

jj2007

Paul,
I was not bashing RichEdit (although it deserves to be bashed :green) - I "bashed" Notepad saying it was a toy; and I am sure nobody here in the forum would object. We are all using more serious toys, right?

When I wrote "it plays tricks on me", I meant the little problems of my own RichMasm code. Nobody is perfect :wink

One example: I use a 204 bytes hidden text string at the beginning of a doc to store user info - last edit position, positions of last changes, window settings etc.; occasionally, this section gets corrupted, and I know it's a stupid little bug that one day will show up in the right moment so that I can hit it over the head. When that corrupted file displays its message "hey, I am corrupt", I know how to deal with it: Open the RTF file in Notepad, delete the 204 bytes, save. But it is not something I am proud of, and therefore I cannot seriously encourage anybody to use RichMasm. That's all...

And I will definitely continue to "support" RichEdit, simply because there is no alternative. But that will not stop me from saying the truth: It is a shame that the OS, for which most of us have paid, provides only a crappy control that is not even able to save hyperlinks.

PBrennick

JJ,
I think you got a little mixed up there. You cannot blame RichEdit for things that are lacking in the Rich Text Format. The RTF format is a specification that does NOT belong to RichEdit, it merely adds that capability and complies to its rules and methodologies. Don't shoot the messenger. This is exactly the type of thing I am referring to.

Rich Text Format (RTF) is a file format that lets you exchange text files between different word processors in different operating systems. The Rich Text Format (often abbreviated RTF) is a free document file format developed by Microsoft in 1987 for cross-platform document interchange.

This means that RTF came BEFORE RichEdit and RichEdit is only complying to this specification. Remember that and be careful what you say.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

jj2007

Quote from: jj2007 on August 22, 2008, 09:03:48 PM
It is a shame that the OS, for which most of us have paid, provides only a crappy control that is not even able to save hyperlinks.

Quote from: PBrennick on August 23, 2008, 10:41:15 AM
JJ,
I think you got a little mixed up there. You cannot blame RichEdit for things that are lacking in the Rich Text Format. The RTF format is a specification that does NOT belong to RichEdit, it merely adds that capability and complies to its rules and methodologies. Don't shoot the messenger. This is exactly the type of thing I am referring to.

Rich Text Format (RTF) is a file format that lets you exchange text files between different word processors in different operating systems. The Rich Text Format (often abbreviated RTF) is a free document file format developed by Microsoft in 1987 for cross-platform document interchange.

This means that RTF came BEFORE RichEdit and RichEdit is only complying to this specification. Remember that and be careful what you say.

So hyperlinks are still excluded from the RTF specs? 21 years after RTF 1.0??

jj2007

Just in case that I have again not expressed myself clearly enough:

{\rtf1\ansi\ansicpg1252\deff0\deflang1036{\fonttbl{\f0\fswiss\fprq2\fcharset0 System;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\tx1800\tx2800\tx3800\tx4800\tx5800\tx0\cf1 Open me in MS Word and press Control K to give me a hyperlink\par
\par
}


This is a perfectly valid 262 bytes RTF document. The good news is that RichEdit can read it. Now the bad news:
- open it in MS Word and insert a hyperlink with Control K
- do NOT do anything else
- save it (at this point you will notice that RichEdit's equally crappy Big Brother multiplies the file size by 15)
- open it in a RichEdit editor (not GeneSys because GeneSys does not recognise it's RTF)
- Wow, we can see there is a hyperlink, it's blue and underlined!!
- unfortunately RichEdit sees only the nice blue colour, but it does not know about links
- save it in your control (the good news is the file is back to a reasonable size - little crappy brother throws away all the goodies that MS Word has added)
- open it in MS Word and see the cute blue colour and underline style
- try opening the link (he he, there is none!!!)

Now tell me again it's perfectly reasonable that an OS that needs 1,500,000,000 bytes on disk does not need a control that knows about hyperlinks.

Sample docs are attached.

[attachment deleted by admin]

Mark Jones

JJ, it's the weekend, have a beer. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

PBrennick

As I recall, in MS-Word and maybe others, there is a key sequence to execute a hyperlink...

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

BlackVortex

Haha, I found this very interesting, I changed it a little to make it more win-compatible and funny, haha. Thx Vortex !    :clap:
(well, this needs masm32, wrong section, but nvm)


[attachment deleted by admin]

PBrennick

Black Vortex,

That is just very cool! I never would have thought to put in the BackSpaces. I think you should try moving the BackSpaces and the rest of the string into another string and add a sleep between the two messages. Perhaps say 'BYe bye' befor Terminating the process. You caught me off gaurd on that one, BTW.

With changes something like that or however your mind takes it, I would like to add your version to the SDK.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

BlackVortex

 :cheekygreen:    :cheekygreen:     :cheekygreen:     :cheekygreen:

Well, I'm not an experienced enough coder, I'm scared to have pieces of my source in an SDK release, so plz you take it over, haha ! You know you want to !!!  You could even make it modular.

>  I think you should try moving the BackSpaces and the rest of the string into another string and add a sleep between the two
>  messages.

Not even that ! I have an even better idea to make it spookier : to make the sleep parameter between the keystrokes use random values (in a reasonable range).  You know, to simulate human typing.  Ooohh  ...   SPOOKY !!!

Or even using a timer, so that the whole thing starts in a non-suspecting time, not when running the app! Nice hoax, huh ? I know I'd shit bricks, unplug the PC and throw the monitor off the window.

Or even trying to personalize the hoax message, using the logged-on windows username or something personal like that.

Example (username=Alex) 
"Help me, Alex,  hhe  " then quickly terminates notepad, lol. Maybe after a few seconds plays a VERY low-volume .wav of mysterious whispers (help me) for a few secs.  Lol, ok that's overkill !

P.S.: Project "Horrorpad"