AutoHotkey Community

It is currently May 27th, 2012, 12:48 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: June 13th, 2011, 11:41 pm 
Offline

Joined: September 17th, 2008, 7:38 pm
Posts: 19
Can anyone open Excel 2007 to test something out =)?

I don’t like to hold my modifier keys; I find it more comfortable to toggle it like a Caps Lock. I got this code from an AHK member along time ago:

Code:
$LShift::
    if GetKeyState("LShift") ; LShift is logically down. Release it.
        Send {Blind}{LShift Up}
    else ; LShift is logically up. Press it.
        Send {Blind}{LShift Down}
Return


Tap LShift once, and it stays down. Tap it again to release it. So I decided recently to do this for my LAlt key:

Code:
$LAlt::
    if GetKeyState("LAlt") ; LAlt is logically down. Release it.
        Send {Blind}{LAlt Up}
    else ; LAlt is logically up. Press it.
        Send {Blind}{LAlt Down}
Return


For excel, I want to open the Office button which is Alt+f. I tap LAlt, then press f, but nothing happens. I had this problem with Ctrl in some adobe applications, so I made LCtrl send a RCtrl down, which seemed to make it work. The code below, where I make LAlt send RAlt down, seems to work in excel, but why is that?

Code:
$LAlt::
    if GetKeyState("RAlt") ; RAlt is logically down. Release it.
        Send {Blind}{RAlt Up}
    else ; RAlt is logically up. Press it.
        Send {Blind}{RAlt Down}
return


The LShift to make LShift keep down is no problem. Any way to keep LAlt with LAlt?

Thanks for any info


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 17th, 2011, 9:19 pm 
bbint wrote:
Can anyone open Excel 2007...

...I don't think Excel is needed, I tested in Notepad.

bbint wrote:
The LShift to make LShift keep down is no problem. Any way to keep LAlt with LAlt?

...in my testing, it appears that GetKeyState() is capable of getting the logical state of LShift while LShift is physically held. However, for some reason, GetKeyState() is NOT capable of getting the logical state of LAlt while LAlt is physically held. This appears to be a bug in GetKeyState()...or possibly a limitation of (or bug in) Windows.

Since GetKeyState() is unreliable in some cases, I recommend a simple toggle...

Code:
$LAlt::
KeyWait, LAlt
if (state_LAlt_toggle) {
   Send, {Blind}{LAlt up}
} else {
   Send, {Blind}{LAlt down}
}
state_LAlt_toggle:=!state_LAlt_toggle
return

...this works in Notepad, tell me if it works in Excel. This code should also work for LShift (rename all "LAlt" to "LShift")...(but I didn't test it with LShift). I know your LShift code already works, but this is simpler.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, jrav, MSN [Bot] and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group