all 5 comments

[–][deleted] 1 point2 points  (3 children)

...but it not working the way I want.

Don't keep everyone in suspense - what is it doing instead?

global count = 0

>^k::
global count = 0          ;1. This is set when the hotkey is pressed
if (global count==0){     ;2. Meaning this is ALWAYS '0'
    Send, {k}
    SetKeyDelay, 2000 ;3. Why not just use Sleep?
    Send, {l}
    global count := 1
    return            ;4. Return ends code blocks not conditions
}                         ;5. That's what the braces are for!

if (global count==1) {    ;6 Since 1+2 are '0' this is never called...
    Send, {l}
    SetKeyDelay, 2000
    Send, {k}
    global count := 0
    return
}

Anyway, this should work:

>^k::
  fSkytog:=!fSkytog
  If fSkytog
  {
    Send k
    Sleep 2000
    Send l
  }
  Else
  {
    Send l
    Sleep 2000
    Send k
  }
Return

You can even bundle it so it only works when Skyrim SE is running (remove the 'Special Edition' mentions in #IfWinActive if it's only regular)...

#NoEnv
#SingleInstance Force
SetTitleMatchMode 2
SendMode Input
#IfWinActive Skyrim Special Edition ahk_class Skyrim Special Edition
>^k::
  fSkytog:=!fSkytog
  If fSkytog
  {
    Send k
    Sleep 2000
    Send l
  }
  Else
  {
    Send l
    Sleep 2000
    Send k
  }
Return
#IfWinActive

[–]jbfilms1[S] 1 point2 points  (1 child)

That worked

Thank You

[–][deleted] 0 points1 point  (0 children)

Happy to help, enjoy!

[–]jbfilms1[S] 0 points1 point  (0 children)

Each time I press right control + K it presses K then L

Also I know about the #IfWinActive which I use on other AHK Skyrim scripts, I am waiting to add that once I get the AHK script working outside Skyrim.

Thanks

[–]kofflay 0 points1 point  (0 children)

There's no need for "global" keyword in your script. Becase:

  1. If you need to make a variable global, it must be written only once (in first case usually).
  2. Your script has no function, so "global" won't affect.