Jump to content

Need a Background Layer to Monitor for Mouse or Keyboard Interrupt


Recommended Posts

Hi guys,

In the same spirit as my last post (http://www.autoitscript.com/forum/index.php?showtopic=115130), I am looking for a way that I can monitor for mouse or keyboard input and cause it to interrupt the operation of my program. I want it to constantly run in the background so that if the user presses any key, or touches the mouse, the program is interrupted until they click a button to resume it.

I am currently using hotkeys to interrupt the script, but in the event the script goes haywire, I would like to simply mash my keyboard to stop it.

I guess this would be like a constantly operating sub-execution layer (if such terminology exists).

Any thoughts?

Link to comment
Share on other sites

What you are describing could be considered as a keylogger, which is pretty much taboo around here.

You could use the _IsPressed() function to monitor keys but that is not the way to go.

Truth is your hotkey method is infact the best way to do what you want, as _IsPressed() will not interupt a running function, where as a hotkey will.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

No no no. I do not care WHICH key is pressed. I only care that a separate layer does the monitoring so that I can detect when input is received WHILE executing the main loop. Like I had said in my other post, at some stages, the algorithm takes on the order of 10's of minutes to operate.

I have a much more general desire to build the GUI Functions and the algorithms themselves on separate layers so that I can interact with the GUI while my program is running. Although, this seems a bit farther out.

Understanding the keyboard/mouse interrupt is a start in that direction.

I'm not looking for a keylogger.

P.S. If someone can actually help me, I will send you a copy of my code - you can examine the code to see that it's not a keylogger. I am simply wary of distribution since it's written for a popular game.

Edited by ok123jump
Link to comment
Share on other sites

Well I dont know what you mean by a different layer (If you can be bothered Id like to know (for my education)) but A hotkey will interupt you algorithm no matter how long it takes, which is what you want isnt it?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Well I dont know what you mean by a different layer (If you can be bothered Id like to know (for my education)) but A hotkey will interupt you algorithm no matter how long it takes, which is what you want isnt it?

Of course I can be bothered, it is I who is asking for help! :mellow:

I'm certain that I am using the term incorrectly, but I envision that there could be several loops running simultaneously according to priority. Their priority would rank the loops according to their importance - thus a base layer would be a loop, with priority 1, a program layer would be a loop running with priority 2. The lower priority loops would execute code (e.g. a pixel checksum algorithm), while the higher priority loops would carry out program monitoring functions (e.g. check for error flags, monitor keyboard & mouse for any interrupt from the user, etc...).

The monitoring functions could provide a way to dynamically catch errors or issues, pause the program and allow the user to fix them before continuing. Additionally, I want the users of my program to be able to interface with the GUI while the program is executing it's main loop method.

To be honest though, since your first response, I am somewhat concerned that this class of prioritized layer functionality could be used for ill-intentioned purposes. I would not like to see it used for such an activity, I am simply attempting to make my program as user-friendly as possible.

I write a lot of code for scientific computing in Matlab, LabView & FORTRAN and I have not been able to successfully implement this structure thus far. AutoIt3 is flexible in many ways that these other programs are not. I am hoping that if I find a solution in AutoIt3, I may be able to apply it to some of my other programming languages as well.

For Example, there is simply no hope of a Pause button for MATLAB without this prioritized layer functionality. No hotkeys, nothing... ='(

Edited by ok123jump
Link to comment
Share on other sites

Ok thanks.

I think I get you now, and I'll try again to respond accordingly.

It sounds as though you are describing multithreading :P which Autoit3 dosent do.

What a lot of people do to try and work around that is multiprocess by having different scripts handle differnt jobs of a project, if you get what I mean.

Im probably wrong again lol :mellow:

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I'm not 100% sure what you mean with "layers", but to get the idle time see _Timer_GetIdleTime() in the helpfile.

Edited by AdmiralAlkex
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...