Doing something if any key is pressed - vbscript

I was wondering how to make a script so every time I click a key on my keyboard the script runs my wanted commands and loop

Related

How to simulate keyboard press on turbo debugger for DOSBOX?

A program I'm writing needs to check keyboard press and loop until it has in the buffer, then check what key was pressed, so when I run it in the debugger, it loops forever because there is no keyboard press.
Until now I've just changed the lines on the program to skip checking keyboard and jump right to the place I want to check, but is there any less exhausting way to do it?

How to setup Toggle Key to display the shell script output during execution?

In my team they have asked me to create a shell script with toggle key option to display the command output/errors when a arrow key is pressed. And it need to hide the output when the same arrow key is pressed. Is there a way we can achieve this using a shell script?
I don't have a solution yet but the script which we are using now is throwing so many output and its making the screen loaded without so many lines of std output/errors during execution. And we would like to hide the output using the toggle key and when needed if we press a key it needs to display the output during execution.
No idea on how to start with this. Need some idea or thoughts on how to achieve this?
Expected:
Shrink the output using toggle key (say for example UP arrow key) and when needed if we press the same UP arrow key it need to display the output again.
Actual:
No code available as of now to do this function.

How to run a function in the terminal everytime a key is pressed(bind the whole keyboard)

I have been playing with bash for the past week and would like to create a function that is called every time I press a key on the keyboard.
I read about bind but it forces me to bind to a specific key.
If anybody can assist me I would appreciate it
I would like to accomplish this without new shells like zsh or fish

vb6: interrupt endless msgbox loop

I am writing a program in VB6.
By mistake many times my code contains an endless loop, inside which there is a message box. For example:
while a>0
msgbox "a is positive"
wend
Then I press the play/run and I realize what has happened. Is there any way to stop the debugging/running of my program?
The only thing that works so far is Ctrl+Alt+Del and end task. But this way the whole visual basic closes and I lose my unsaved data. (please don't comment that I should save my program more often. I know it (now)).
Edit: I found on the internet that maybe esc or ctrl+c or ctrl+break could do the job. The first two do nothing and my laptop doesn't have a break key
Solution: I have the insert key in my laptop. on the key there is also written pause for use along with the Fn key. So I was able to break the application by pressing Ctrl+Fn+Insert (which maybe could be translated in Ctrl+Pause)
edit: link to photo of my keyboard:
ctrl + break will work. If you don't have those keys, use the on screen keyboard.
Start | Run | osk
Then press ctrl + break.

watir-webdriver functions do not execute as a script but works on the interactive ruby shell

I am trying to write automated scripts for a web application using watir. There is a slider in the UI, which has a range from 1 to 11. It is a horizontal div. So, if you press the right arrow key, the number increments by 1, and if you press a left arrow key the number decrements. My problem is when I try to execute the following statements in irb individually, the send_keys function works fine, but as soon as I move it to a ruby script, it does not execute the send_keys.
assert($b.div(:class, "position").text == "2")
$b.div(:class, "scroll").wait_until_present
$b.div(:class, "scroll").click
$b.div(:class, "scroll").send_keys(:arrow_right)
assert($b.div(:class, "position").text == "3")
The send_keys(:arrow_right) works if I run separately in irb. When trying to run through a script file, it does not give me any error and remains on the same number, and it just says "Failed assertion, no message given."
The b.div(:class, "scroll").click is to activate the div on which the the right arrow key is to be pressed.
I'm using watir-webdriver 0.6.2, Firefox 18.0.2, Windows 7 64-bit
As you mentioned b.div(:class, "scroll").click is to activate the div on which the key is to be pressed,
There might be possibilities that this is taking a while to activate the div, and when you are doing that in IRB that is getting proper time to load as it takes time to execute another line, but when you are doing that in script and executing you are performing send_keys action immediately after clicking on the div, and execution not getting proper time to activate that Div.
Try to give a pause/delay in your script for a while and then try to perform send_keys.
To give a pause/delay you can use sleep(time_period)

Resources