Something wrong with my code, either control or alt key becomes sticky, which manifests in script becoming unresponsive until I press either of these keys.
What could be wrong? Is there a likely culprit? I have checked the code but found nothing not right.
Sticky control or alt key Topic is solved
Re: Sticky control or alt key
I don't see any code here.
Re: Sticky control or alt key
Here is the code, thank you.
Here is the other of the two active scripts
I would appreciate knowing what you were looking at/for if there is a method.
Code: Select all
;q:: ;MIDI play notes
hModule := DllCall("kernel32\LoadLibrary", "Str","winmm", "Ptr")
vDeviceID := 1, hMIDIOutputDevice := 0
if DllCall("winmm\midiOutOpen", "Ptr*",hMIDIOutputDevice, "UInt",vDeviceID, "UPtr",0, "UPtr",0, "UInt",0, "UInt")
return
hDev := hMIDIOutputDevice
vChan := 0
;==============================
AW:= A_IsUnicode? "W": "A", A_CharSize:= A_IsUnicode? 2: 1
hWinMM:= DllCall("kernel32\LoadLibrary" AW, "Str", "Winmm.dll", "Ptr")
NumDevs:= DllCall("Winmm\midiOutGetNumDevs"), sz:= 20+32*A_CharSize
Loop, % NumDevs {
VarSetCapacity(DevCaps, sz, 0)
DllCall("Winmm\midiOutGetDevCaps" AW, "UInt", id:=A_Index-1, "Ptr", &DevCaps, "UInt", sz)
Name:= StrGet(&DevCaps+8)
DevName%A_Index%:= Name
DevNames.= id ": " Name "`n"
}
StringTrimRight, DevNames, DevNames, 1
MsgBox % DevNames
#^`::
send, ^s
reload
return
#esc::
MidiNoteOn(hDev, vChan, 93, 127) ; stop
MidiNoteOff(hDev, vChan, 93, 127)
return
#InstallKeybdHook
#if (WinActive("ahk_class AbletonVstPlugClass") or WinActive("ahk_class Ableton Live Window Class") or WinActive("ahk_class Ableton Live 10 Suite.exe"))
{
^s::
Lwin up:: return
!x:: send mxm
!=::
send m
send u
send m
return
!z::
{
toggle := !toggle
if (toggle)
{
send mzm
sleep 300
send {-}
send {-}
send {ctrl down}----------------{ctrl up}
}
else
{
send mxm
}
}
return
Lwin::return
#q::
varis:= 102
MidiNoteOn(hDev, vChan, varis, 127) ; solo
MidiNoteOff(hDev, vChan, varis, 127)
MidiControlChange(hMIDIOutputDevice, vChan, 209, 0 )
return
Ralt up:: send {,} ; free
Rctrl::
mousegetpos, x, y
Send {Click 667 60} ; re-enable automation
mousemove, x, y
return
printscreen:: send ^+C ; capture midi
#`::
MidiNoteOn(hDev, vChan, 80, 127) ; back to arrangement
MidiNoteOff(hDev, vChan, 80, 127)
return
/::
MidiNoteOn(hDev, vChan, 82, 127) ; set marker
MidiNoteOff(hDev, vChan, 82, 127)
return
,::
MidiNoteOn(hDev, vChan, 84, 127) ; prev / next marker
MidiNoteOff(hDev, vChan, 84, 127)
return
.::
MidiNoteOn(hDev, vChan, 85, 127)
MidiNoteOff(hDev, vChan, 85, 127)
return
#[::
; MidiControlChange(hMIDIOutputDevice, vChan, 102, 127) ; prev/next scene
MidiNoteOn(hDev, vChan, 96, 127)
MidiNoteOff(hDev, vChan, 96, 127)
return
#]::
; MidiControlChange(hMIDIOutputDevice, vChan, 102, 127) ;
MidiNoteOn(hDev, vChan, 97, 127)
MidiNoteOff(hDev, vChan, 97 , 127)
return
^!PgUp::
MidiNoteOn(hDev, vChan, 96, 127)
MidiNoteOff(hDev, vChan, 96, 127)
return
^!PgDn::
MidiNoteOn(hDev, vChan, 97, 127)
MidiNoteOff(hDev, vChan, 97, 127)
return
[::
MidiNoteOn(hDev, vChan, 98, 127) ; prev / next track
MidiNoteOff(hDev, vChan, 98 , 127)
return
]::
MidiNoteOn(hDev, vChan, 99, 127)
MidiNoteOff(hDev, vChan, 99 , 127)
return
delete::
loop 40 ; go to master track
{
MidiNoteOn(hDev, vChan, 99, 127)
MidiNoteOff(hDev, vChan, 99 , 127)
}
send {right}{right}{right}
return
lwin & insert::
loop 40 ; first scene
{
MidiNoteOn(hDev, vChan, 96, 127)
MidiNoteOff(hDev, vChan, 96 , 127)
}
return
Lwin & delete::
loop 40 ; last scene
{
MidiNoteOn(hDev, vChan, 97, 127)
MidiNoteOff(hDev, vChan, 97 , 127)
}
return
\:: send !{f9}
#\::
MidiNoteOn(hDev, vChan, 100, 127) ; LAUNCH CLIP
MidiNoteOff(hDev, vChan, 100 , 127)
return
#enter:: ;LAUNCH SCENE
MidiNoteOn(hDev, vChan, 101, 127)
MidiNoteOff(hDev, vChan, 101, 127)
return
}
#Ifwinactive
;==============================
;==============================
DllCall("winmm\midiOutClose", "Ptr",hMIDIOutputDevice, "UInt")
DllCall("kernel32\FreeLibrary", "Ptr",hModule)
;==================================================
MidiNotePlay(hMIDIOutputDevice, vChannel, vNote, vVelocity, vDuration)
{
MidiNoteOn(hMIDIOutputDevice, vChannel, vNote, vVelocity)
Sleep, % vDuration
MidiNoteOff(hMIDIOutputDevice, vChannel, vNote, 0)
}
MidiNoteOn(hMIDIOutputDevice, vChannel, vNote, vVelocity)
{
DllCall("winmm\midiOutShortMsg", "Ptr",hMIDIOutputDevice, "UInt",0x90 | vChannel | (vNote << 8) | (vVelocity << 16), "UInt")
}
MidiNoteOff(hMIDIOutputDevice, vChannel, vNote, vVelocity)
{
DllCall("winmm\midiOutShortMsg", "Ptr",hMIDIOutputDevice, "UInt",0x80 | vChannel | (vNote << 8) | (vVelocity << 16), "UInt")
}
;==================================================
MidiControlChange(hMIDIOutputDevice, Channel, ControlNo, Value)
{
DllCall("winmm\midiOutShortMsg", "UInt", hMIDIOutputDevice, "UInt", 0xB0 | Channel
| (ControlNo << 8) | (Value << 16)) ;"Control Change" event
}
; :: MidiControlChange(hMIDIOutputDevice, vChan, 107, 127) ; PREVIOUS TRACK
; :: MidiControlChange(hMIDIOutputDevice, vChan, 108, 127) ; NEXT TRACK
; :: MidiControlChange(hMIDIOutputDevice, vChan, 109, 127) ;PREVIOUS SCENE
; :: MidiControlChange(hMIDIOutputDevice, vChan, 110, 127) ;NEXT SCENE
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; rctrl up:: send {end}
#ifwinactive, ahk_exe Onenote.exe
^t::
send ^n
return
^!Left:: Send !{Left}
^!right:: send !{right}
LAlt Up:: send {esc}
#ifwinactive
;----------------------------------------------------------------------------------------
#ifwinactive, ahk_class JUCE
^#!c::
winminimize, A
return
#ifwinactive
#ifwinexist, ahk_class JUCE
^#!c:: winmaximize, ahk_class JUCE
#ifwinactive
;----------------------------------------------------------------------------------------
#ifwinactive, ahk_class Ableton Live Window Class
f3::
^!pgdn:: send {f1}
^!pgup:: send {f2}
pgdn:: send {-}
pgup:: send {+}
;[:: send {-}
;]:: send {+}
sc163::
send ^!p
return
;winmaximize A
#ifwinactive
#ifwinactive, ahk_class AbletonVstPlugClass
sc163::
;winminimize, A
send ^!p
return
space::
winhide, A
send {space}
send ^!p
send ^!p
return
#ifwinactive
;#Z::SendInput !{Tab}
;rwin up:: send {win down} 3 {win up}
;--------------------notenote---------------------------------------
#IfWinActive ahk_class ConsoleWindowClass
^V::
SendInput {Raw}%clipboard%
return
#IfWinActive
Rshift & enter::AltTab
Rshift & Lshift::ShiftAltTab
^#J:: click, 918,55
^#K::
send, {tab}
sleep 500
send, {down}{enter}{esc}{esc}
return
^#U::
send, {tab}{tab}
sleep 500
send, {down}{enter}{esc}{esc}
return
^#L:: click, 975,55
^#;:: send ^w
;^#J::
;SendInput,
;(
;
;Business Support Pending
;
;)
;^+up:: sendplay {ctrl down} {shift down} {up} {shift up} {ctrl up}
^+backspace:: sendplay {shiftdown}{home}{shiftup}{backspace}
^+delete:: sendplay {shiftdown}{end}{shiftup}{backspace}
;up:: SendPlay {up}
#up:: send #{up}
!up:: send !{up}
^up:: send ^{up}
+up:: sendplay +{up}
^+up:: sendplay ^+{up}
pgdn & up::
Send {WheelDown}
Sleep, 55
Return
pgup & up::
Send {Wheelup}
Sleep, 55
Return
mbutton:: mbutton
mbutton & j::
Send {Wheelup}
Sleep, 55
Return
mbutton & k::
Send {Wheeldown}
Sleep, 55
Return
#pgup:: send {home}
#pgdn:: send {End}
+^pgup:: send {shiftdown}{home}{shiftup}
+^pgdn:: send {shiftdown}{End}{shiftup}
^#E::
mousegetpos, x, y
click, 1290, 131
mousemove, x, y
return
#^`::
send, ^s
reload
return
ScrollLock::#left
;+PGdn:: Send, {CTRLDOWN}{PGdn}{CTRLUP}
;+PGup:: Send, {CTRLDOWN}{PGup}{CTRLUP}
;---------------------------------------------------------------------------------
rshift & lalt::
send {rshift up}
send {Lalt up}
mousegetpos, x, y
click, 175,300
mousemove, x, y
return
rshift & rctrl:: Send ^w
rshift & ralt:: Send, {CTRLDOWN}{shiftdown}t{shiftup}{CTRLUP}
rshift & printscreen:: Send !{f4}
rshift & left:: send {browser_back}
rshift & right:: send {browser_forward}
rshift & pgup:: send ^{pgup}
rshift & pgdn:: send ^{pgdn}
^pgup:: send ^{pgup}
^pgdn:: send ^{pgdn}
;printscreen:: mouseclick, left,, , up
^printscreen:: run d:\monoff.exe
;lbutton down:: mouseclick, left,,, down
pause:: winclose A
pgdn & pgup:: send {end}
pgup & pgdn:: send {home}
;pgup:: pgup
;pgdn:: pgdn
pgup::
SendPlay {pgup}
return
pgdn::
SendPlay {pgdn}
return
; -----------------------------------------------fn key
#k::
Send {Wheeldown}
Sleep, 55
Return
#j::
Send {Wheelup}
Sleep, 55
Return
;sc163 up:: winmaximize A
#ifwinnotexist ahk_class Chrome_WidgetWin_1
#ifwinexist
^Space:: run C:\Program Files\Everything\everything.exe
; ^+m:: run C:\Program Files (x86)\Microsoft Office\root\Office16\onenote.exe
;-------------------------nonenote
#InstallKeybdHook
#if !(WinActive("ahk_class AbletonVstPlugClass") or WinActive("ahk_class Ableton Live Window Class") or WinActive("ahk_class Ableton Live 10 Suite.exe"))
{
;RButton & LButton::MsgBox You pressed the left mouse button while holding down the right.
LButton::
If KBrecent := A_TimeIdleKeyboard < 400 { ; Keyboard was recently used, so...
KeyWait, LButton, T.4 ; ... check for drag
recentAndHeld := ErrorLevel
} Else recentAndHeld := False
Send % (recentAndHeld || !KBrecent) ? "{LButton Down}" : "" ; Press if drag or no recent KB use
Return
~LButton Up:: ; Release the button
If !recentAndHeld && KBrecent ; Short click & recent keyboard use, so...
SoundBeep, 900, 20 ; ... sound a beep
Return
}
#Ifwinactive
Re: Sticky control or alt key Topic is solved
I do not have a good way to test, but note the following things.
1. To send the routine's hotkey, as in #up:: send #{up}, the hotkey should use the keyboard hook.
2. If both scripts use the keyboard hook, they can conflict with each other and yield unexpected or undesired results. Consider combining the scripts. KeyHistory can inform you about whether the hook is used.
3. One way to debug your scripts is to simplify them: eliminate non-essential routines and loops, shorten the script, and retest.
1. To send the routine's hotkey, as in #up:: send #{up}, the hotkey should use the keyboard hook.
2. If both scripts use the keyboard hook, they can conflict with each other and yield unexpected or undesired results. Consider combining the scripts. KeyHistory can inform you about whether the hook is used.
3. One way to debug your scripts is to simplify them: eliminate non-essential routines and loops, shorten the script, and retest.
Re: Sticky control or alt key
That's what I thought because this is linked with applications you are likely not to have.
Making them one file with a single keyboard hook has done the trick so far.
Thanks a lot.
Making them one file with a single keyboard hook has done the trick so far.
Thanks a lot.
Who is online
Users browsing this forum: dunnerca and 150 guests