topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday December 7, 2021, 1:03 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Skommel's CapShift not working in Chrome  (Read 157 times)

kunkel321

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 557
    • View Profile
    • Donate to Member
Skommel's CapShift not working in Chrome
« on: November 19, 2021, 11:06 AM »
This is Skommel's excellent CapShift "one hour software."
https://www.dcmembers.com/skrommel/download/capshift/

He has the ahk file in his download, but below is a version with a bunch of MsgBox debug stops that I put.   I'm trying to figure out why it doesn't work in Chrome browser edit fields.  Works fine in Notepad.  I'm trying to use the conver-to-UPPER CASE feature from the popup.  In Chrome the text doesn't get converted.... CapShift merely pastes whatever is on the clipboard.  It seems there's a hickup at line 274 (Send, ^C).   The hickup is not consistent though... Sometimes the selected text does get copied to the clipboard, but the app still fails. 

Thoughts?  I just poseted this at the AutoHotkey forum too.

Code: Autohotkey [Select]
  1. ;CAPshift.ahk
  2. ;Slows down and extends the CapsLock key.
  3. ; Also slows down F1, Insert, NumLock and ScrollLock
  4. ;
  5. ;Hold for 0.5 sec to toggle caps lock on or off.
  6. ;Hold for 1 sec to show a menu that converts selected text to
  7. ; UPPER CASE, lower case, Title Case or iNVERT cASE.
  8. ;
  9. ;If the keyboard is idle for 120 seconds, CapsLock is turned off.
  10. ;
  11. ;Skrommel @2005
  12.  
  13.  
  14. applicationname=CAPshift
  15.  
  16. Gosub,READINI
  17. Gosub,TRAYMENU
  18.  
  19. WinGet,oldid,ID,A
  20.  
  21. SetTimer,ACTIVEWIN,500
  22.  
  23. {
  24.   Input,key,L1 T1 V,{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
  25.   If (ErrorLevel<>"Timeout")
  26.     time:=A_TickCount
  27.   If (A_TickCount-time>=capslockidle*1000)
  28.   {
  29.     If capslockidle>0
  30.     If (GetKeyState("CapsLock","T"))
  31.       SetCapsLockState,Off
  32.     time:=A_TickCount
  33.   }
  34. }
  35. Return
  36.  
  37.  
  38. ACTIVEWIN:
  39. WinGet,id,ID,A
  40. WinGetClass,class,ahk_id %id%
  41. If id=
  42.   id=%oldid%
  43. If class=Shell_TrayWnd
  44.   id=%oldid%
  45. If id=AutoHotkey
  46.   id=%oldid%
  47. oldid=%id%
  48. Return
  49.  
  50.  
  51. DELAY:
  52. hotkey=%A_ThisHotkey%
  53. If hotkey=CapsLock
  54.   Gosub,CAPSLOCK
  55. Else
  56.   Gosub,THEREST
  57. Return
  58.  
  59.  
  60. THEREST:
  61. counter=500
  62. {
  63.   If showstatus=1
  64.     ToolTip,%hotkey% in %counter% ms
  65.   Sleep,100
  66.   counter-=100
  67.   GetKeyState,state,%hotkey%,P
  68.   If state=U
  69.     Break
  70. }
  71. If showstatus=1
  72. If counter=0
  73. If hotkey=F1
  74.   Send,{%hotkey%}
  75. Else
  76. {
  77.   GetKeyState,state,%hotkey%,T
  78.   If state=U
  79.   {
  80.     If hotkey=NumLock
  81.       SetNumLockState,On
  82.     If hotkey=ScrollLock
  83.       SetScrollLockState,On
  84.     If hotkey=Insert
  85.       Send,{%hotkey%}
  86.     If showstatus=1
  87.       ToolTip,%hotkey% On
  88.   }
  89.   Else
  90.   {
  91.     If hotkey=NumLock
  92.       SetNumLockState,Off
  93.     If hotkey=ScrollLock
  94.       SetScrollLockState,Off
  95.     If hotkey=Insert
  96.       Send,{%hotkey%}
  97.     If showstatus=1
  98.       ToolTip,%hotkey% Off
  99.   }
  100.   SetTimer,TOOLTIPOFF,On
  101. }
  102. KeyWait,%hotkey%
  103. Return
  104.  
  105.  
  106. CAPSLOCK:
  107. counter=1000
  108. Loop,10
  109. {
  110.   If showstatus=1
  111.     ToolTip,%hotkey% in %counter% ms
  112.   Sleep,100
  113.   counter-=100
  114.   If counter=500
  115.     SoundPlay,%SYSTEMROOT%\Media\ding.wav
  116.   GetKeyState,state,%hotkey%,P
  117.   If state=U
  118.     Break
  119. }
  120. If showstatus=1
  121. If counter=0
  122. Else
  123. If counter<600
  124. {
  125.   GetKeyState,state,%hotkey%,T
  126.   If state=D
  127.     Gosub,OFF
  128.   Else
  129.     Gosub,ON
  130. }
  131. Return
  132.  
  133.  
  134. status=
  135. key=Insert
  136. Gosub,GETSTATE
  137. key=CapsLock
  138. Gosub,GETSTATE
  139. key=NumLock
  140. Gosub,GETSTATE
  141. key=ScrollLock
  142. Gosub,GETSTATE
  143. If showstatus=1
  144.   TrayTip,Status,%status%,10
  145. Return
  146.  
  147.  
  148. GETSTATE:
  149. GetKeyState,state,%key%,T
  150. If state=D
  151.   status=%status%%key%`n
  152. Return
  153.  
  154.  
  155. Menu,convert,Add
  156. Menu,convert,Delete
  157. Menu,convert,Add,CAPshift,TOGGLE
  158. Menu,convert,Add,
  159. Menu,Convert,Add,CapsLock &On,On
  160. Menu,Convert,Add,&CapsLock Off,Off
  161. Menu,convert,Add,
  162. Menu,convert,Add,&UPPER CASE,UPPER
  163. Menu,convert,Add,&lower case,LOWER
  164. Menu,convert,Add,&Title Case,TITLE
  165. Menu,convert,Add,&iNVERT cASE,INVERT
  166. Menu,convert,Add,&RaNDoM CaSE,RANDOM
  167. Menu,convert,Add,Replace user &chars,REPLACE
  168. Menu,convert,Add,
  169. Menu,convert,Add,&Settings...,SETTINGS
  170. Menu,convert,Add,&About...,ABOUT
  171. Menu,convert,Add,E&xit,EXIT
  172. Menu,convert,Default,CapShift
  173. Menu,convert,Show
  174. Return
  175.  
  176.  
  177. TRAYMENU:
  178. Menu,Tray,NoStandard
  179. Menu,Tray,DeleteAll
  180. Menu,Tray,Add,CAPshift,TOGGLE
  181. Menu,Tray,Add,
  182. Menu,Tray,Add,CapsLock &On,On
  183. Menu,Tray,Add,&CapsLock Off,Off
  184. Menu,Tray,Add,
  185. Menu,Tray,Add,&UPPER CASE,UPPER
  186. Menu,Tray,Add,&lower case,LOWER
  187. Menu,Tray,Add,&Title Case,TITLE
  188. Menu,Tray,Add,&iNVERT cASE,INVERT
  189. Menu,Tray,Add,&RaNDoM CaSE,RANDOM
  190. Menu,Tray,Add,Replace user &chars,REPLACE
  191. Menu,Tray,Add,
  192. Menu,Tray,Add,&Settings...,SETTINGS
  193. Menu,Tray,Add,&About...,ABOUT
  194. Menu,Tray,Add,E&xit,EXIT
  195. Menu,Tray,Default,CapShift
  196. Menu,Tray,Tip,%applicationname%
  197. Return
  198.  
  199.  
  200. TOOLTIPON:
  201. Return
  202.  
  203.  
  204. TOOLTIPOFF:
  205. If showstatus=1
  206. SetTimer,TOOLTIPOFF,Off
  207. Return
  208.  
  209.  
  210. ON:
  211. If showstatus=1
  212.   ToolTip,CapsLock On
  213. SetTimer,TOOLTIPOFF,On
  214. Return
  215.  
  216.  
  217. OFF:
  218. If showstatus=1
  219.   ToolTip,CapsLock Off
  220. SetTimer,TOOLTIPOFF,On
  221. Return
  222.  
  223.  
  224. TOGGLE:
  225. GetKeyState,state,CapsLock,T
  226. If state=D
  227. {
  228.   If showstatus=1
  229.     ToolTip,CapsLock Off
  230. }
  231. Else
  232. {
  233.   If showstatus=1
  234.     ToolTip,CapsLock On
  235. }
  236. SetTimer,TOOLTIPOFF,On
  237. Return
  238.  
  239.  
  240. CUT:
  241. oldclipboard:=ClipboardAll
  242.  
  243. MsgBox clp just saved to oldClp which is %oldClipboard%  ;####################################debug
  244.  
  245. WinActivate,ahk_id %id%
  246. WinWaitActive,ahk_id %id%,,1
  247. WinGetClass,class,ahk_id %id%
  248. If class In Progman,WorkerW,Explorer,CabinetWClass
  249.   Send,{F2}
  250. Sleep,500
  251. Send,^c
  252. string=%clipboard%
  253.  
  254. msgbox bottom of CUT sub`nstr is %string%  ;####################################debug
  255.  
  256. Return
  257.  
  258.  
  259. PASTE:
  260. WinActivate,ahk_id %id%
  261. WinWaitActive,ahk_id %id%,,1
  262.  
  263. MsgBox now at paste sub and str is %string% ;####################################debug
  264.  
  265. If class In Progman,WorkerW,Explorer,CabinetWClass
  266.   Send,{F2}
  267. clipboard=%string%
  268.  
  269. MsgBox just before send`nclipbrd is %Clipboard%`noldClipbrd %oldclipboard% ;####################################debug
  270.  
  271. Send,^v
  272. Clipboard:=oldclipboard
  273. oldclipboard=
  274. Return
  275.  
  276.  
  277. UPPER:
  278.  
  279. MsgBox top of upper sub  ;####################################debug
  280.  
  281. Gosub,CUT
  282.  
  283. MsgBox before stringUpper str is %string% ;####################################debug
  284.  
  285. StringUpper,string,string
  286.  
  287. MsgBox after stringUpper str is %string%  ;####################################debug
  288.  
  289. Gosub,PASTE
  290. If showstatus=1
  291.   ToolTip,Selection converted to UPPER CASE
  292. SetTimer,TOOLTIPOFF,On
  293. Return
  294.  
  295.  
  296. LOWER:
  297. Gosub,CUT
  298. StringLower,string,string
  299. Gosub,PASTE
  300. If showstatus=1
  301.   ToolTip,Selection converted to lower case
  302. SetTimer,TOOLTIPOFF,On
  303. Return
  304.  
  305.  
  306. TITLE:
  307. Gosub,CUT
  308. StringLower,string,string,T
  309. Gosub,PASTE
  310. If showstatus=1
  311.   ToolTip,Selection converted to Title Case
  312. SetTimer,TOOLTIPOFF,On
  313. Return
  314.  
  315.  
  316. INVERT:
  317. Gosub,CUT
  318. StringLen,length,string
  319. Loop,%length%
  320. {
  321.   StringLeft,char,string,1
  322.   If char Is Upper
  323.     StringLower,char,char
  324.   Else
  325.   If char Is Lower
  326.     StringUpper,char,char
  327.   StringTrimLeft,string,string,1
  328.   string=%string%%char%
  329. }
  330. If showstatus=1
  331.   ToolTip,Selection converted to iNVERTED cASE
  332. SetTimer,TOOLTIPOFF,On
  333. Gosub,PASTE
  334. Return
  335.  
  336.  
  337. Gosub,CUT
  338. StringLen,length,string
  339. Loop,%length%
  340. {
  341.   StringLeft,char,string,1
  342.   Random,random,1,2
  343.   If random=1
  344.     StringLower,char,char
  345.   Else
  346.     StringUpper,char,char
  347.   StringTrimLeft,string,string,1
  348.   string=%string%%char%
  349. }
  350. If showstatus=1
  351.   ToolTip,Selection converted to RaNDoM CaSE
  352. SetTimer,TOOLTIPOFF,On
  353. Gosub,PASTE
  354. Return
  355.  
  356.  
  357. REPLACE:
  358. Gosub,CUT
  359. Loop,%swapcount%
  360. {
  361.   from:=swap_%A_Index%_1
  362.   to:=swap_%A_Index%_2
  363.   StringReplace,string,string,%A_Space%,.space.,All
  364.   StringReplace,string,string,%A_Tab%,.tab.,All
  365.   StringReplace,string,string,`r,.return.,All
  366.   StringReplace,string,string,`n,.newline.,All
  367.   StringReplace,string,string,`,,.comma.,All
  368.   StringReplace,string,string,`;,.semicolon.,All
  369.   StringReplace,string,string,%from%,%to%,All
  370.   StringReplace,string,string,.space.,%A_Space%,All
  371.   StringReplace,string,string,.tab.,%A_Tab%,All
  372.   StringReplace,string,string,.return.,`r,All
  373.   StringReplace,string,string,.newline.,`n,All
  374.   StringReplace,string,string,.comma.,`,,All
  375.   StringReplace,string,string,.semicolon.,`;,All
  376. }
  377. If showstatus=1
  378.   ToolTip,Selection's User chars replaced
  379. SetTimer,TOOLTIPOFF,On
  380. Gosub,PASTE
  381. Return
  382.  
  383.  
  384. ABOUT:
  385. Gui,99:Margin,20,20
  386. Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
  387. Gui,99:Font,Bold
  388. Gui,99:Add,Text,x+10 yp+10,%applicationname% v1.7
  389. Gui,99:Add,Text,y+10,CAPshift slows down and extends the CapsLock key.
  390. Gui,99:Add,Text,y+5,It also slows down F1, Insert, NumLock and ScrollLock.
  391. Gui,99:Add,Text,y+10,- Hold down CapsLock for .5 sec to toggle CapsLock on or off.
  392. Gui,99:Add,Text,y+10,- Hold for 1 sec to show a menu that converts selected text to
  393. Gui,99:Add,Text,y+5,UPPER CASE, lower case, Title Case, iNVERT cASE, RaNDoM CaSE  
  394. Gui,99:Add,Text,y+5,or to Replace user defined chars as defined in CAPshift.ini.
  395. Gui,99:Add,Text,y+10,- If the keyboard is idle for 120 seconds, CapsLock is turned off.
  396.  
  397. Gui,99:Add,Picture,xm y+20 Icon5,%applicationname%.exe
  398. Gui,99:Font,Bold
  399. Gui,99:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
  400. Gui,99:Add,Text,y+10,For more tools, information and donations, please visit
  401. Gui,99:Font,CBlue Underline
  402. Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
  403.  
  404. Gui,99:Add,Picture,xm y+20 Icon7,%applicationname%.exe
  405. Gui,99:Font,Bold
  406. Gui,99:Add,Text,x+10 yp+10,DonationCoder
  407. Gui,99:Add,Text,y+10,Please support the contributors at
  408. Gui,99:Font,CBlue Underline
  409. Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
  410.  
  411. Gui,99:Add,Picture,xm y+20 Icon6,%applicationname%.exe
  412. Gui,99:Font,Bold
  413. Gui,99:Add,Text,x+10 yp+10,AutoHotkey
  414. Gui,99:Add,Text,y+10,This tool was made using the powerful
  415. Gui,99:Font,CBlue Underline
  416. Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
  417.  
  418. Gui,99:Show,,%applicationname% About
  419. hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
  420. OnMessage(0x200,"WM_MOUSEMOVE")
  421. Return
  422.  
  423. 1HOURSOFTWARE:
  424.  Run,http://www.1hoursoftware.com,,UseErrorLevel
  425. Return
  426.  
  427. DONATIONCODER:
  428.  Run,http://www.donationcoder.com,,UseErrorLevel
  429. Return
  430.  
  431. AUTOHOTKEY:
  432.  Run,http://www.autohotkey.com,,UseErrorLevel
  433. Return
  434.  
  435. 99GuiClose:
  436.  Gui,99:Destroy
  437.   OnMessage(0x200,"")
  438.   DllCall("DestroyCursor","Uint",hCur)
  439. Return
  440.  
  441. WM_MOUSEMOVE(wParam,lParam)
  442. {
  443.   Global hCurs
  444.   MouseGetPos,,,,ctrl
  445.   If ctrl in Static13,Static17,Static21
  446.     DllCall("SetCursor","UInt",hCurs)
  447.   Return
  448. }
  449. Return
  450.  
  451.  
  452.  
  453.  
  454. SETTINGS:
  455. Gosub,READINI
  456. Run,CAPshift.ini
  457. Return
  458.  
  459.  
  460. READINI:
  461. IfNotExist,CAPshift.ini
  462. {
  463.   inifile=;CAPshift.ini
  464.   inifile=%inifile%`n`;[Settings]
  465.   inifile=%inifile%`n`;capslockidle=120    `;0-999  0=Off  Seconds to wait before turning off CapsLock when the keyboard is idle
  466.   inifile=%inifile%`n`;showstatus=1        `;0,1    0=Hide  1=Show  Hide or show the status windows
  467.   inifile=%inifile%`n`;delaycapslock=1     `;0,1    0=Ignore CapsLock  1=Delay F1
  468.   inifile=%inifile%`n`;delayf1=1           `;0,1    0=Ignore F1  1=Delay F1
  469.   inifile=%inifile%`n`;delayinsert=1
  470.   inifile=%inifile%`n`;delayscrolllock=1
  471.   inifile=%inifile%`n`;delaynumlock=1
  472.   inifile=%inifile%`n`;
  473.   inifile=%inifile%`n`;ae=æ                `;Chars to replace=Chars to replace with
  474.   inifile=%inifile%`n`;oe=ø                `;Special characters:
  475.   inifile=%inifile%`n`;aa=å                `;  .space. .tab. .return. .newline. .comma. .semicolon.
  476.   inifile=%inifile%`n`;AE=Æ
  477.   inifile=%inifile%`n`;OE=Ø
  478.   inifile=%inifile%`n`;AA=Å
  479.   inifile=%inifile%`n`;AA=Å
  480.   inifile=%inifile%`n`;.return..newline..return..newline.=  ;Removes empty lines
  481.   inifile=%inifile%`n
  482.   inifile=%inifile%`n[Settings]
  483.   inifile=%inifile%`ncapslockidle=120
  484.   inifile=%inifile%`nshowstatus=1
  485.   inifile=%inifile%`ndelaycapslock=1
  486.   inifile=%inifile%`ndelayf1=1
  487.   inifile=%inifile%`ndelayinsert=1
  488.   inifile=%inifile%`ndelayscrolllock=1
  489.   inifile=%inifile%`ndelaynumlock=1
  490.   inifile=%inifile%`n
  491.   inifile=%inifile%`nae=æ
  492.   inifile=%inifile%`noe=ø
  493.   inifile=%inifile%`naa=å
  494.   inifile=%inifile%`nAE=Æ
  495.   inifile=%inifile%`nOE=Ø
  496.   inifile=%inifile%`nAA=Å
  497.   FileAppend,%inifile%,CAPshift.ini
  498.   inifile=
  499. }
  500. IniRead,capslockidle,CAPshift.ini,Settings,capslockidle
  501. IniRead,showstatus,CAPshift.ini,Settings,showstatus
  502. IniRead,delaycapslock,CAPshift.ini,Settings,delaycapslock
  503. IniRead,delayf1,CAPshift.ini,Settings,delayf1
  504. IniRead,delayinsert,CAPshift.ini,Settings,delayinsert
  505. IniRead,delayscrolllock,CAPshift.ini,Settings,delayscrolllock
  506. IniRead,delaynumlock,CAPshift.ini,Settings,delaynumlock
  507.  
  508. If delaycapslock=1
  509.   Hotkey,$CapsLock,DELAY
  510. If delayf1=1
  511.   Hotkey,$F1,DELAY
  512. If delayinsert=1
  513.   Hotkey,$Insert,DELAY
  514. If delaynumlock=1
  515.   Hotkey,$NumLock,DELAY
  516. If delayscrolllock=1
  517.   Hotkey,$ScrollLock,DELAY
  518.  
  519. swapcount=0
  520. Loop,Read,CAPshift.ini
  521. {
  522.   If char=`;
  523.     Continue
  524.     Continue
  525.   If A_LoopReadLine Contains capslockidle=,showstatus=,delaycapslock=,delayf1=,delayinsert=,delayscrolllock=,delaynumlock=
  526.     Continue
  527.     Continue
  528.   swapcount+=1
  529.   StringSplit,swap_%swapcount%_,A_LoopReadLine,=
  530. }
  531. Return
« Last Edit: November 19, 2021, 05:38 PM by kunkel321 »