AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[help] how to toggle a key on/off

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Mon May 12, 2008 7:21 pm    Post subject: [help] how to toggle a key on/off Reply with quote

I was wondering how do I keep my ctrl key held down if ScrollLock is on... if it is off then don't hold ctrl

im trying to implement it into this script:
Code:
;;;;; Hotkeys ;;;;;

#ifWinActive, Lineage II

;;;;; NUMPAD for F keys ;;;;;
Numpad1::F1
Numpad2::F2
Numpad3::F3
Numpad4::F4
Numpad5::F5
Numpad6::F6
Numpad7::F7
Numpad8::F8
Numpad9::F9


NumpadAdd::Sendplay, !{F1}
NumpadEnter::Sendplay, !{F2}
NumpadSub::Sendplay, !{F3}


I only want ScrollLock to toggle ctrl; not my keymapping
Back to top
View user's profile Send private message
Razlin



Joined: 05 Nov 2007
Posts: 288
Location: canada

PostPosted: Mon May 12, 2008 7:34 pm    Post subject: Reply with quote

Code:

scrolllock::
   GetKeyState, state, scrolllock, T
   if state = D
       send {control down}
else
       send {control up}
return

_________________
-=Raz=-
Back to top
View user's profile Send private message
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Mon May 12, 2008 8:06 pm    Post subject: Reply with quote

thanks alot... do i just put it anywhere in my current script?

EDIT: i put it at the end of my script and it doesnt work
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 883

PostPosted: Mon May 12, 2008 8:24 pm    Post subject: Reply with quote

Code:
*ScrollLock::Send % "{blind}" (GetKeyState("LCtrl") ? "{LCtrl up}" : "{LCtrl down}")

_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Mon May 12, 2008 8:34 pm    Post subject: Reply with quote

Thanks [VxE] that was perfect!

Now I decided to remap my keys so now I have:
Code:
;;;;; Hotkeys ;;;;;

#ifWinActive, Lineage II

`::Suspend, toggle

;;;;; QWER for F keys ;;;;;
q::F1
w::F2
e::F3

r::F4
a::F5
s::F6
d::F7
f::F8
z::F9
x::F10
c::F11
v::F12

1::Sendplay, !{F1}
2::Sendplay, !{F2}
3::Sendplay, !{F3}
4::Sendplay, !{F4}
5::Sendplay, !{F5}

*capsLock::Send % "{blind}" (GetKeyState("LCtrl") ? "{LCtrl up}" : "{LCtrl down}")


How do I make a message pop up in the tray icon saying when i have my keymap toggled on and or my ctrl is toggled on?

Example:
if my keymap is ON and my ctrl is OFF it will say in the same bubble
_______________
| Keymap = ON |
| CTRL = OFF |
---------------------
v
[X] <--- trayicon

or maybe someone knows a better way of knowing when these 2 things are toggled?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2472
Location: Australia, Qld

PostPosted: Mon May 12, 2008 9:56 pm    Post subject: Reply with quote

TrayTip Question
Back to top
View user's profile Send private message
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Mon May 12, 2008 11:37 pm    Post subject: Reply with quote

Lexikos wrote:
TrayTip Question

yea traytip.. i just tried putting it in my script but i cant get it to work properly
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2472
Location: Australia, Qld

PostPosted: Tue May 13, 2008 6:53 am    Post subject: Reply with quote

A few suggestions:
  • Read the documentation.
  • Try the example in the documentation.
  • If you've written code and it isn't working, post it so we can help.
  • If you've written code and it works, but not "properly," post the code and define what "properly" is.
Back to top
View user's profile Send private message
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Tue May 13, 2008 1:58 pm    Post subject: Reply with quote

Code:
;;;;; Hotkeys ;;;;;

#ifWinActive, Lineage II

~`::Suspend, toggle
{
RefreshTrayTip:
TrayTip, Refreshed TrayTip, Keymap is ON, , 16
return
}

;;;;; QWER for F keys ;;;;;
q::F1
w::F2
e::F3
r::F4
a::F5
s::F6
d::F7
f::F8
z::F9
x::F10
c::F11
v::F12

1::Sendplay, !{F1}
2::Sendplay, !{F2}
3::Sendplay, !{F3}
4::Sendplay, !{F4}
5::Sendplay, !{F5}

*capsLock::Send % "{blind}" (GetKeyState("LCtrl") ? "{LCtrl up}" : "{LCtrl down}")
{
RefreshTrayTip:
TrayTip, Refreshed TrayTip, CTRL is ON, , 16
return
}

There's what I tried. I know it's probably completely wrong but I have never done any kind of scripting before. I'm only using AHK for this one game.

AHK won't run because there's duplicate lines (TrayTip).
Back to top
View user's profile Send private message
stewie7griffin
Guest





PostPosted: Tue May 13, 2008 2:59 pm    Post subject: diablo Reply with quote

are you trying to make this for Diablo? best game ever
Back to top
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Tue May 13, 2008 4:24 pm    Post subject: Reply with quote

nah im making it for lineage2
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2472
Location: Australia, Qld

PostPosted: Tue May 13, 2008 10:42 pm    Post subject: Reply with quote

Quote:
Code:
~`::Suspend, toggle
{
RefreshTrayTip:
TrayTip, Refreshed TrayTip, Keymap is ON, , 16
return
}
The first line is a one-line hotkey - because the command is on the same line as the hotkey, there is an implicit return after the hotkey. If you intended the TrayTip to be shown when you press the key, move Suspend, toggle to the next line. Labels, such as "RefreshTrayTip:" are used as targets for goto/gosub. You cannot use the same label name twice. In this case you aren't using goto/gosub to run the code, so you can remove the label. Also, {braces} have no effect for labels, only functions and if/else/loop.
Code:
~`::
Suspend, toggle
TrayTip, Refreshed TrayTip, Keymap is ON, , 16
return
The same goes for the *capsLock hotkey.
Back to top
View user's profile Send private message
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Tue May 13, 2008 11:45 pm    Post subject: Reply with quote

thanks lexikos, that was extremely helpful

this is what i have now and it's working the way I want it to
Code:
;;;;; Hotkeys ;;;;;

#ifWinActive, Lineage II

~`::
Suspend, toggle
if A_IsSuspended = 1
{
TrayTip, KEYMAP, OFF, 99999, 3
}
else
{
TrayTip, KEYMAP, ON, 99999, 2
}
return


;;;;; QWER for F keys ;;;;;
q::F1
w::F2
e::F3
r::F4
a::F5
s::F6
d::F7
f::F8
z::F9
x::F10
c::F11
v::F12

1::Sendplay, !{F1}
2::Sendplay, !{F2}
3::Sendplay, !{F3}
4::Sendplay, !{F4}
5::Sendplay, !{F5}

*capsLock::Send % "{blind}" (GetKeyState("LCtrl") ? "{LCtrl up}" : "{LCtrl down}")

The only problem I have with it now is making the traytip permanent. I had to improvise by putting the seconds to 99999, but it still disappears after a minute.
Back to top
View user's profile Send private message
Guest






PostPosted: Wed May 14, 2008 4:50 am    Post subject: Reply with quote

Code:
Gui +AlwaysOnTop +ToolWindow
Gui, Font, bold
Gui, Add, Text, w75 vGuiText, Keymap: ON
Gui, Show, % "x" . (A_ScreenWidth - 100) . "Y" . (A_ScreenHeight - 85)
Return

;;;;; Hotkeys ;;;;;

;#ifWinActive, Lineage II`

~`::
Suspend, toggle
if A_IsSuspended = 1
  GuiControl,, GuiText, Keymap: OFF
else
  GuiControl,, GuiText, Keymap: ON
return


;;;;; QWER for F keys ;;;;;
q::F1
w::F2
e::F3
r::F4
a::F5
s::F6
d::F7
f::F8
z::F9
x::F10
c::F11
v::F12

1::Sendplay, !{F1}
2::Sendplay, !{F2}
3::Sendplay, !{F3}
4::Sendplay, !{F4}
5::Sendplay, !{F5}

*capsLock::Send % "{blind}" (GetKeyState("LCtrl") ? "{LCtrl up}" : "{LCtrl down}")
Back to top
nvus



Joined: 02 Aug 2007
Posts: 22

PostPosted: Wed May 14, 2008 2:41 pm    Post subject: Reply with quote

wow thanks alot. thats MUCH better.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group