View Full Version : Sense Mouse Movement
rhosk
11-09-2003, 07:31 AM
Is there any way that AMS (5 or preferably 4 right now) can sense mouse movement? Similar to the way windows does like for a screensaver (to terminate it)? Got an interesting project in mind that would need to exit upon mouse movement or keypress. Thanks for any tips.
Corey
11-09-2003, 07:35 AM
Keypress isn't that hard to do, I think someone posted something about how to key hook using a .dll a while back. But that being said I bet someone here can figure out the mouse movement thing. It can't be that hard because you see it in lots of very simple apps... Cool idea, if someone can figure this out I would probably use it too...
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-09-2003, 08:30 AM
I know I can figure out a "cheezy" way of doing it with Flash (onMouseMove), but I was hoping for a "global" movement on the screen. Flash will only do it if you broadcast over a MC/Button, etc. Conversely, you could make the clip transparent I guess, but you would still be at the mercy of the confines of the clip - not the whole computer screen.
Where's Worm when you need him, eh (when you get time :))? It's probably some kind of dll function that can sense mouse movement; guessing & of course, hoping.
rhosk
11-11-2003, 02:41 AM
Maybe if I provide details on what I would like to accomplish here, it would possibly be worthwhile to look into? Still haven't figured out a way and would like some ideas. Anything would be great from any of you gurus!! :)
Would like to simply launch an AMS executable that would maybe reside in the system tray and be able to sense inactivity of the mouse/keyboard for a period of time (I can do the time part easy enough) - again similar (actually exactly) like a screensaver scenario. When this inactive time has elapsed, launch an external application. Conversely, when it senses mouse/key press activity, while this external app is running, AMS finds the window and closes it. I can figure out everything for this project except the mouse sensing. This poor sole would be willing to pay for a viable solution, it's that important. Thanks for reading!
Corey
11-11-2003, 03:06 AM
Well there may very well be a free solution yet I'm sure but just FYI our programmers can be had for a reasonable price and there's not too much they can't figure out. :)
If you look at the status bar in AMS 5.0 you can see that it is displaying your mouses co-ordinates in real time (I love the status bar in 5.0 A LOT) which is basically what you want to do but in your apps, i.e. a plug-in which adds mouse functions such as:
Mouse.X();
Mouse.Y();
And maybe even:
Mouse.Hide();
Mouse.Show();
Mouse.CursorAttach();
Mouse.CursorRemove();
Mouse.OnClick();
Just riffing. That would be cool, plus a plug-in like that would have lots of room for version expansion as you could add more and more complex things over time including right click menu controls, augmented events such as OnDrag/OnDrop, hit testing, etc.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-12-2003, 03:26 PM
I am still working this issue as this thread slowly but surely tries to disappear. Have I stumped everyone, haha, or does it sound like not such a good idea? As in most of my strange cases, I cannot find a solution to this problem (searched for a couple of days on the Net) and I really thought that 5.0 could be the answer, but I can't see how it could do it either. I did manage to figure out (on XP anyway) that "scrnsave.exe" in the system32 directory will launch an executable (even if you change the extension from exe to scr), and you can even select it in properties to set the delay, but I don't know how reliable this will be, and the executable in question is obviously missing some code to terminate the app on keypress or mousemove, so I'm still stuck.
I can't even find a program or a workaround for launching executables (as a quasi-screensaver) anywhere! They all boast to launch images, swf's and even videos, but just a mere program - I guess there's been no demand for this. I may have to live with "press any key" to terminate, but this seems to be a challenge as well. I've seen a couple examples on how to detect individual keys, but would there happen to be a blanket any key script? Or would I have to compile a large script to account for every key? Sorry to ramble.
TJ_Tigger
11-12-2003, 03:30 PM
Isn't there a .dll that was used to set the visibility of the mouse pointer. Could you use that to sense mouse movement. You could use a timer and maybe get the mouse position and compare it with the last poll. Stir and repeat.
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
· dwFlags
A set of flag bits that specify various aspects of mouse motion and button clicking. The bits in this parameter can be any reasonable combination of the following values:
MOUSEEVENTF_ABSOLUTE
Specifies that the dx and dy parameters contain normalized absolute coordinates. If not set, those parameters contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.
MOUSEEVENTF_MOVE
Specifies that movement occurred.
MOUSEEVENTF_LEFTDOWN
Specifies that the left button changed to down.
MOUSEEVENTF_LEFTUP
Specifies that the left button changed to up.
MOUSEEVENTF_RIGHTDOWN
Specifies that the right button changed to down.
MOUSEEVENTF_RIGHTUP
Specifies that the right button changed to up.
MOUSEEVENTF_MIDDLEDOWN
Specifies that the middle button changed to down.
MOUSEEVENTF_MIDDLEUP
Specifies that the middle button changed to up.
MOUSEEVENTF_WHEEL
Windows NT only: Specifies that the wheel has been moved, if the mouse has a wheel. The amount of movement is given in dwData
The flag bits that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, MOUSEEVENTF_LEFTDOWN is set when the left button is first pressed, but not for subsequent motions. Similarly, MOUSEEVENTF_LEFTUP is set only when the button is first released.
· dx
Specifies the mouse’s absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse’s actual x-coordinate; relative data is given as the number of mickeys moved. A mickey is the amount that a mouse has to move for it to report that it has moved.
· dy
Specifies the mouse’s absolute position along the y-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse’s actual y-coordinate; relative data is given as the number of mickeys moved.
· dwData
If dwFlags is MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.
If dwFlags is not MOUSEEVENTF_WHEEL, then dwData should be zero.
· dwExtraInfo
Specifies an additional 32-bit value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information.
rhosk
11-12-2003, 03:38 PM
Where it be (dll)?? Sounds as if that would be a good start! I'm desperate for any pointers right now (no pun intended).
That's actually how Flash does it, but the [window] needs focus to work. I mean, not even focus because it (cursor) has to actually be inside the movie (let's say - not a 1x1 pixel). I'd like this to work in a basic windows environment if at all possible.
OK tigger, that's not fair, you edited while I was typing :)
rhosk
11-12-2003, 05:05 PM
Um...Tigger, can you explain yer last post just a bit? I don't know where to start.
Corey
11-12-2003, 05:16 PM
Cool Tigg!
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
TJ_Tigger
11-12-2003, 06:16 PM
Originally posted by rhosk
Um...Tigger, can you explain yer last post just a bit? I don't know where to start.
Me neither. But I was looking around on one of the dll boards that Worm mentions and thought it might be a good place to start. It looks like User32.dll has a library with an alias of mouse_event where one might be able to determine if there has been mouse movement by using an 'event' called MOUSEEVENTF_MOVE. But I don't know how to proceed from here. I will play around and see what I can do.
Again, I think you could put this on a timer and have it fire every 60 seconds if you wanted to see if there was mouse movement.
rhosk
11-12-2003, 07:23 PM
I sorta get the gist, but still don't know where to start :confused:
Where in the heck is Worm!? :D Haven't seen him around the boards lately. I will play with this tomorrow and see if I can make it do something. It definitely sounds like the right track. Thanks again!
Corey
11-12-2003, 08:01 PM
I'm probably wrong but I think MOUSEEVENTF_MOVE is used to create mouse movement, not detect it... BTW one super easy way if you are in a rush is to use this and serve your content via kiosk mode browser. http://www.scriptsearch.com/cgi-bin/jump.cgi?ID=1274 A cheap workaround I know but it's fast. I'll take a look around and see if I can find any better ideas...
FYI I think getting GetCursorPos from user32.dll is the thing. You can set it on a one second timer to look for any change in that value...
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Corey's right, the best bet would be to use GetCursorPos in a timer (use a silent MP3 in 4). Problem is that its not directly callable from AMS because of the way the data is returned. I'll see if I can throw together a wrapper DLL to return the data in a meaningful way. When I do, don't forget to use some sort of tolerance in checking the position. The slightest mouse movement will change the X,Y position.
Corey
11-13-2003, 06:06 AM
This is the 5.0 forum so page timers are available. The moribundly silent MP3 rides no more.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
I agree the timers are a much better solution. The initial post asked how to achieve this in both versions though.
Here is the DLL.
The function to call is GetMouseXY with no parameters. It will return a string value like this:
400;;200
rhosk
11-13-2003, 10:15 AM
Once again Worm - awesome. Works beautifully! And the application/window doesn't even need focus; exactly what I needed. How it's able to do that, I don't know and don't care :D I'm going to use the Flash timer for now in 4.0 as I still have a large learning curve yet to go in 5.0. Can't even get labels figured out, LOL.
I do believe that there's absolutely nothing this program can't do. A fully functional screensaver/application launcher on idle - who would've thought? Thanks again to everyone that helped - especially the dll God!
Have a great day!
Originally posted by rhosk
I do believe that there's absolutely nothing this program can't do.
I can't stress that enough. Sure, there is sometimes the need of an occasional helper DLL/Plugin to get the functionality you need, but that is the brilliance behind AMS. I have never come across a more flexible application.
I can attest to this too; In the last couple weeks, I've been working on a simple app thats basically a video chapter book. A menu structure that takes you into the appropriate video. My development time in AMS was a whopping 4 hours.
After the project was completed. The client wanted to make a slight change. They wanted to have the video be able to go Full Window (not full screen). I tried about everything I could think of to get 2 media player objects to sync-up so that I could hide one, then show the other without any pause/rewind/fastforward, but didn't have any luck. The deadline, of course was today, or AMS5 would have handled it no problem.
Long story short, I had to use VB for the project and ended up putting in around 20 hours to do the same thing I was doing in AMS.
Crazy, I tell ya; crazy!
rhosk
11-13-2003, 06:17 PM
Update...I've been messing with the dll all day and I've found that using the "Flash Timer" and waiting for the timer to reach 0:00 doesn't really do the trick. Causes tremendous processing power for the loop (pegs at 100% throughout). I'm now experimenting with the silent mp3 "on End of Stream" and it seems to be a little easier on the resources. I've even resorted to "Application.Sleep" and the processor pegs at this as well. I haven't delved into 5.0 much more, but I'm wondering if any kind of "timer" will play havoc on the user's processor? I will experiment with this later. I'm sure that there's a better answer for everything.
When I think I have a decent project, I will post it and see what you all think. Not that I'm looking for approbation; just maybe a way to to it better. Worm? When this dll is called, it continues to call throughout a/the process. Didn't realize this at first. This could be good and bad. What I had to do (the novice programmer I am) is "capture it" and write it to a text file to call up later for a comparison. Is this the right road to take? Or might there be a similar/improved approach? I like what I have so far, but it's slow going. I'm dedicated to the task and I'm sure I will achieve the original thought (with the help from this fantastic team here of course).
And hey Worm, don't frett! We are just hours away from the official release of 5.0!! I for one can't wait! Sorry to hear about your woes; glad you got it worked out. Anyway, thanks again for all the support here! It's unprecedented to say the least.
Corey
11-13-2003, 06:27 PM
I agree with Worm, I've been down the aisle with every two bit design app in town and AMS is the only one that makes my heart go giddy-up. I guess what I'm trying to say is that it's definitely an issue of flexibilty and that I am married to my software so I oughtta know an imposter. Other than Director, which is obviously obscenely difficult to master, AMS is the only *serious* app of its type that I know of.
And also that Edmonton is about to whallop Montreal in a most unholy manner come Grey Cup day. Sorry Montreal, we love you too, but get ready for a nice big bowl of just-been-whalloped pudding.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-13-2003, 06:48 PM
I have to say Corey that I haven't personally "played" with Director, but I could probably tell you that hands down, I don't think they can keep up and it's a secret that needs to get out more!! I ran across AMS by accident (can't recall how at this moment), but maybe you guys should increase your marketing a bit. Couldn't hurt. I am impressing client after client and I for one am not even mentioning that I use this software to perform the magic. It has awe-inspiring power and why should I give away a trade secret?
It's an understatement when I say that you guys have something going on here; more than a diamond in the rough at this point. Please keep up your inspiring support, your incredible development and of course the unmatched customer service. I think I said it before, but I have never come across such attentive individuals and compassion for a product in my life. If you misplace that any time in the future, I'm here to tell you, you'll join the monotonous bandwagon & lose! I probably don't have to tell you that though. Keep up the great work!
I would parse the return string and store the X and Y values in a variable. Then on the next hit of the timer, compare the DLLs returned values to the variable. Saves on reading and writing to disk.
And yes, the DLL doesn't monitor the X/Y position. With AMS4 there isn't a way that I know of to hook back into the app. You have to wait for the DLL to finish it's process. Think of it as a File.Execute with the Wait option on. Hence the reason for a timer or some other event to fire at a somewhat regular interval so the call can be made for comparison.
Just for kicks...
I've been using a product called PowerBasic to create the DLLs that I've been posting here for about the last 3 months or so. PB is a much easier language for me to grab onto than C++. I thought I'd post the code to the CursorPos.DLL that I uploaded.
#########################################
#COMPILE DLL "CursorPos.DLL"
#INCLUDE "win32api.inc"
DECLARE FUNCTION GetMouseXY AS STRING
FUNCTION GetMouseXY ALIAS "GetMouseXY" () EXPORT AS STRING
STATIC P AS POINTAPI
GetCursorPos P
FUNCTION= STR$(P.x) & ";;" & STR$(P.y)
END FUNCTION
#########################################
Lot's of magic and hocus-pocus :rolleyes:
Corey
11-13-2003, 08:56 PM
rhosk, you have a great point but it's so tricky to balance everything. IR is a very special thing, tricky evolution to keep it what it is but you can bet we'll get some serious marketing improvements implemented over 2004. As always our main emphasis will remain on product and support quality first though. :)
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Thanks for the new DLL Worm! Incredibly cool as always. Thanks to you too Ron, for asking. Being able to include input from the mouse at run time is wonderful, and something I’ve been hoping for. Now that it’s here, it got me to thinking about different and more ways that it could be used.
I have tried to understand one Tigger’s early posts on this thread. And frankly, it’s over my head. I’m trying to understand how an AMS project can check or test the flags (dwFlags) that detect the state of the mouse buttons. I see that user32.dll is mentioned, but I’m lost after that. I can’t figure out the correct way to call user32.dll to get the state of MOUSEEVENTF_RIGHTDOWN, or MOUSEEVENTF_RIGHTUP, etc. I don’t know enough about it, to understand if I’m even looking in the right direction.
I realize that button objects, hotspot objects, and other objects, can detect this, but they each keep the information to themselves.
Specifically why I’m interested in this, is to create the ability to ‘drag’ the mouse at run time. Maybe a better way to say it, is being able to build a ‘rectangle selection’ function that’s available at run time. Here’s the plan:
I use Worm’s new DLL to get the mouse x,y coordinates. I test the mouse for the MOUSEEVENTF_LEFTDOWN flag to set the upper left anchor.
Using the new image position action, and perhaps image opacity actions, I load a small square red image set to 30%-50% opacity at the anchor spot. That image gets resized during the mouse drag by using Worm’s new DLL, and a little math, to figure the image size (bottom left pixel position). When the MOUSEEVENTF_LEFTUP flag is detected, the newly sized, opaque red selection is set.
A little more math, and a project could determine what objects, or parts of objects, are located under, or within the selected rectangle area.
Actually, with Worm’s new DLL, and the ability to test the state of the mouse buttons, a person could build all types of selection tools that were available at runtime. You could go beyond knowing if a person clicks on an image or button, to know the exact x,y coordinate on the image that the user clicked.
It could be used to allow a user to have full mouse control during an interactive game. (the new dynamic images lets a developer build pseudo-Sprites).
As developers, it would give us full runtime support for another input device. The new implementation of keyboard ‘on click’ actions, give us the whole keyboard to use at run time, I think full use of the mouse would be cool too.
Thanks to Worm’s new DLL, we got the x,y coordinates, if anyone has any insights on detecting button states, I’d sure be interested. That would give us full run time use of the mouse.
Corey
11-14-2003, 05:47 AM
Sounds great Jim. Just FYI though I think you're getting the terms reversed, I believe the following are used to *create* movement of the mouse cursor, they aren't co-ordinate values.
MOUSEEVENTF_RIGHTDOWN, or MOUSEEVENTF_RIGHTUP
I might be wrong but I think that's so...
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
One thing to keep in mind here is that the XY position is in aspect to the screen, not the window. If you tried to use the XY values as the Top and Left in a project, you wouldn't get the results you were after.
Corey, I’m sure you are right. I don’t have the first clue of what DLL to call, or how to structure the call to get what I’m after. That’s why I’m asking. Using events listed in Tigger’s post, just give me official (and understandable) sounding names for the button functions. This is all so far above my head that it makes me dizzy just thinking about it.
I’ve been able to figure out how to use Worm’s DLL’s and a few others that I’ve found, ones that come with documentation, but beyond that, I’m hopelessly lost. I’m hoping that you, or one of the other smart guys, can explain the real way to do it. I’m strictly a ‘cut & paste’ type of guy when it comes to messing with DLL’s. It’s all voodoo magic to me.
I might be able to think about ‘what’ could be done, but I need serious help and hand holding, to figure out ‘how’ to do it.
Worm, I didn’t realize that, but I think it could still work if I did a bit more math. I can check screen size when the program (project) starts. I can get window position to give me the XY value of the top left of the window. Since I would know the dimensions of my project, I think I could still figure everything out. It would take more math to figure all the ‘relative’ positions out, but I think it could be done. Your point is an important one, a person would have to use additional math to do it, for sure.
I just thought of another possible problem. I use two monitors. I think that the get screen size actions give you the rez of the main monitor, or the monitor that the AMS project is running in. I don’t know how a person would test for multiple monitor set up. Also sounds like it would add even more complexity to the math.
Corey
11-14-2003, 06:30 AM
There's a way to do this in a window rather than screen too Worm, although of course I have no clue how. I don't think it's that hard to do though FWIW...
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Your're right Corey, I'd have to use GetWindowRect.
Seems like this would be a better plugin than DLL though. I need to delve into that SDK and get my head into C++ and see what I come up with.
It sure is a great thing, that really smart people like Worm hang out here. I was just thinking, with all the new features that are coming online for this product, calling it Auto Menu Studio, seems like a major understatement. I realize that IR has quite a bit wrapped up already in the marketing on it, so the name is probably unlikely to change, but the ‘A’ in AMS ought to stand for Amazing. With all the new features, plug-in expandability, and brilliant people like Worm, the current and potential power of this program really is amazing.
Corey
11-14-2003, 07:06 AM
I agree Worm. Don't forget, we will gladly market and/or distribute any quality plug-ins you may someday design (if you wish us to) via our upcoming plug-in farm. :)
Jim, "Amazing Media Studio?" We'd be laughed off the playground by noon, with the exception of Adam who's hair is usually somewhere around 2 minutes behind him "just doing its thing", so 12:02 for him.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-14-2003, 07:29 AM
Wow, lots of good discussion here since last night, whew! Anyway, back to topic :) As I said earlier, the "timer loop" function is not the way to go here (major 100% pegged processor; mp3 is nill). I've decided to use timed silent mp3's for my mouse coordinate checks. Tis working out nicely so far. My question is: How would I go about "counting" the mp3 plays. ie, for testing I have a 15 second stream and a 60 second stream. The 15 second stream will kick in the "mouse hasn't moved" stream - the 60 second stream. This is what I'd like to count to enable adjusting the screen saver. It's merely comparing the mouse coordinate values every 60 seconds. If the mouse moves, start all over (trying to emulate a real screensaver). So, how would I count the 60 second streams and say if it reaches 10 minutes (10 counts); do something, else (if mouse moves) go back to 15 second stream and start over. I hope I'm not being confusing. I'm sure I need to set a variable and use something like count++ or whatever, but don't know the syntax. I'm almost there, thanks!
Ron,
Use whatever MP3 you want, set repeat to true.
Do the testing in the OnProgress of the MP3. It fires every seconds or so.
Corey
11-14-2003, 07:51 AM
Not at all rhosk, one call per minute is peanuts on any processor. Not even remotely in the ballpark of "100%" or of any actual performance concern, you can easily make several calls per second without any problem. Check out that math based dot project I did last week, it proves this handily http://www.indigorose.com/forums/attachment.php?postid=22937
Also I don't think a silent MP3 takes up "nill" resources, since the decoder is still engaged... Just doing a quick cursory test over here shows that indeed it does take up memory.
The timer is a much better choice for several good reasons IMO. For example it instantly solves your loop issue... :) Timers are way more efficient than the MP3 trick.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-14-2003, 08:01 AM
I tried using the infamous Flash timer and used an if statement waiting for it to hit 0:00 and my processor pegged during the loop. Or maybe the dll call was doing that? Anyway, this is why I moved to mp3 timers (still in 4.0 here). Seems to be a good workaround for now. And if I can count these plays, I can easily have the user adjust the minutes on their own.
Worm. I do get what you're trying to say; will the OnProgress do my counting for me? I can't see it right away here. Need a kick start.
BTW Grand Rapids Mich.(just noticed that)....born and raised in the Motor City :)
Corey
11-14-2003, 08:09 AM
That means you accidentally created an endless loop somewhere in there... A flash timer burns barely any resources at all, especially one set to loop once every 60 seconds, such a timer shouldn't even put a tiny dent in your processor.
But anyhow, as long as you've got the method you need, then great...
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
No you'll have to use a variable, add 1 to it every time it hits, then check the value.
TJ_Tigger
11-14-2003, 08:59 AM
Here is an example using Worms dll and the timer function in AMS5
The Autoplay image will follow the cursor. I don't know why I did it, I don't like it when web pages do that, but I thought it would be a good show of what you can do with Worm's dll.
TJ_Tigger
11-14-2003, 09:11 AM
This makes the tracking of the image smoother and closer to the mouse pointer.
Change line 14 in On Timer to the following, this takes into account the border on the window.
Image.SetPos("Image1", (cursor_x - (window_pos.X + 5)), (cursor_y - (window_pos.Y + 30)));
And change the Start Timer in the On Show actions to
Page.StartTimer("10");
TJ_Tigger
11-14-2003, 09:19 AM
With this, I am sure you could allow users to click and "drag" items on the screen, resize items and all sorts of cool stuff.
Originally posted by TJ_Tigger
With this, I am sure you could allow users to click and "drag" items on the screen, resize items and all sorts of cool stuff.
OK, I understand the 'drag' part, but how do I register the 'click' part?
TJ_Tigger
11-14-2003, 12:41 PM
I was thinking you could have them click on an object to pick it up and then click again to place it. When you click to pick it up you then use the dll that Worm wrote to have the image follow the mouse, then when they click again you leave it where they clicked.
Brett
11-14-2003, 12:42 PM
Nice work TJ and Worm! Theoretically one could probably create a CBT hook in the form of a plugin or external dll that could hook all windows messages (such as mouse up, down, movement, etc.) and let you handle them in a project. Here is an artile to help get you started...
http://www.codeproject.com/dll/hooks.asp
Good thinking there Tigger, I just might be able to make that work. Thanks for the suggestion.
rhosk
11-14-2003, 02:23 PM
OK, I have the screensaver test platform ready to go for mouse movement; both executing the program and termination. Seems to work great thanks to all the great tips here. Now to emulate a total package, I'd also like a "press any key" variable/dll call. Does this exist? Or will I have to input all the keys in the script (or at least the most common ones)? Is there any function I can use to sense any key press or activity from the keyboard?
I swear when I get this project smoothed out, I will post it for all to download. I think it has many uses and could spark interest in a variety of applications.
Colin
11-14-2003, 02:27 PM
Keypress events are in AMS50 Pro. Doing it in v4.0 would be tricky to say the least...
TJ_Tigger
11-14-2003, 02:46 PM
rhosk,
Use the On Key actions tab and put what every you want in for actions that will stop your screen saver. If you don't care what the key is then just use that as the event to terminate your screen saver.
If you wanted it to be a certain key to terminate your screen saver then you would check to see what key as pressed. For instance if you wanted the ESC key to be the one key to stop your screensaver then use somehting like this
if (e_Key == 27) then
stop screensaver
end
Tigg
Corey
11-14-2003, 05:03 PM
Cool stuff rhosk!!
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-14-2003, 05:45 PM
Originally posted by TJ_Tigger
rhosk,
If you don't care what the key is then just use that as the event to terminate your screen saver.
Tigg
That's just it Tigg, I don't want just a single key to terminate. I want to go all out and have an "any key" press to terminate (or prevent execute). Conversely, I want to include this in my "execution of the program as well" (if they are typing on the keyboard; to send the timer back to 0 with the any key press). I don't want a single key to do it. What did you mean by "....use that as the event". I'm really close here - and thanks for the interest and the help so far! If it weren't for all of you, I wouldn't be here :)
TJ_Tigger
11-14-2003, 08:09 PM
Ok, maybe I need to back up and try to better understand what you are trying to do.
The screensaver you have made, is it part of AMS or is it an external .scr or .exe file?
The "On Key" event is what I was referring to in my earlier post. I was trying to state that the "On Key" event will allow you to perform an action every time a key is pressed. If you want to stop a screensaver or reset a timer every time a key is pressed then you can use the "On Key" event to accomplish that. Place your actions on the "On Key" tab and when ever a key is pressed those actions will fire. If you want those actions to be tied to an actual key, not the "any Key", then you will need to use an if/then/end statement to test for what key was pressed and if it is the right one then execute the actions.
Does that help? Or am I way off base with what you are trying to do.
Tigg
rhosk
11-15-2003, 04:44 AM
OOOKKK. I see what you're saying now (new day :)).
First of all, I built this so-called screensaver, so far, in AMS 4.0 (no .scr or external .exe; I'll probably ask the user if they want their current screensaver turned off and input that - just thinking out loud here). As Worm suggested, I have the timer working great for mouse movement using a silent mp3 & the On Progress.
I just went to 5.0 and I do see the "On Key" event (duh, sorry for the misinterpretation) and it does work great. Now I'm wondering if I should merge these two versions somehow, or just dig down into 5.0 now that we all have the working version. I wanted to wait to "play" with 5.0 until I got some other work done. But, thinking about it, I could probably use your example you provided earlier as a guideline for the real-time mouse movement! Anyway, thanks for your efforts. If anything, you all have me thinking in all the right directions. I'll play with my new toy and I'm sure I'll be back. I was the one that couldn't even figure out how to emulate "labels" in this version, LOL.
TJ_Tigger
11-15-2003, 08:40 AM
I am glad you got it working. If you want to work with Key strokes then I would move to AMS5. As Colin said above, it would be tricky to do with AMS4. Unless you had a .scr as your screen saver, then keystorkes and mouse movement will automatically terminate the screen saver. (unless your screensaver only works on a special key, like ESC)
I vote go to AMS5
rhosk
11-15-2003, 08:44 AM
Hey Tigg, before you go! Your example with the window position vs. the cursor position; I'm playing around with this now and was wondering how I would compare the cursor position either with respect to the user's screen / or maybe a timed compare to itself (ie, if cursor_x doesn't match cursor_x at a given interval [say 2 seconds] then --do something). Can you set my brain straight. I AM in AMS 5 now :)
TJ_Tigger
11-15-2003, 09:17 AM
Originally posted by rhosk
how I would compare the cursor position either with respect to the user's screen / or maybe a timed compare to itself (ie, if cursor_x doesn't match cursor_x at a given interval [say 2 seconds] then --do something).
What I think you would want to do is to save the x coordinate to a variable (cursor_x_old) and compare it with the new variable(cursor_x_new).
I will have more time later today and I can try to post some code to help. Gotta get ready for my sons bowling b-day party.
TJ_Tigger
11-15-2003, 09:49 AM
Wife had to go get the cake so I had a couple of minutes. Try this.
On Page Show, set cursor_x to 0
cursor_x_old = 0
Page.StartTimer ("2000");
On Timer do the following
window_pos = Window.GetPos(Application.GetWndHandle());
cursor_pos = DLL.CallFunction("CursorPos.dll", "GetMouseXY", "", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
strlength = String.Length(cursor_pos);
delimiter_pos = String.Find(cursor_pos, ";;", "1", false);
cursor_x = String.Left(cursor_pos, (delimiter_pos - 1));
cursor_y = String.Right(cursor_pos, (strlength - (delimiter_pos + 1)));
if (cursor_x ~= cursor_x_old) then
--this indicates that the mouse pointer has moved so you should
--perform whatever actions you want here including the following
cursor_x_old == cursor_x
end
Try that and see if that works. This will start a timer that will trigger every two seconds. When it triggers it will get the current position of the cursor and compare it to the previous position of the cursor. If they do not match then you can perform some actions, and the old cursor variable is set to equal the new cursor variable. This will repeat every two seconds.
HTH
Corey
11-15-2003, 10:11 AM
A very hoppy birthday to Tigg Jr.!
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-15-2003, 10:17 AM
I see what you're trying to tell me there. 2 problems though. AMS 5 is not accepting the "==" (in the if statement) Says it needs to be replaced with a plain ol' "=" :confused:
And if cursor_x_old is always starting at 0, I don't see where the compare is. Unless the cursor is in the upper left of the screen, it's always gonna be ~= initially. I need a break too. I'll come back to this later. Thanks & Have Fun!!
rhosk
11-15-2003, 02:37 PM
Update on my project w/AMS5.
Awaiting a response from Tigger (no hurry btw) I moved on to the "On Key" event and although this works well, if the app loses focus, the On Key event is no more (it doesn't seem to work all the time either, could be a bug). This is not going to be good. In theory, if you launch an application and want to "sense" key presses, you can't rely on the app being the focused object (screensaver scenario). Not blaming AMS, just wondering if I can simulate that or make it think it is the focused app all the time. This is obviously a Windows System dll responsible for system-wide keypress sensing. I've seen a [keystroke] dll of sort here at the forum somewhere before, but my searches are turning up nothing. Maybe the old forum? Don't know if it will solve my problem though. Any further ideas would be appreciated? Maybe a new thread. I appologize for being such a pain.
TJ_Tigger
11-15-2003, 03:15 PM
Originally posted by rhosk
I see what you're trying to tell me there. 2 problems though. AMS 5 is not accepting the "==" (in the if statement) Says it needs to be replaced with a plain ol' "=" :confused:
And if cursor_x_old is always starting at 0, I don't see where the compare is. Unless the cursor is in the upper left of the screen, it's always gonna be ~= initially. I need a break too. I'll come back to this later. Thanks & Have Fun!!
The double == was a type on my part, it should have been only one =. The single = sets the value of the variable, where as double compares the two.
The cursor_x_old starts at 0 only when the page is first shown. It is then replaced within the IF statement
cursor_x_old = cursor_x --single = not two, typo in my first post
The timer will continue to fire even if the AMS program is not in the forground. But I don't know if it will detect the key strokes or not. That is something I would have to play with. Could you move the application to "Always On Top"?
Tigg
TJ_Tigger
11-15-2003, 03:16 PM
Originally posted by Corey
A very hoppy birthday to Tigg Jr.!
Thanks Corey. My oldest turns 7 tomorrow. Where does the time go. . .
Corey
11-15-2003, 03:50 PM
I know what you mean. :)
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
TJ_Tigger
11-15-2003, 04:01 PM
This be he. At Walt Disney World none-the-less.
http://home.mchsi.com/~griffin.freese/WDW/file/P5243020.jpg
Sorry but I love that picture and had to share.
Corey
11-15-2003, 04:05 PM
Great pic! That photo says everything you need to know about being 7. :)
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-15-2003, 04:37 PM
Originally posted by TJ_Tigger
Could you move the application to "Always On Top"?
Tigg
I did try this and thought the same thing. I've been playing around something fierce with this new upgrade. I thought too that it would make a difference, but it didn't. I think we need Worm again :) Worm, I will pay you and I'm not lyin'!! I think this idea has major potential if I could just work out the little details. Can you make or reference a windows dll that is used system-wide for keypress? Give me your PayPal addy (or form of payment) and I will compensate! Don't be modest, I'm serious!
And Tigg, if the "cursor_x_old" is referenced in the "On Show" as 0, then no matter what the cursor_x position is later, it will always be different and fire in the if statement, right? At least initially. I mean, after the if statement fires once, I'm home free, it would seem. Thanks much for hangin' on with me here.
And Corey! Any input? You seem to be avoiding this one, LOL!
BTW, that picture is awesome! You'd better copyright it!!! :D Good catch!
Corey
11-15-2003, 05:04 PM
No I'm not avoiding, just out of my depth. You're right about that photo though, it's a one in a million shot, the kind you see in photography textbooks. :) As for the "good catch" I think it's more like a nice planned shot, this one's just a little too good to have been a fluke... :)
I love the expression on the doll's face created by the slight motion, he's like, "YEEEEEEEHAH!" I swear I can see him grinning.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
I'm not sure where to go with this. I can think of some ways to do it, but they seem very cludgy. Let me do some thinking and see what I can come up with.
rhosk
11-15-2003, 05:55 PM
Thanks Worm for even considering!!! But, I have to ask. What does ""cludgy"" mean? I have an idea with your context, but must inquire. I hope it doesn't mean that it can be done, but with extenuating circumstance! Hmm, very intriguing to say the least. Throw it at me!
TJ_Tigger
11-15-2003, 08:27 PM
kludgy
"kloo'gee"
awkward, unpolished, designed with complete disregard to established rules, potentially fatal
The kludgy highway off-ramp that curled into a figure-eight loop before turning into a two-foot merge lane into traffic was cited as the cause of numerous accidents by the state highway patrol.
dictionary.com (http://dictionary.reference.com/search?q=kludge)
rhosk
11-15-2003, 08:50 PM
Eewe, doesn't sound good!! LOL We'll continue this tomorrow. Have a great evening everyone.
Corey
11-15-2003, 10:35 PM
Excellent word.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
Better if I'd have spelled it correctly :)
TJ_Tigger
11-15-2003, 11:39 PM
Originally posted by Corey
No I'm not avoiding, just out of my depth. You're right about that photo though, it's a one in a million shot, the kind you see in photography textbooks. :) As for the "good catch" I think it's more like a nice planned shot, this one's just a little too good to have been a fluke... :)
I love the expression on the doll's face created by the slight motion, he's like, "YEEEEEEEHAH!" I swear I can see him grinning.
Yeah, I love the picture. That would be Buzz Lightyear that he is holding. We were sitting in the Magic Kingdom watching the night parade, and I decided to turn off the flash and increase the time to about 1/5 of a second and it came out that way on the first click. I was amazed by how it came out.
I tried to do the same with my other boy, but he was sitting too far away and there was not enought light. He was sitting with his mama.
http://home.mchsi.com/~griffin.freese/WDW/file/P5243023.jpg
Corey
11-15-2003, 11:55 PM
That's one of the things which I love about photography, the randomness. Not even painting or drawing have that exact same type of serendipity component. I can hardly wait to get heavy into video art next year, should carry that same component but with that added dimension of motion and time.
Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)
rhosk
11-16-2003, 06:02 AM
This thread's getting outta hand, haha! Anyway Tigg another new day, finally got it to work. What I did was "not set the variable" for cursor_x_old right away. Just using it in the if statement only. This works well. It does restart my timer at the very beginning on its very first fire, but this will be transparent to the user anyway. From then on, if the mouse is moved within the 2 second timer, the if statement fires - perfect! And, once again, the app does not need to be focused - another perfect. Now, if I can get the key press issue worked out, I'm home free!! :)
Here is a key press idea that will work in AMS4. Create a 1 pixel by 1 pixel hotspot. Give it the hot key F1, and set the On Mouse Click action to set a value to a variable. This way hitting the F1 key will be the same as clicking on it with a mouse. Position the hotspot off of the edge of your project page.
Now select it and copy it (CTRL+C) now make about 103 copies of it (CTRL+V lots of times). For the next step it’s easier to use the object browser located in the left pane of AMS4. Start double clicking on each hotspot in turn, and set a new hot key for it. I’d bet that you could go through the keys in under an hour. You probably don’t need the uppercase letters, unless the person has their Caps Lock on, it’s up to you.
I tested it out in AMS4 sort of. I set the action to Close Application for my test, I think you would want the action to assign a value to a variable instead. Something like:
%KeyClick% = "1"
I made about 120-130 copies of these hot spots, but I only took the time to set new hot keys for about 10 of them.
I didn’t notice any appreciable delay in the project even with all those hot spots.
On that loop you got built to test if the mouse moved, add a check for the value of the variable you set with the hot spots.
Something like:
IF (%KeyClick%=1)
//Put code to stop your screen saver here
END IF
I’d bet you could have the whole thing finished in less than 2 hours. It’s an idea anyway.
*** A couple of the possible keys won't work in AMS4, the escape key Esc, and the Enter key, maybe a couple more. I believe with AMS5, you can use all the keys.
rhosk
11-16-2003, 08:48 AM
Jim, does the application need focus for this to work? I will play with your suggestion and it sounds like a good one if the window doesn't need to be active.
Yes the app needs to have focus.
rhosk
11-16-2003, 02:47 PM
Yeah, this is why we need Worm!! I am confident that he can come up with something. If he can conquer this, the possibilities are endless. You need to think about it a bit. I mean, capturing system-wide keypresses w/out focus! I think they should think about a plug-in for this. I just seen another post asking about keypress and as far as I know, it's not even in the upgrade. It can do it "On Key" in the page options, but I don't think it can do it with a button (could be wrong - matter of fact, probably am). I've tried everything from bring window to front, always on top, etc...Nothing worked to keep it active. Thanks for the tip though JimS, still learned some new stuff!
rhosk
11-17-2003, 06:13 PM
**bump**
Sorry, been busy rewriting the project I spoke of before that I rewrote in VB. AMS4 to VB to AMS5. Now thats an odd development cycle :p
rhosk
11-18-2003, 04:38 AM
Just keeping the thread a little in sight Worm :) Goes without saying but, you take your time! I don't even begin to think that you make me your priority. Good things come to those who wait. Please let me know if I do anything from this end. Good luck with your conversions :cool:
rhosk
11-18-2003, 11:14 AM
OK, my ongoing saga. Trying to get [creative] here. This may be deep.
Is there a way to "log" system-wide keystrokes?; then I can just check the file every few minutes to reset a timer? Conversely, maybe there's a current Windows .dat file or something that I can compare? Does anyone know of a file that constantly changes as keystrokes are happening or apps are being launched?
TJ_Tigger
11-18-2003, 12:49 PM
Originally posted by rhosk
Found a free little program that logs keystrokes (all) in real time and the AMS app does not need focus!!
I would be very careful with Keyloggers. They have shown these on TechTV and had articles in magazines. I would be very upset if I found that a keylogger were installed on my machine for any program. I even use Search & Destroy and Ad Aware to remove spyware and would not be happy if it found a key logger. If you do use a key logger, I would make sure that you erase the file every time your timer fires.
Tigg
rhosk
11-18-2003, 01:19 PM
Eh, was gonna do it on exit of the app, but good point. Might as well erraticate it at every sweep, thanks Tigg.
Protocol
11-17-2004, 10:12 PM
Just a WEEEEEE bit out-dated (lol), but here's an updated version of Tigger's mouse movment template (which used Worm's Cursor DLL). I've added comments and reworked the code to make it more easily understandable. I also added some enhanced features that make it more applicable. If for some reason it seems to glitch, just drop the Timer setting up a few milliseconds (it's set on preload). This could be useful for some of youz out there.
Can you say "Solitare"?
:)
Protocol
Corey
11-17-2004, 10:23 PM
Can you say "Solitare"?
Yeah sure. Watch. "Solitaire". [choke, cack, gasp, wheeze, cough, dishevel, faint, somersault]
Whew... Piece of cake. :yes
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.