Jump to content

hotkeyset altgr ? :o


Recommended Posts

Hi, 1st, sorry for my english :whistle:.

Well I would like to know how I can do to hotokeyset the altgr key.

I've tried

Func _IsPressed($hexKey)  
  Local $aR, $bO
  
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf
  
  Return $bO
EndFunc

Global $Paused
while 1
    If _IsPressed('A5') = 1 Then myfunc()    (I also have tried alt+ctrl)
  Sleep(10)
Wend

but it works very bad... like if when I press alt gr, alt or control still keep pressed.

Thx for your help !

Link to comment
Share on other sites

I know what you mean, but looking in the Helpfile, I cannot find the actual hex code for this key. I will look on MSDN for you and see what I can find.

#include <Misc.au3>

HotKeySet("A5", "MyFunc")

While 1
    Sleep(100)
WEnd

Func MyFunc()
    MsgBox(4096, "You pressed:", "The AltGr key!")
EndFunc

Doing this, and pressing Shift+A makes the popup appear. I do not see anywhere the key that you are looking for. I dont think this is allowed to be pressed by AutoIt.

Edited by JBr00ks
Link to comment
Share on other sites

oh, and I have forgotten, getasynckeystate need a decimal value.

My code now looks like :

while 1
    If _IsPressed('11') = 1 and _IsPressed('12') = 1 Then
        Space2()
        sleep(10)
    endif
Wend

and

Func Space2()
Send("{Space down}")
Sleep(10)
Send("{Space up}")  
sleep(25) 
Send("{Space down}")
Sleep(10)
Send("{Space up}")
EndFunc

But it's like if space was permanantly pressed, and like if altgr was fonctionning at the same time (permanantly pressed too), but I want that altgr be really bypassed.

Edited by arkane
Link to comment
Share on other sites

OK, I found these links, just in General:

WikiPedia

To start press the ALTGR key.

The key to the ALTGR problem

Just to let you know that European keyboards do not work with the AltGr key, apparently.

#include <Misc.au3>

$DLL = DllOpen("user32.dll")

While 1
    Sleep(100)
Wend

If _IsPressed("11", $DLL) = 1 & _IsPressed("12", $DLL) =1 Then
    MsgBox(4096, "", "")
    Exit
EndIf

Doesn't work aswell. I will keep looking.

Edited by JBr00ks
Link to comment
Share on other sites

It doesn't work with this include with my version, but this code was working if I wrote it like this :

Func _IsPressed($hexKey)
  Local $aR, $bO  
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf  
  Return $bO
EndFunc


While 1
    If _IsPressed('11') = 1 and _IsPressed('12') = 1 Then
    MsgBox(4096, "", "")
EndIf
Wend

But as I said, it works correctly with a msgbox, but If I call a send command, It sends it permantly, and the algr key isn't bypassed ...

Edited by arkane
Link to comment
Share on other sites

Here we go:

#include <Misc.au3>

$DLL = DllOpen("user32.dll")

While 1
    If _IsPressed('11', $DLL) = 1 and _IsPressed('12', $DLL) = 1 Then
    MsgBox(4096, "", "")
EndIf
Wend

Works just fine for me!

Pressing either AltGr or Ctrl+Alt will msgbox.

Lol, yeah, that's what I told you 3 or 4 posts before lol xD.

but if I use :

While 1
    If _IsPressed('11') = 1 and _IsPressed('12') = 1 Then
    Space2()
    sleep(10)
EndIf
Wend


Func Space2()
Send("{Space down}")
Sleep(10)
Send("{Space up}")  
sleep(25) 
Send("{Space down}")
Sleep(10)
Send("{Space up}")
EndFunc

Everything is buggy :

Altgr send space permantly to my game, it doesn't works on windows, on my game, the space sequence is sent permanantly, and visibly, the altgrkey isn't bypassed, and the pression of altgr creates some bugs in my game so the game detects, Space, and altgr.

Plus, if I press AltGr, it's like if ctrl+alt was permanantly pressed too, and I need to repress them to unfreeze them....

Link to comment
Share on other sites

I can set a sleep(2000) that I still got all theses bugs =), So I don't think there is a problem with the Sleep time.

Or maybe I'm wrong.

I would agree with JBr00ks on this one. The other day I learned exaclty what could be accomplished in about 500ms as I was trapping for a doubleclick event, and it's not all that much. As for your game I would have a hard time believing you would need to press and release the spacebar twice in less than the amount in takes to double click a mouse. Lengthen them out to be about 200ms a piece and try that.

Edited by kiwikid
Link to comment
Share on other sites

  • 2 years later...

Anybody any news on the ALTGR key?

My new notebook has one and it really annoys me since I use ALT-LeftArrow a lot in the browser, so I wanted to create a function to bypass it, but apparently this isn't so easy.

The example above works, but it also triggers CTRL+ALT which I do use a lot (no not only CTRL-ALT-DEL >_< ).

So hotkeysetting or detecting ispresseds from LCTRL+RALT would do the trick I guess?

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