flat assembler
Message board for the users of flat assembler.

Index > Windows > How to Send Key: ALT+F4?

Author
Thread Post new topic Reply to topic
SPTH



Joined: 24 Jul 2004
Posts: 91
SPTH 19 Sep 2008, 03:59
Hey,
Topic says everything: I need to know how to simulate a ALT+F4 in fasm.

I've tried some hours for searching a way to close a specific window, and it seems just a ALT+F4 would work.
Unfortunatly, MSDN just gave me information how to do it with WScript :roll: +g+

i would be really happy, if anybody could help me. thanks alot!

kind regards, Mario!
Post 19 Sep 2008, 03:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19868
Location: In your JS exploiting you and your system
revolution 19 Sep 2008, 05:13
To simulate keystrokes have a look at keybd_event.

But perhaps an easier method is just a simple PostMessage.
Post 19 Sep 2008, 05:13
View user's profile Send private message Visit poster's website Reply with quote
SPTH



Joined: 24 Jul 2004
Posts: 91
SPTH 19 Sep 2008, 05:38
Thanks a lot, that has helped.

see the code:
Code:

   invoke  keybd_event, VK_MENU, 0x0, 0x0, 0x0
 invoke  keybd_event, VK_F4,   0x0, 0x0, 0x0
 invoke  keybd_event, VK_MENU, 0x0, KEYEVENTF_KEYUP, 0x0
     invoke  keybd_event, VK_F4,   0x0, KEYEVENTF_KEYUP, 0x0
    


quite easy, and does exactly what i want - great! :)
Post 19 Sep 2008, 05:38
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 19 Sep 2008, 08:11
send WM_CLOSE
Post 19 Sep 2008, 08:11
View user's profile Send private message Visit poster's website Reply with quote
SPTH



Joined: 24 Jul 2004
Posts: 91
SPTH 19 Sep 2008, 12:38
WM_CLOSE minimizes the window, WM_DESTROY is what I would need (also tried that), but the to-be-destroyed window was no child-window -> did not work with WM_DESTROY

[edit]Ignore that post, it's misinformation - sorry +g+[/edit]


Last edited by SPTH on 19 Sep 2008, 22:44; edited 1 time in total
Post 19 Sep 2008, 12:38
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19868
Location: In your JS exploiting you and your system
revolution 19 Sep 2008, 12:47
WM_QUIT is meant to end the task. That is what Windows sends if you click the close button.

[edit]the above is not correct, see the messages below for what really happens.[/edit]


Last edited by revolution on 19 Sep 2008, 13:32; edited 1 time in total
Post 19 Sep 2008, 12:47
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8263
Location: Kraków, Poland
Tomasz Grysztar 19 Sep 2008, 13:23
revolution wrote:
WM_QUIT is meant to end the task. That is what Windows sends if you click the close button.

Are you sure? On my system it sends WM_CLOSE.
Post 19 Sep 2008, 13:23
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19868
Location: In your JS exploiting you and your system
revolution 19 Sep 2008, 13:25
Oh, is that wrong? I always use the WM_QUIT to signal the message loop exit and then call ExitProcess.
Post 19 Sep 2008, 13:25
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8263
Location: Kraków, Poland
Tomasz Grysztar 19 Sep 2008, 13:27
Well, it's OK tu use it for this purpose, as this is exactly what it's for. I just mean that when you press the close button, Windows just sends you a WM_CLOSE message, and to send the further WM_QUIT message in such case is your own choice.
Post 19 Sep 2008, 13:27
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19868
Location: In your JS exploiting you and your system
revolution 19 Sep 2008, 13:31
Oh dear, it has been a while since I had to manually write a WndProc that I had completely forgotten that the app calls PostQuitMessage (or just PostMessage with WM_QUIT). Sorry about the misinformation above.
Post 19 Sep 2008, 13:31
View user's profile Send private message Visit poster's website 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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.