Advertisement
mgis90

ExcelLabels.ahk

Jan 29th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Excel Labels - hotkeys                             2016-02-01
  2. ;adds bookmark functionality in Notepad2 style
  3. ;requires ExcelGetCell() function to be accessible in Local Library
  4. ;------------------------------------------------------------------
  5. ;Ctrl+F1    ustaw zakładkę                    [set]
  6. ;F1         idź do następnej zakładki        [go next]
  7. ;Shift+F1   idź do poprzedniej zakładki       [go prev]
  8. ;----------------------------------------------------
  9. ;Select Load Settings from tray to LOAD
  10. ;Reload the script to RESET
  11. ;Reload twice to delete history
  12. ;--------------------------------------
  13. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  14. #LTrim  ; Allows continuation sections to be indented. Positional. May be turned off via #LTrim Off
  15. #KeyHistory 0  ; Disable keyboard and mouse event history.
  16. #SingleInstance force
  17. #Warn   ;requires ahk_L
  18. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  19. Menu,tray,icon,C:\PATHTOYOUREXCEL\Microsoft Office\Office12\EXCEL.EXE,4
  20. Menu,tray,add
  21. Menu,tray,add,Load Settings,LoadSettings
  22. Menu,tray,add,Display,display
  23. StringTrimRight,file_ini,A_ScriptFullPath,3
  24. file_ini.="ini"
  25. list:=Array()
  26. i=0
  27. ;Gosub,LoadSettings     ;uncomment this to always load previous settings on startup
  28. OnExit,ExitSub
  29. return  ;autoexec
  30.  
  31.  
  32. GoThere:
  33. cell:=list[i]
  34. Send ^g
  35. ;this next line must be sendraw because of "!"
  36. SendRaw, % cell
  37. Send {ENTER}
  38. return
  39.  
  40. ExitSub:
  41. FileDelete,%file_ini%
  42. s=
  43. Loop, % list.MaxIndex()
  44.     s.=list[A_Index] . "`n"
  45. if StrLen(s)>4
  46.     FileAppend,%s%,%file_ini%
  47. ExitApp
  48. return
  49.  
  50. LoadSettings:
  51. Loop, Read, %file_ini%
  52.     if StrLen(A_LoopReadLine)>=2
  53.         list.Insert(A_LoopReadLine)
  54. return
  55.  
  56. display:                        ;[display]
  57. s=
  58. Loop, % list.MaxIndex()
  59.     s.=list[A_Index] . "`n"
  60. MsgBox, % s
  61. return
  62.  
  63. #IfWinActive Microsoft Excel ahk_class XLMAIN
  64. F1::
  65. ;następna zakładka            [next]
  66. i++
  67. if (i>list.MaxIndex())
  68.     i:=list.MinIndex()
  69. GoSub,GoThere
  70. return
  71.  
  72. +F1::
  73. ;poprzednia zakładka       [prev]
  74. i--
  75. if (i<list.MinIndex())
  76.     i:=list.MaxIndex()
  77. GoSub,GoThere
  78. return
  79.  
  80.  
  81. ^F1::
  82. ;ustaw zakładkę               [set]
  83. cell:=ExcelGetCell()
  84. ;dbg        InputBox,cell,,edit cell,,,,,,,,%cell%
  85. if cell
  86. {
  87.     list.Insert(cell)
  88.     TrayTip,Dodano zakładkę, % "[" . list.MaxIndex() . "]`t" . cell       ;bookmark added
  89. } else {
  90.     TrayTip,%A_ScriptName%,Nie znaleziono pozycji                       ;position not found
  91. }
  92. SetTimer,cls,-5000
  93. return
  94.  
  95. cls:
  96. TrayTip
  97. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement