Jump to content

Reassigning <SpaceBar> as the <Enter> key


jlroper
 Share

Recommended Posts

I'm using a program in which the <Enter> key is used to signify an end of a particular region. Since the program doesn't have the capability of using another key for the action the <Enter> key normally takes, I would like to use AutoIt to get it done. I'm a VB.NET programmer, but I'm having issues understanding how to get this done in using the scripting language AutoIt uses.

Can someone tell me how (simpler the better) to reassign the <Enter> key to the <SpaceBar> key within only a certain program? Just giving the <SpaceBar> key the same functionality as the <Enter> key would be fine, too.

Any help would be greatly appreciated, thank you.

Link to comment
Share on other sites

take a look at

http://www.autoitscript.com/forum/index.php?showtopic=90492

* You can specify a hot key, any key, including the CTRL-ALT-DEL, F12, WIN-..., etc. An exception is the only specific keys for notebooks, such as Fn.

* You can associate a hot key with the specified window, ie the hot key will work only if this window is currently active.

* You can disable repeat key if it holding down.

* You can to disable (enable) at any time all the hot keys by calling just the one function.

* You can block a call to your function, if the previous call has not yet been completed.

* You can associate multiple keys with one function for the subsequent analysis of the code key.

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

This is the code I have:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=SendEnterForSpaceBarPress_Transcriber.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <HotKeySet.au3>


HotKeySet ("{SpaceBar}","Enter")


Func Enter()

    WinWaitActive("Transcriber 1.5.1")
    Send("{ENTER}")

EndFunc

I compiled the.AU3 as an .EXE and ran the .EXE file. I then went to the program (which has that title specified). I then hit the <SpaceBar> key, but the <Enter> key action didn't take place.

Am I doing something wrong?

Link to comment
Share on other sites

Am I doing something wrong?

there isnt "{SpaceBar}" its only "{SPACE}", you dont have main loop to keep script alive

HotKeySet ("{SPACE}","Enter")

While 1
    Sleep(10)
WEnd

Func Enter()
    If WinActive("Transcriber 1.5.1") Then
        Send("{ENTER}")
    Else
        HotKeySet ("{SPACE}")
        Send("{SPACE}")
        HotKeySet ("{SPACE}","Enter")
    EndIf
EndFunc
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

there isnt "{SpaceBar}" its only "{SPACE}", you dont have main loop to keep script alive

HotKeySet ("{SPACE}","Enter")

While 1
    Sleep(10)
WEnd

Func Enter()
    If WinActive("Transcriber 1.5.1") Then
        Send("{ENTER}")
    Else
        HotKeySet ("{SPACE}")
        Send("{SPACE}")
        HotKeySet ("{SPACE}","Enter")
    EndIf
EndFunc

I tried the exact code you posted, it's still not performing an action which <Enter> took when <Space> was pushed (when ran as the compiled .EXE or the .AU3). Does anyone else have suggestions?

Thank you.

Link to comment
Share on other sites

1) When the spacebar is pressed run the function called enter

2) If a window titled "Transcriber 1.5.1" has the focus then press the enter key.....end function

3) If the window titled "Transcriber 1.5.1" is not active then make then turnoff the hotkeyset for spacebar (so the function is not called again), press the spacebar then turn the hotkeyset back on. End function.

So....Is there a window called this? Is it active? I'm guessing no.

If it does exist....is it a game....don't answer that question as bots are not permitted here. But games may resist our efforts ;)

Edited by picea892
Link to comment
Share on other sites

@picea892

Not neseceraly that its a game, your jumping too fast to conclusions

@jlroper

Is Transcribed 1.5.1 Mac OS X 10.3 aplication, or its for Microsoft Windows?

Probably it be nice to post some more info about program that your trying to automate, and info about you OS.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

The code works fine with transcriber 1.5.1

You can down it from sourceforge and confirm.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I did try to download it and it tells me that its "Mac OS X 10.3 or later" app :/

Nice to hear thet someone confirmed that its working ;)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

The code works fine with transcriber 1.5.1

You can down it from sourceforge and confirm.

That's odd, I am using the exact (windows based) 'Transcriber' program from SourceForge you are, and it's not working.

Can you tell me exactly how you are going thru the process? It just maybe how I think it should be implemented.

Thank you.

Link to comment
Share on other sites

1) I copied the code that pice upped into a new file in my editor.

2) Saved it

3) hit F5

4) opened a transcriber demo

5) clicked on the first line for speaker 1

6) hit space bar and watched it behave like the {enter} key

7) stopped the execution of pice's script

8) hit space bar in transcriber and watched it go back to being a space bar

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

1) I copied the code that pice upped into a new file in my editor.

2) Saved it

3) hit F5

4) opened a transcriber demo

5) clicked on the first line for speaker 1

6) hit space bar and watched it behave like the {enter} key

7) stopped the execution of pice's script

8) hit space bar in transcriber and watched it go back to being a space bar

Interesting, it was because I had the statement, '#Include <HotKeySet.au3>' at the top of the file. I thought it needed to be there, so it could be referenced properly. I guess not.

I removed that, and it worked perfectly! I appreciate the clear steps, by the way.

Thank you for your assistance.

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...