Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Running programs in background

Author
Message
mR n
23
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 16th Aug 2003 06:22
This is probably complicated to do but is there any way that you could make a program that could run in the background and detect when you click on certian things (in other applications),when certian programs are being run, or allow you to take a screenshot of the desktop...etc. Maybe even if there was a way for you to make a program that ran itself on startup automaticly or after downloading it. That might be vague or very broad so let me know! I was wondering if someone could just point me in the right direction.
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 16th Aug 2003 06:59
Actually, no I dont think so. Once I tried to make a program that logs keypresses, clicks, and time spent on the computer (For personal use only, of course. I wanted to see how many times I click in a day.) I found that while running in the background, it cannot detect keypresses/clicks. Also, it is impossible to get a screenshot of the desktop in DBP because anything off the DBP window is 'illegal image area' and DBP automatically resizes the screen inside the window, so it is not windows screen units.

About the startup thing, the easiest way to do it would be to put a shourtcut in the startup folder in the start menu. This can be easily done with DBP. Another option would be to edit the registry, also possible in DBP.

"All programmers are playwrites and all computers are lousy actors" -Anon
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 18th Aug 2003 12:44
Well, I don't think you meant to do this in DBpro, right? If you plan to make this program in VC++ using WinAPI, then yes there is way to do this.

Basically Windows programming are event driven. Meaning that it will notify events THAT HAPPENED IN YOUR OWN APPLICATION WINDOW to your program. Thus, this model doesn't work in your case.

There is 2 ways that I thought of to achieve your goals:

Way #1
1. Create a timer that fires WM_TIMER in certain interval, the smaller the better.

2. Handle that timer event and poll for for current mouse status, i.e. mouse position and its buttons status.

3. Check whether the current buttons status is same as previous one. If it is, then meaning that the status haven't change since last check. If the status changes, check whether the button is pressed. If it is, then record it the way you want it.

4. Keep the current status for next round.

Way #2

This way is more hardcore, it is dealling with write a so called "hook" in Windows. A mouse hook is basically a function that is connected to the Windows mouse interface. So whenever there is a mouse event happening, it will call whatever registered mouse hook function. The function will process it, and decides whether want to consume the event so that no other application will receive it, or pass on the event.


Hoped you can get what I mean. I am not a good teacher.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
mR n
23
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 19th Aug 2003 03:42
Well thanks for the advice. I wasn't really planning anything major i was really just wondering because there's a couple things i was thinking of doing. nice to know the limits of dbpro. thanks again!
swdave
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United States
Posted: 19th Aug 2003 09:39
Im using pthreads-w32 in a TPC for background tasks. It works good.


http://sources.redhat.com/pthreads-win32/

Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 19th Aug 2003 15:28
It depends...

You can start a thread (a prog or a function runing in the background) even with dbp, when you can get the pointer to that function. Maybe Lee will add that feature sometimes?! Then u can call an api-function to start that thread in the background.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Aug 2003 15:49
No. DBPro will most likely never have threads.

Why?

1) Because DirectX itself cannot handle threads very well
2) DBPro was not designed to be threaded

Point 1 could be got around despite the fact that it's at the centre of most of DBPro's libraries, but point 2 would require a rewrite of large portions of those libraries for a feature that most would not use.

Now, function pointers for windows callbacks might happen, but there are difficulties there too. DBPro uses one function calling convention (cdecl) and windows uses another (stdcall).

Login to post a reply

Server time is: 2026-07-25 08:13:23
Your offset time is: 2026-07-25 08:13:23