flat assembler
Message board for the users of flat assembler.
Index
> Windows > Inactivity time system wide |
Author |
|
Foamplast 04 Sep 2004, 22:05
I advice you to use mouse and keyboard hooks. So then, everytime you receive a message from keyboard or mouse you may set a timer for 5 minutes, killing previous timer if there is one. If the user works, you are frequently killing your timer. If the user doesn't touch keybord and mouse, your timer will start a screensaver.
|
|||
04 Sep 2004, 22:05 |
|
MACi 05 Sep 2004, 17:08
Okay... but I was doing serious asm coding in DOS era last time...
Can you help me with some code snippets, how to do, please? |
|||
05 Sep 2004, 17:08 |
|
DEMON 05 Sep 2004, 21:15
Read ICZELION's tutorials
There you can find information about hook's |
|||
05 Sep 2004, 21:15 |
|
MACi 05 Sep 2004, 21:43
I've downloaded and searched through many tutorials (also Iczelion's), but didn't found hooks+systemwidetimers examples...
|
|||
05 Sep 2004, 21:43 |
|
Foamplast 06 Sep 2004, 22:12
Well, I always wonder why do people study someone's tutorials, not official documents. If you are going to program Window's applications you should know what method of communication this OS provides. This doesn't depend on language: asm, C, Pascal or something else. ICZELION's tutorials are good enough to understand principles of Windows assembly programming, but he can not re-tell all MSDN.
I advice you to study MSDN articles about hooks. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks.asp |
|||
06 Sep 2004, 22:12 |
|
MACi 07 Sep 2004, 06:22
Thanks!
So I find useful this msdn source and also I've found hooks example in Iczelion's tutorial #24, but win32 is yet strange for me (and I don't have enough free time to play much with masm32 code written for another purpose), so can anybody help with some code snippets, how to do it in a real world example, and also with some timer code snippets (you know, just simple to display a little text, when I don't touch the keyboard and mouse for some minutes), please? _________________ MACi |
|||
07 Sep 2004, 06:22 |
|
f0dder 09 Sep 2004, 00:00
There's a couple of ways to handle this - I'm assuming you're using a hook (although there's probably other ways - hooks should be avoided if you can, as they take system resources and can cause instability if not written properly).
Anyway, each time your hook gets fired and you detect a keypress, note current time in some variable (use GetLocalTime, GetSystemTime, or GetTickCount to get time). Either use WM_TIMER or a separate Thread to fire periodically - try to make it sleep as long as possible while not causing timing problems (with five minutes a one-minute sleep would be fine, and not take too much system resources). Anyway, when checking timer/thread is fired, you get system time again, compare the difference between current system time and last hook-fire time - if larger than your period, act |
|||
09 Sep 2004, 00:00 |
|
MACi 09 Sep 2004, 07:23
Thanks, that was closer, but... there are some unclear areas, how to do...
...this doesn't work, it even cannot get to hookproc: Code: include '%fasminc%\win32ax.inc' .code start: invoke SetWindowsHookEx, WH_KEYBOARD, hookproc, 0, 0 invoke ExitProcess, 0 .end start proc hookproc, hwnd, uMsg, idEvent, dwTime invoke SetTimer, 0, 1, 1000, timerproc invoke MessageBox, HWND_DESKTOP, "hook installed", "hook", MB_OK return endp proc timerproc, hwnd, uMsg, idEvent, dwTime invoke KillTimer, 0, 1 invoke MessageBox, HWND_DESKTOP, "timer finished", "timer", MB_OK return endp ...and for the mouse also the same hook with WH_MOUSE to the same hookproc? _________________ MACi |
|||
09 Sep 2004, 07:23 |
|
MACi 21 Sep 2004, 08:32
nobody can help???
|
|||
21 Sep 2004, 08:32 |
|
omega_red 21 Sep 2004, 09:58
Check what SetWindowsHook returns. Check GetLastError. Because you're setting global hook, HookProc has to be in DLL.
|
|||
21 Sep 2004, 09:58 |
|
MACi 21 Sep 2004, 20:32
I don't know how to code dll, but this is the smaller problem, if there are exact example source codes (and I saw those for dll), the biggest problem is win32asm is not transparent for me, this is 1000 miles away from DOS ASM, and when I don't see the source code then I cannot learn swirls and catches, how to code...
_________________ MACi |
|||
21 Sep 2004, 20:32 |
|
Foamplast 21 Sep 2004, 20:53
Hello!
The attached is an example of keyboard hooking. It is a simple keylogger that writes keystrokes pressed to the file named "C:\kbd.log". This program is written in NASM, but the syntax is very close to FASM. You can easily port this to NASM and enjoy. Feel free to ask me any questions you may have.
|
|||||||||||
21 Sep 2004, 20:53 |
|
MACi 23 Sep 2004, 21:25
Thanks, I'll examine this
_________________ MACi |
|||
23 Sep 2004, 21:25 |
|
MACi 01 Oct 2004, 17:48
I stucked on this
I think I'll give a try to iczelion's tutor#24 combined with my own code above... it'll be hard for a dos coder... _________________ MACi |
|||
01 Oct 2004, 17:48 |
|
MACi 12 Nov 2004, 13:29
doesn't work!
Code: include '%fasminc%\win32ax.inc' .data hookflag dd FALSE hook dd ? .code start: .if [hookflag],e,FALSE invoke SetWindowsHookEx, WH_MOUSE, hookproc, 0, 0 mov [hook],eax .if eax,ne,0 mov [hookflag],TRUE .endif invoke Sleep, 30000 invoke ExitProcess, 0 .else invoke UnhookWindowsHookEx,[hook] invoke ExitProcess, 0 .endif .end start proc hookproc, nCode, wParam, lParam invoke CallNextHookEx,[hook],[nCode],[wParam],[lParam] invoke SetTimer, 0, 1, 1000, timerproc invoke MessageBox, HWND_DESKTOP, "hook started", "hook", MB_OK return endp proc timerproc, hWnd, uMsg, idEvent, dwTime invoke KillTimer, 0, 1 invoke MessageBox, HWND_DESKTOP, "timer finished", "timer", MB_OK invoke UnhookWindowsHookEx,[hook] return endp _________________ MACi |
|||
12 Nov 2004, 13:29 |
|
MACi 16 Nov 2004, 09:06
HELP PLEASE!
_________________ MACi |
|||
16 Nov 2004, 09:06 |
|
MACi 17 Nov 2004, 11:54
After many sleepless nights with writing and modifying and rewriting code... I've made it!
Can I think about myself, I'm the best asm coder in this area, because only I can do this and nobody could effectively help? Moreover because this code is only one 2k exe and no dlls? Not bad from a win32 newbie, eh? _________________ MACi |
|||
17 Nov 2004, 11:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.