Jump to content

Recommended Posts

Posted

I want to type certain letters or words and basically whatever I type I want to go into a special format into an input. I'm using this so I can assign hotkeys to certain function and don't know where to start:

Example:

If on my keyboard I press and hold the control key and the letter y then in the input my script would put:

Ctrl + Y

the input would be letters only so it shouldn't be too complex.

Can someone help?

Posted (edited)

well, it is kind of hard to help when we can't see your code.

My best guess is use the example in the helpfile, and change it so it looks like this example:

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("11", $dll) = 1 and If _IsPressed("59", $dll) Then
       $string = String("Ctrl + Y")
    If _IsPressed("23", $dll) Then
        MsgBox(0,"_IsPressed", "End Key Pressed")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

This is quite messy, but without seeing your code....

Edited by Volly
Posted

Why do you keep screaming about seeing my code? I clearly told you I have no code that can possibly help with the my question.

Either you don't understand this or you are you really do want code. In that case all you have to do is put an input on a gui because thats all I have. The rest (having the script input whatever I press) is what I am hoping someone can help me with.

Does anyone have a better approach?

Posted

Why do you keep screaming about seeing my code? I clearly told you I have no code that can possibly help with the my question.

Either you don't understand this or you are you really do want code. In that case all you have to do is put an input on a gui because thats all I have. The rest (having the script input whatever I press) is what I am hoping someone can help me with.

Does anyone have a better approach?

I'm pretty sure that Volly just doing his best to help you when he ask for the code.

It's allways easier to help a person when you know exactly what they are trying to do.

BTW: the example that Volly provided should work, so maybe there is a something in your code that prevent it work, but it's up to you what you wan't. I'm just saying that you could save the headach muttley

Regards

Posted

Yes this method no doubt works. But this can be a very long and time consuming process, and can take up a big part of my script.

So I was wondering if there is a simpler way.

Or should I suck it up and put this into an include?

Posted

unfortunately, a full log of all keys pressed would constitute a keylogger, which I think is against AutoIt forum rules. Anybody know about that?

Opt("GuiOnEventMode",1)

GUICreate("test",200,50)
$input = GUICtrlCreateInput("",15,15,170,20)
GUICtrlSetState(-1,128)
GUISetState()

GUISetOnEvent(-3,"Quit")

Global $dll = DllOpen("user32.dll"), $key, $ctrl, $pressed = False

While 1
    $key = DllCall($dll,"int","GetAsyncKeyState","int","0x59")
    If $key[0] And Not $pressed Then
        $ctrl = DllCall($dll,"int","GetAsyncKeyState","int","0x11")
        If $ctrl[0] Then
            GUICtrlSetData($input,"CTRL+Y ",1)
        Else
            GUICtrlSetData($input,"Y ",1)
        EndIf
        $pressed = True
    ElseIf $pressed And Not $key[0] Then
        $pressed = False
    EndIf
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc
Posted (edited)

You are looking for this:

http://www.autoitscript.com/forum/index.ph...st&p=532733

Don't ask me to explain it.... wacko.gif

Exactly what I wanted. Thanks muttley

@crzftx:

unfortunately, a full log of all keys pressed would constitute a keylogger, which I think is against AutoIt forum rules. Anybody know about that?

Let me open your eyes...

the input would be letters only so it shouldn't be too complex.

You said

unfortunately, a full log of all keys pressed would constitute a keylogger

Did I say a full log of keys?

which I think is against AutoIt forum rules.

Try not to be such a sycophant.

Edited by nowagain
Posted (edited)

One question. Does anyone know if I will need the below line if I already have a created gui and input.

I don't quite understand this:

$hWnd = _WinAPI_CreateWindowEx (0, 'msctls_hotkey32', '', BitOR($WS_CHILD, $WS_VISIBLE), 10, 10, 200, 25, $gui_Main)
Edited by nowagain
Posted

Why do you keep screaming about seeing my code? I clearly told you I have no code that can possibly help with the my question.

Either you don't understand this or you are you really do want code. In that case all you have to do is put an input on a gui because thats all I have. The rest (having the script input whatever I press) is what I am hoping someone can help me with.

Does anyone have a better approach?

To explain it simply, many times seeing the code can help because we can get a idea of what you are attempting. There are often times someone will explain something in what they think they need, but will be way off the mark. I foolishly assumed you made some attempt at solving your issue first, and was hoping to see what you tried first before posting on your issue. Many of us who have been using AutoIt for a while now try to use this approach and find it quite helpful and educational. From your abrupt response and reviewing your first post I see now you made no such attempt before hand nor pointed out any attempt to search the forum for information in previous post on this thread. My mistake was to help you. I won't make it again.

Sorry to intrude in your obviously troubled scripting problem and practices. Perhaps in the future you should understand that many of us are happy to help, but we will make mistakes in understanding what someone asks when they explain it in the way that you did. My sincere apologies on offending you.

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
×
×
  • Create New...