Sign in to follow this  
Followers 0
Guy_

Newbie partial keyboard locking / looping

14 posts in this topic

Hi all and thanks for this *amazingly* helpful app & support B)

I'm starting an IrfanView slideshow with a script. However, if people too near to the keyboard inadvertently touch a key, the show is stopped, which in this case can be a "disaster".

I'd like a way to have plain keyboard keys locked while it's playing, but still have a way out.

My preferred way out is Alt+F9, an already defined call to an established script, which I could just as well integrate in this new script that someone might kindly provide me with, hopefully :o

This is kind of how far of an idea I get after some reading...

HotKeySet("!{F9}", "ExitIrfanView") ; [this same combo should unlock the keyboard, quit the slideshow and start a video player, a script I've already made (except for the locking/looping problem)]

Run("C:\program files\IrfanView 3.97\i_view32.exe /slideshow=c:\pics") ; starts slideshow

[some kind of loop around this here?]

BlockInput(1)

[loop]

Func ExitIrfanView()

BlockInput(0)

[my code to quit slideshow and start up a video player instead]]

Exit

EndFunc

But I understand BlockInput may only be escaped from with ctrl+alt+del?

So maybe there's some other nifty loop solution that doesn't eat my CPU during the slideshow?

This is where it's getting over my head a bit...

If someone knows a simple keyboard locker app that I could start and quit from within AI, then that's almost just as great. But I might still need the looping help.

Many thanks in advance!

Share this post


Link to post
Share on other sites



By the way: it's a W2K SP4 machine

Share this post


Link to post
Share on other sites

As far as i understand you right you don't need help with the "close slideshow/open video" part, so i just left that blank B)

If you look in your helpfile, under AutoIt->Language Reference->Loop Statements you can find help for the 3 (5 with newest beta) loop functions!

The one we're gonna use is:

While 1
...
WEnd

so your code would look like this:

HotKeySet("!{F9}", "ExitIrfanView"); [this same combo should unlock the keyboard, quit the slideshow and start a video player, a script I've already made (except for the locking/looping problem)]

Run("C:\program files\IrfanView 3.97\i_view32.exe /slideshow=c:\pics"); starts slideshow

While 1
BlockInput(1)
WEnd

Func ExitIrfanView()
BlockInput(0)
;[my code to quit slideshow and start up a video player instead]]
Exit
EndFunc

Hope thats what you needed

HF

Felix N. (tdlrali)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Oh yeah, for this script archrival has wrote a vb program that blocks all input except for ctrl-alt-del!

You might wanna ask him if he can modify is so it blocks ctrl-alt-del too but allows alt-f9... i bet he is happy to help you! B)

Felix

Edited by Felix N.

Share this post


Link to post
Share on other sites

"Gee, thanks". I hope you mean well, but this was "the worst advice I've ever gotten" :o

I thought of such a simple looping scheme myself, but as I feared, the CPU is constantly maxing out.

The BlockInput "of course" seems to block my escape as well. And on top of that: even the ctrl-alt-del just showed me the window, but I couldn't get out and had to reset.

BTW: I repeat that I just need protection against accidental keystrokes, not against bad-mannered geeks trying every combo B)

Share this post


Link to post
Share on other sites

"Gee, thanks". I hope you mean well, but this was "the worst advice I've ever gotten" :o

I tested it on XP instead of W2K though. So if that was the reason, I apologize B) (but I doubt it)

Share this post


Link to post
Share on other sites

"Gee, thanks". I hope you mean well, but this was "the worst advice I've ever gotten" :o

I'm sure you've been given worse advice in your life. Anyway, welcome to the forums -- hopefully my attempt to help you won't provoke such a cold retaliation. B)

Calls to BlockInput() do not need to be looped. Once you activate input blocking, it's active until you deactivate it.

Your current approach will not work because hotkeys become inactive while BlockInput() is active. Currently there is no way around this so your best option is to research a slideshow player that doesn't respond so daintily to keyboard activity. You might find one here or here; otherwise a Google search might be more fruitful.

When you find one that you can tolerate, it may offer only a few different keys (instead of the myriad that IrfanView appears to offer), but you may not want all of those keys to be available -- at that point you can use HotkeySet() to map those unwanted keys to an empty function which will effectively disable those keys.

Of course, you could take this approach for IrfanView if you really wanted to but HotkeySet() is limited to 64 mappings, so you wouldn't be able to disable most of the keys.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I'm sure you've been given worse advice in your life. Anyway, welcome to the forums -- hopefully my attempt to help you won't provoke such a cold retaliation. B)

Sorry, it was in good humour. It just seemed to me that Felix hadn't really thought it through or tried it himself. I had thought of that kind of loop, but had predicted the CPU maxing out before trying it; also it seemed a bit obvious that the key to get out of it wouldn't work anymore :D That's all :graduated: It was ages ago that I had to use my PC's reset button twice, you see :x

I had tried the plain command without the loop as well, but it didn't do anything at that time...

Anyway, they say they're sure they're not touching the keyboard and I believe them, so it must be something else and I'm not going to pursue this further at the moment.

Still, your advice is very helpful for future cases, so Thank You for that & the links :o And to Felix for the link. I'll forget the other part :):x

Edited by Guy_

Share this post


Link to post
Share on other sites

Hey! I'm really sorry I gave you such a crappy piece of code! I hope I didn't do any harm ?!? :o

I didn't really think about what I posted, I just saw that you needed a loop so i gave you one...^^

Again, I apologise that I didn't think about what I posted, I hope we can both learn from this: Never believe what a Newbie posts, always double check! B)

Felix N.

Share this post


Link to post
Share on other sites

Hey! I'm really sorry I gave you such a crappy piece of code! I hope I didn't do any harm ?!? :)

"I forgive you"... :o I still tried it because I was desperate :D

Harm? Now that you mention it... For some reason my XP won't shut off anymore. I've never had this before. But please don't offer me your solution B):graduated:

Share this post


Link to post
Share on other sites

Well, you could always jerk the power cord B)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Well, you could always jerk the power cord B)

Luckily I can restart and shut down in two more Windows installations. I should now use AutoIt to do just that :o

Share this post


Link to post
Share on other sites

Lol, I don't see why you can't shut down anymore.... B) kinda strange, autoit doesn't do anything to files or anything...

Maybe you should run a BlockInput(0) command, i don't know whether the blockinput changes anything that didn't get changed back due to the restart? But you're right, you're better off not doing it^^

Felix N.

Share this post


Link to post
Share on other sites

Lol, I don't see why you can't shut down anymore....

It was probably the last drop in a crowded system situation, not *only* caused by you... :graduated::o

I figure it might well happen if you freeze a PC when a lot of other programs are running and you have to reset. You never know what can happen there when you're out of luck... B)

Share this post


Link to post
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
Sign in to follow this  
Followers 0