why using {Sleep} affects IME ? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
Seven0528
Posts: 269
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

why using {Sleep} affects IME ?

Post by Seven0528 » 29 Jan 2023, 20:21


I'm sorry. I'm posting it again because there was a big mistake in the question... (I'm a newbie, I can't edit my post)

Image

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance Force
#Include <IME>
IME:=Class_IME()

F2::
F3::
F4::
{
    ; <Set Language to Korean>
    IME.SetKeyboardLayout(0x0412), Sleep(50)
    IME.SET(1)
    IME.SetConvMode(1)

    sendkey:="dkssudgktpdy", sendkey_delayed:=""    
    Switch A_ThisHotkey
    {
        case "F2":
            Loop Parse, sendkey
                sendkey_delayed.=A_LoopField "{Sleep 50}"
            Send(sendkey_delayed) ; d{Sleep 50}k{Sleep 50}s{Sleep 50}s{Sleep 50}u{Sleep 50}d{Sleep 50}g{Sleep 50}k{Sleep 50}t{Sleep 50}p{Sleep 50}d{Sleep 50}y{Sleep 50}
        case "F3":
            Loop Parse, sendkey
                Send(A_LoopField), Sleep(50)
        case "F4":
            Loop Parse, sendkey
                SendText(A_LoopField), Sleep(50)
    }
}
  (the example script was written in v2, but v1 has the same problem)




1.
 Why is there a difference between F2 and F3 methods?
F2 responds to IME.
dkssudgktpdy --> 안녕하세요
F3 does not respond to IME. (each char is not combined by IME)
dkssudgktpdy --> ㅇㅏㄴㄴㅕㅇㅎㅏㅅㅔㅇㅛ
I wonder why using {Sleep} affects IME.
(I'm also curious about the meaning of {Sleep} in "Send" commands)



2.
 Even if I don't care about input method editor,
I don't understand why this "Send({Sleep 50})" actually has a longer delay than 0.05 seconds.
Also, I don't understand why this does not have uniform delays.
Delays that run earlier tend to be slower than delays that run later.
Does anyone have a detailed understanding of this problem?



 

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: why using {Sleep} affects IME ?  Topic is solved

Post by mikeyww » 29 Jan 2023, 20:39

As I understand it, Sleep() is a function that induces a short delay in executing script commands, while {Sleep} is a key name (in braces) for Sleep-- the computer's Sleep key-- that causes the computer to sleep, for some computers. A number inside braces after a key name indicates how many times to send the key.

Some computers might not respond to a sleep key.
If SetKeyDelay is never used by a script, the default Delay for the tradional SendEvent mode is 10.
Sending a key 50 times with SendEvent would require approximately 500 ms (somewhat more), by default. The key history shows the timing.

The "batch lines" setting indicates how often the script should sleep for 10 ms. The default frequency for sleeping 10 ms is 10 ms.
Last edited by mikeyww on 29 Jan 2023, 20:54, edited 1 time in total.

User avatar
Seven0528
Posts: 269
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: why using {Sleep} affects IME ?

Post by Seven0528 » 29 Jan 2023, 20:52

Code: Select all

Msgbox SleepSC:=Format("sc{:03X}",GetKeySC("Sleep")) ; sc15F
Msgbox SleepVK:=Format("vk{:02X}",GetKeyVK("Sleep")) ; vk5F
 Oh, Interesting...
I thought "{Sleep}" was a separate(?) grammar like "{Text}" or "{Raw}".
"{Sleep 50}" was just a key name, it simply means repeated key input. Just like the {a 30} thing.
Now I understand what happened.
Thank you for teach me, mikeyww!

Post Reply

Return to “Ask for Help (v2)”