Jump to content

HotKeySet("[")


Recommended Posts

Hi,

i try to write a script to close the brackets "({[" by a script.

Why does the following script not work?

If I use the part with "(" only everything is fine.

But if I use the lines with "[" and "{" too I have some ''funny'' results

like Keyboard is blocked afterwards.

Any help is welcome.

HotKeySet("(","WriteCloser_1")
HotKeySet("[","WriteCloserEk")
HotKeySet("{{}","WriteCloser_3")

While 1
    Sleep(500)
WEnd

Func WriteCloser_1()
    HotKeySet("(")
    Send("(")
    Send(")")
    Send("{LEFT}")
    HotKeySet("(","WriteCloser_1")
EndFunc

Func WriteCloserEk()
    HotKeySet("[")
    Send("[")
    Send("]")
    Send("{LEFT}")
    HotKeySet("[","WriteCloserEk")
EndFunc

Func WriteCloser_3()
    HotKeySet("{{}")
    Send("{{}")
    Send("{}}")
    Send("{LEFT}")
    HotKeySet("{{}","WriteCloser_3")
EndFunc
Link to comment
Share on other sites

Hi, and Welcome!

try this:

HotKeySet("(","WriteCloser_1")
HotKeySet("[","WriteCloserEk")
HotKeySet("{{}","WriteCloser_3")

While 1
    Sleep(500)
WEnd

Func WriteCloser_1()
    HotKeySet("(")
    Send("(")
    Send(")")

EndFunc

Func WriteCloserEk()
    HotKeySet("[")
    Send("[")
    Send("]")

EndFunc

Func WriteCloser_3()
    HotKeySet("{{}")
    Send("{{}")
    Send("{}}")

EndFunc

accomplishes the same thing without the last 2 steps.

Link to comment
Share on other sites

Ah,

I see what you mean...answered too fast.

try this:

HotKeySet("{F1}", "_F1")
HotKeySet("{F2}", "_F2")
HotKeySet("{F3}", "_F3")

While 1
    Sleep(500)
WEnd

Func _F1()

Send("(")
Send(")")

EndFunc

Func _F2()

Send("{")
Send("}")

EndFunc

Func _F3()

Send("[")
Send("]")

EndFunc
Link to comment
Share on other sites

Hi billo,

thank you for your answer,

but it does not working too.

If I open a editor (Notepad++ in my case)

The keybord is blocked after pressing the "[" key.

BrainDrain,

I notice you're using a hotkey of "{{}" That hotkey would be very hard to press. You don't have two keys with the '{' character on them. Therefore it will never be hit. Also I would recommend you search the forum for _IsPressed(). Actually it is in the helpfile as a UDF include these days I believe. Check it out. It will be potentially much more helpful. You simply want to re-act to certain combinations of key presses not react to a specific hotkey.

I hope this helps you on your journey,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Thank you for your answers.

@billo of course I can use F1 F2 F3 but that is not what I want.

I'd like to use the "{" and "[" as usual and autoIt should close the brackets and put the cursor between them.

Perhaps I'll find a solution in JSThePatriot hint.

Link to comment
Share on other sites

Nice tip!

another one for my box of stuff...

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("DB", $dll) Then
        Send("{]}")
    Send("{LEFT}")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

Thanks JS

Link to comment
Share on other sites

Nice tip!

another one for my box of stuff...

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("DB", $dll) Then
        Send("{]}")
    Send("{LEFT}")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

Thanks JS

Happy to be of service...I hope it helps the OP as well!

Regards,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

On a UK keyboard, and probably many others, you don't want

HotKeySet("{{}","WriteCloser_3")

you want

HotKeySet("+[","WriteCloser_3")

and no need for _IsPressed.

HotKeySet("+[", "WriteCloser_3")

While 1
    Sleep(90)
WEnd

Func WriteCloser_3()
    HotKeySet("+[")
    Send("{")
    Send("}")
    HotKeySet("+[", "WriteCloser_3")
EndFunc ;==>setcurly
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hello ,

thank you again.

@martin: On a german keybord the "[" and "{" brackes need the ALT GR key that is {RALT} for AutoIt.

But {RALT} can't be used for a Hotkey in Combination with another key.

Or am I wrong?

HotKeySet("{RALT}0") but it does not work (like I have expected).

So I have to use the _IsPressed solution.

Link to comment
Share on other sites

Alt Gr is actually Ctrl+Alt.

#Include <Misc.au3>
$dll = DllOpen("user32.dll")

HotKeySet("^!0", "WriteCloser_3")

While 1
    Sleep(90)
WEnd

Func WriteCloser_3()
    HotKeySet("^!0")
    Do
    Until _IsPressed("11", $dll) <> 1
    Send("{")
    Send("}")
    HotKeySet("^!0", "WriteCloser_3")
EndFunc ;==>setcurly

This works fine on my swedish keyboard. The _IsPressed() is there because the Ctrl key just got stuck for me without it.

Edited by AdmiralAlkex
Link to comment
Share on other sites

I know 7 is opening bracket, I just used 0 as you had yourself in the previous post :(

HotKeySet("{RALT}0") but it does not work (like I have expected).

Link to comment
Share on other sites

Looks like you are use brackets very ofthen, - developer? Sorry that is not topic answer, but man, do you like typing? If yes, just pass through all of "Solo on the keyboard" exercises, and you will not need hotkeys for putting special simbols and brackets. You will type fast and clear. :(

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