How to fix a keyboard error. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

How to fix a keyboard error.

Post by hancre » 24 Mar 2023, 05:01

I've used Capslock as a modifker key.
( a~z, 1~9, key in numpad )

suddenly I got this following message and my ahk file doesn't often work. sometimes it works. )
Note : The hotkey Capslock & will not be active because it does not exisit in the current keyboard layout.
How can I fix the error? ^^

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: How to fix a keyboard error.

Post by mikeyww » 24 Mar 2023, 05:56

Hello,

You can post your script in a new reply below.

RussF
Posts: 1237
Joined: 05 Aug 2021, 06:36

Re: How to fix a keyboard error.

Post by RussF » 24 Mar 2023, 07:04

I see so many people trying to use the CapsLock key as a modifier - something it wasn't really intended for. I can only guess that it is because of its close proximity to the home row of a QWERTY keyboard.

The original IBM type F and early type M keyboards had the Ctrl key next to the A key and CapsLock was down where Ctrl is now. Many people, myself included, typed for years with this arrangement, especially in old applications like Wordstar in which EVERY command utilized the Ctrl key.

When "they" in their infinite wisdom, changed the standard layout, most people - especially touch typists - were completely frustrated because as they were typing copy, they would look up at their screen and realize they had typed an entire paragraph in all caps because they had touched the CapsLock key by mistake.

This gave rise to numerous aftermarket keyboards from companies like NorthGate that had an actual switch and extra keycaps to swap the positions of Ctrl and CapsLock if you so desired. when my NorthGate finally died, the company was out of business by then and I had to find another method.

I found a registry hack (easy to find on the internet) that remaps those two keys at a low level and puts the Ctrl back up next to the A key where, in my opinion, it belongs. Now, even if I accidentally touch that key while typing, it does not affect anything.

While you could do the same thing with AHK, I think the registry hack is much more effective. When you press the (old)Ctrl which is now the CapsLock key, any indicator lights on your keyboard follow the state of that key. Also, on a few occasions, I've had AHK scripts freeze up for no apparent reason or just stop working - forcing a reload. I've never had an issue with the registry hack affecting ANYTHING.

Of course, younger users would have to re-train their typing skills a little, but us old-timers will feel right at home with the Ctrl key back where it belongs. :D

Just my $0.02 worth.

Russ

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to fix a keyboard error.

Post by hancre » 24 Mar 2023, 07:41

mikeyww wrote:
24 Mar 2023, 05:56
Hello,

You can post your script in a new reply below.
Thank you for your reply.
My script is so long ( over 5000 lines )

I'll post codes related to Capslock.

Code: Select all

Capslock::Return

; Case 바꾸기
#InputLevel 1
CapsLock::return ;Capslock 불능(Modify Key로만 작동)

#InputLevel
#If GetKeyState("Capslock","P")
y::
StringLower, Text, Clipboard
Text := RegExReplace(Text, "((?:^|[.!?]\s+)[a-z])", "$u1")
Send %Text%
return

!y::case("U") ; Upper
^y::case("T") ; Title
+y::case("L") ; Lower

#If
case(caseType) {
 Clipboard =
 Send ^c
 ClipWait, 0
 If ErrorLevel
  MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Else  SendInput % "{Text}" (caseType = "S"
                  ? Format("{:U}{:L}"       , Chr(Asc(Clipboard)), SubStr(Clipboard, 2))
                  : Format("{:" caseType "}", Clipboard))
}



$+BS::SetCapsLockState % !GetKeyState("CapsLock", "T") ; c

Capslock & \::   앞에 커서 자르기
5::run https://mall.xinghejishi.com/mall/home/index?alias=3f3&h5path#/pages/loginByRegister/loginByRegister ;쌍디 회원가입
!6::run https://mall.xinghejishi.com/mall/home/index?alias=3f3&h5path#/pages/mine2/m ;쌍디 <我的  내 것>
+!6::run https://mall.xinghejishi.com/mall/home/index?alias=1&h5path   pages/login/login ;쌍디 로그인 

;단락 단위 선택/삭제 (진정한 의미에서 선택, 다른 부분들은 복사한 것임)
^sc027:: Sendinput, {Shift down}{Ctrl down}{up}{Ctrl up}{Shift up} ; Ctrl + Shift + ↑ + (윗 방향으로 원하는 영역 선택)
Capslock & sc027:: Sendinput, {Shift down}{Ctrl down}{up}{Ctrl up}{Shift up}^x ;(윗 방향으로 원하는 영역 선택 후 지우기)
^':: Sendinput, {Shift down}{Ctrl down}{Down}{Ctrl up}{Shift up} ; Ctrl + Shift + ↓ (아랫 방향으로 원하는 영역 선택)
Capslock & ':: Sendinput, {Shift down}{Ctrl down}{Down}{Ctrl up}{Shift up}^x ; Ctrl + Shift + ↓ + Del (아랫 방향으로 원하는 영역 선택 후 지우기)

; 한 단어 선택(복사)/삭제(잘라내기) : Ctrl+화살표로 가능하지만, 손 이동 최소화) - 오른쪽 선택/삭제는 qwer로 해결(커서 위치), appskey는 오류 많이 냄
^~vk15::Sendinput ^+{Left}^c
CapsLock & ~vk15::Sendinput ^+{Left}^x
^~vk19::Sendinput ^+{Right}^c
CapsLock & ~vk19::Sendinput ^+{Right}^x 


Capslock & q::Send {Del} ;지우기(Del)
Capslock & w::Send ^{Left}^+{Right}^x ;자르기
Capslock & e::Send ^{Left}^+{Right}^c ; 복사
Capslock & r::Send ^{Left}^+{Right}^v ;대체
Capslock & t::Send ^{Left}^+{Right}^b ;굵은 글씨
;Capslock & t:: Send {Ins} ;삽입(Insert) Send, {Insert} 안 됨



Capslock & z::Sendinput {Home}{Shift Down}{End}{Shift Up}^x{Del}{End} ;{BackSpace}{End} ;지우고 위로 올라가기
Capslock & x::Sendinput {Home}{Shift Down}{End}{Shift Up}^x ;잘라내기(삭제하고, 그 자리에 머무름)
Capslock & c::Sendinput {Home}{Shift Down}{End}{Shift Up}^c ;전체 복사
Capslock & v::Sendinput {Home}{Shift Down}{End}{Shift Up}^v ;클립보드로 대체
Capslock & b::Sendinput {Home}{Shift Down}{End}{Shift Up}^b ;굵은 글씨로 쓰기

; Capslock + jkil (left, down, up, right) 화살표로 이동
CapsLock & j:: Sendinput {Left} 	; CapsLock + j : 왼쪽 화살표
CapsLock & l:: Sendinput {Right} 	; CapsLock + l : 오른쪽 화살표
CapsLock & i:: Sendinput {Up} 	; CapsLock + i : 위 화살표
CapsLock & k:: Sendinput {Down} ; CapsLock + k : 아래 화살표

CapsLock & y:: Sendinput {PgUp} 
CapsLock & u:: Sendinput {PgDn}
CapsLock & o:: Sendinput {Home} ; CapsLock + o : Home 버튼
CapsLock & p:: Sendinput {End}	; CapsLock + p : End 버튼

;커서 기준 복사/삭제
^[:: Sendinput, {Shift down}{Home}{Shift up}^c ;커서 기준 왼쪽 선택 (대가리 선택)
Capslock & [:: Sendinput, {Shift down}{Home}{Shift up}^x ;커서 기준 왼쪽(대가리 짜르기)
^]:: Sendinput, {Shift down}{end}{Shift up}^c  ;커서 기준 오른쪽 선택 (꼬리 선택)
Capslock & ]::Sendinput, {Shift down}{end}{Shift up}^x ;커서 기준 오른쪽(꼬리 자르기)


;단락 단위 선택/삭제 (진정한 의미에서 선택, 다른 부분들은 복사한 것임)
^sc027:: Sendinput, {Shift down}{Ctrl down}{up}{Ctrl up}{Shift up} ; Ctrl + Shift + ↑ + (윗 방향으로 원하는 영역 선택)
Capslock & sc027:: Sendinput, {Shift down}{Ctrl down}{up}{Ctrl up}{Shift up}^x ;(윗 방향으로 원하는 영역 선택 후 지우기)
^':: Sendinput, {Shift down}{Ctrl down}{Down}{Ctrl up}{Shift up} ; Ctrl + Shift + ↓ (아랫 방향으로 원하는 영역 선택)
Capslock & ':: Sendinput, {Shift down}{Ctrl down}{Down}{Ctrl up}{Shift up}^x ; Ctrl + Shift + ↓ + Del (아랫 방향으로 원하는 영역 선택 후 지우기)

;3단어 선택(복사)/삭제(잘라내기)
^,::Sendinput ^+{Left 3}^c ;왼쪽 3단어 선택
Capslock & ,::Sendinput ^+{Left 3}^x ;왼쪽 3단어 지우기
^.::Sendinput ^+{Right 3}^c ;오른쪽 3단어 선택
Capslock & .::Sendinput ^+{Right 3}^x  ;오른쪽 3단어 선택 지우기


Capslock & sc052::  ;영화 정보검색 Capslock & Numpad0
InputBox, SearchTerm, 영화정보 검색
if (SearchTerm <> "") {
   Run https://movie.naver.com/movie/search/result.naver?query=%SearchTerm%&section=all&ie=utf8
   Run http://www.imdb.com/find?q=%SearchTerm%&s=tt ; opens the IMDB search results in your default browser
}
Return


#if GetKeyState("Ctrl", "P")
   Capslock & sc052::
       Clipboard :=""
       Sleep 50
       SendInput,^c
       Sleep 50
       Run https://movie.naver.com/movie/search/result.naver?query=%Clipboard%&section=all&ie=utf8
       Run https://www.imdb.com/find?s=tt&q=%Clipboard%&ref_=nv_sr_sm
Return
#If

#if GetKeyState("Shift", "P")
   Capslock & sc052::
        Run https://www.koreafilm.or.kr/cinematheque/schedule
        Run https://lib.sen.go.kr/lib/board/index.do?menu_idx=12&manage_idx=1121
    Return
#If




Capslock & sc050:: ;엄마 일처리 (SC050 - numpad2)
;run https://www.evernote.com/shard/s55/nl/5798446/5b244ede-624c-1d21-f312-879435e3d44f?title=%EC%97%84%EB%A7%88%20%EC%97%85%EB%AC%B4%20%EA%B4%80%EB%A6%AC
run https://docs.google.com/spreadsheets/d/1BoIXwK8d-EDGREC2Srlnc5P4U85pe90OqdKrY2uKcF8/edit#gid=0
;run https://crowd1.com/login
;run https://healysg.globalewallet.com/MemberLogin.aspx
;send {capslock up}
return


#if GetKeyState("Shift", "P")
  CapsLock & sc50:: ;numpad2
run https://vein-x.com/admin
sleep 4000
Send {tab}
Sendinput ksi5115 `t
Sleep 4000
Sendinput ksi5115@ `n
Sleep 4000
run https://vein-x.com/admin/org_chartp_box.asp
return
#If



Capslock & sc051:: ;도서관 (sc051-numpad3)
run https:://lib.sungshin.ac.kr
run https://www.sblib.seoul.kr/library/index.do
run https://lib.sen.go.kr/lib/index.do?getContextPath=
return

;출판유통업체 모음 Capslock & 4::6
Capslock & SC04C:: ;오토핫키 (sc04C-numpad5)
;run https://docs.google.com/spreadsheets/d/1bJ005wNFTY3CA1r--b7dZFDNJVmP8kBgqc346Lqnbjk/edit#gid=0 ;ahk code 모음
run https://cafe.naver.com/ca-fe/cafes/26085981/members?memberId=pumki
run https://www.reddit.com/user/Sophie0315/posts/
run https://www.autohotkey.com/boards/search.php?search_id=egosearch
send {capslock up}
return



Capslock & sc04d:: ; Capslock & Numpad6 수학 문제 
run https://www.edunet.net/nedu/contsvc/subjectForm.do?menu_id=2  ;에듀넷 
run https://www.11math.com/calc#44F2F165 ;일일수학1 
run https://calcproject.tistory.com/ ;학습지 제작소
Sleep 5500 
Mousemove, 1250, 487
;mouseclick, left, 1250, 487 
Return 




Capslock & sc047:: ; sc047 Numpad7  (고37 수업)
;run C:\Users\\AppData\Roaming\Zoom\bin\Zoom.exe
run C:\ing\야학\상록영어고등단어최종_20211115_다의어포함62run_고1수업용.docx
run https://docs.google.com/document/d/1_iaAzGd67DYK8F5
run https://us02web.zoom.us/j/3470281143?pwd=UjVNREhse
runwait C:\Program Files (x86)\Kakao\KakaoTalk\KakaoTalk.exe
Winactivate, ahk_exe KakaoTalk.exe
CoordMode, Mouse, relative
Sleep 500
mouseclick, left, 35, 65 ; (35, 65)
sleep, 500
Send ^f
sleep, 250
Sendinput {Home}{Shift Down}{End}{Shift Up}^x{End}
sleep, 50
Clipboard := "상록 고3/37회 교사/학생방"
send ^v
sleep, 50
Send {Enter} ;
sleep, 500
Return



#if GetKeyState("Shift", "P")
  CapsLock & :: ;고37회 zoom 열기
Run https://band.us/band/85111111 ;고37
Run https://zoom.us/signin#the-main-content
Sleep 5500
Sendinput [email protected] `t
Sleep 4200
Sendinput T******** `n
Sleep 30007
;Run C:\Users\\Documents\Zoom
Run https://docs.google.com/spreadsheets/d/1r9BvHY6t#gid=0 ;출석부
;Run https://us02web.zoom.us/account/report/reportedparticipants
Run https://us02web.zoom.us/account/report/user ; Reports - Usage Reports - Active Hosts
Run https://us02web.zoom.us/recording/
ToolTip % "업로드 먼저, 출석체크는 나중에!", 250, 500
	Sleep 5000
	ToolTip
send {capslock up}
Return
#If

;Capslock & 8::run https://www.fiverr.com/inbox/shezan_bai


Capslock & sc049:: ;sc049 Numpad9
run C:\Program Files (x86)\Kakao\KakaoTalk\KakaoTalk.exe
Sleep 2000
Winactivate, ahk_exe KakaoTalk.exe
;CoordMode, Mouse, relative
Sleep 500
Open_Kakaochat("상록 고3/37")
Sleep 1500
;Run C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Google Drive.lnk,, Hide
run C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Prefs LAYOUT="image"
run https://docs.google.com/document/d/1_iaAzGd67DYK8F5E8uKfDsdR0XKOuw8lPy-L6l9wVZw/edit ;상록 일일 영단어
run C:\ing\야학\상록영어고등단어최종_20211115_다의어포함62run_고1수업용.docx, , Max ; UseErrorLevel
Run C:\ing\야학\상록고등영어_종합_파닉스표상함_단어수정용.docx, , Max ; UseErrorLevel
Run C:\ing\야학\상록-검정고등-독해-20220905.docx
Return

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: How to fix a keyboard error.

Post by mikeyww » 24 Mar 2023, 20:03

When you run the exact script that you posted, what error message is displayed?

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to fix a keyboard error.

Post by hancre » 24 Mar 2023, 21:02

mikeyww wrote:
24 Mar 2023, 20:03
When you run the exact script that you posted, what error message is displayed?
The following error message appears.
Note : The hotkey Capslock & will not be active because it does not exisit in the current keyboard layout.
sometimes my ahk file runs well.
But suddenly the message appears again.
It's annoying me.

Sometimes my ahk file doesn't well.
At that time, I solve the problem trying to run the file again and again. ( sometimes I can't use my ahk file despite my trial. )

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: How to fix a keyboard error.

Post by mikeyww » 24 Mar 2023, 21:14

Strange. I am not seeing that. I see a different message, as your script clearly shows duplicate hotkeys in the first five lines. My conclusion is that you are running a script other than the one that you have posted. Since I am unable to replicate your finding, I will let others respond here.

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to fix a keyboard error.

Post by hancre » 24 Mar 2023, 21:57

mikeyww wrote:
24 Mar 2023, 21:14
I'm sorry to make you confused again.
I added script with 'Capslock &' twice by mistake.

My main script is so long to upload it in this forum.
I've used the script over 1 year well. ( There're lots of combination of Capslock.

I have a question.

What's the difference betweeb SC and Vk?
If VK code is more stable than SC code, I'll apply vk it to the combination of Capslock and others.

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: How to fix a keyboard error.

Post by mikeyww » 25 Mar 2023, 06:20

Some general information here.

Others know more about the key systems, but my simplistic understanding is that the keyboard usually sends one or more numbers to the computer when a key is pressed. This is the scan code. In addition, Windows defines a virtual key code for a larger set of "keys" (also mouse button presses) that the user can trigger. This may include some keys or buttons that do not generate scan codes, hence the term "virtual keys".

https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes/

When you have a custom combination with a null suffix key, you will generate the error message that you initially mentioned.

Code: Select all

CapsLock & ::MsgBox 123
A simple search of your script will actually find this exact hotkey on line 207.

Other bugs:

Line 5: Duplicate hotkey
Line 35: Plain text after your hotkey definition
Line 87: duplicate hotkey
Line 88: duplicate hotkey
Line 89: duplicate hotkey
Line 90: duplicate hotkey
Line 236: function not defined

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to fix a keyboard error.  Topic is solved

Post by hancre » 26 Mar 2023, 06:30

mikeyww wrote:
25 Mar 2023, 06:20
I found I had removed a number after 'Capslock &' by mistake.

There're comment area in my script with /* and */.
When I get the codes for Capslock and others, I put them to the codes I posted in this forum.

I'm so sorry to make you confused again. @.@
I should have took care of my scripts.

hancre
Posts: 241
Joined: 02 Jul 2021, 20:51

Re: How to fix a keyboard error.

Post by hancre » 26 Mar 2023, 06:35

RussF wrote:
24 Mar 2023, 07:04

My mistake caused the error at this time.
But I'll think about your advice.

Thank you for your reply ^^

Post Reply

Return to “Ask for Help (v1)”