Sign in to follow this  
Followers 0
Prx3k

Unfocus a Window temporarily

12 posts in this topic

#1 ·  Posted (edited)

Hi there,

What am I trying to do is open a Notepad, then type something in Korean in it and close the Notepad. In theory, it's pretty simple. However, Microsoft decided to chose the key "ALT GR" (right alt), so switch between English and Korean input mod. So basically, when I open the Notepad, I press RALT, but it goes to the toolbar (File, Edit, etc), instead of switching the input type. I think it's because the RALT key actually doesn't press the ALTGR key, but rather the regular ALT key...

So 2 options for me :

  • I unfocus the notepad, press right alt, and focus the notepad again (may not solve the problem, since RALT doesn't work)

  • I find a way to press ALT+GR using autoit (RALT doesn't work)

Any clues ? How can I simulate the ALTGR key ?

Thank you very much

Edited by Prx3k

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Prx3k,

Welcome to the AutoIt Forums, :)

This seems to work well.

Opt("WinTitleMatchMode",4)
WinActivate("[CLASS:Shell_TrayWnd]")
Send("{LCTRL}{RALT}")
;- OR
Send("^{ALT}"
;- OR
Send("^!")

WinActivate("[CLASS:Notepad]")

*Edit - Added some options

Anonymous

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Thanks for your answer, however it seems I need to press ALTGR, and RALT =/= ALTGR for whatever reason... I am on a French keyboard

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Prx3k,

Wikipedia state that ALTGR = Ctrl+Alt

http://en.wikipedia.org/wiki/AltGr_key

*Edit -

Send("{LCTRL}{LALT}{RALT}") ; - Maybe this is want you need?

Anonymous

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Decipher,

Indeed, except for the language toolbar, which requires the ALTGR key to be pressed. If I do CTRL+ALT (not even using AutoIt here), the input mod doesn't change. It does only switch when I press the ALTGR key.

Share this post


Link to post
Share on other sites

Prx3k,

Try

Send('!Gr')

Anonymous


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

No more success :

AutoIt isn't the problem here, it's Windows itself... AltGr is equivalent with CTRL+ALT, except for this. Plus, ALTGR seems to be a key modifier, so I guess there is no ASCII code to simulate it :/

Share this post


Link to post
Share on other sites

Prx3k,

Maybe it is working and the application isn't responding quick enough.

Try increasing the key release delay.

Opt("SendKeyDownDelay", 15)

Anonymous


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Still no success...

It would be great if a moderator could change the title to "Simulate ALTGR with AutoIt" or something like this :)

Share this post


Link to post
Share on other sites

#10 ·  Posted

You can do that yourself. Edit your initial post using the full editor and change it.


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Shotgun approach since I can't test here:

Send("{RALT down}yourkeyhere{RALT up}")

Send("^!yourkeyhere")

Send("{CTRL down}{ALT down}yourkeyhere{ALT up}{CTRL up}")

?

There's probably some better way we could do this if we knew the scancode.

Alternatively, if you already know what text you want in notepad, use a different method than AltGR+Send to send the unicode text to notepad.

Eg:

See the Appendix for some tips on using Send. AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to send (see {ASC} at the bottom of the table below).

For a given unicode string I would think you could do something like:

For $i=1 To StringLen($str)
    Local $c=StringMid($str,$i,1)
    Local $a=AscW($c)
    If $a>0xFF Then
        Send("{ASC "&$a&"}")
    Else
        Send($c,1)
    EndIf
Next

But even that seems unnecessary and redundant.

Edit: According to the help file, ASC must be used for unicode; but using Send() with the Raw flag set to 1 works fine for me?

WinActivate("Untitled - Notepad")
Local $str=BinaryToString("0x019C019D",3);Latin Turned M, N with Left Hook
Send($str,1)
Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

#12 ·  Posted

If all you are doing is switching between languages - Regional and Language Options has the ability to reassign the key sequences to this.

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