Update WIP.ahk

Update WIP.ahk

;In the Header we define declares which need to be added to the Header of the script (or to the .def files if they exist)
Header =
(
Declare Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
Declare Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt 'as long
Declare Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
)

;In the footer we define the inner workings of the functions/subroutines declared in header
Footer =
(
'~~~~~~~~~~~~~~~~~~~~~~~~~~ GENERATED BY EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
	Dim strArr() As String

	'get array of character pairs		'splitStringToArray sub-routine ported to MapBasic
	Call splitStringToArray(strToWrite, 3, strArr)

	'Write binary file
	Dim i As Integer, filePart As SmallInt, nFileNum As Integer

	If Not FileExists(sFilePath) then
		Open File sFilePath for Output as #1
		Close File #1
	End If

	' Open the file in binary mode.  Locks are optional
	Open File sFilePath For Binary Access Read Write As #1
	   ' Put the data in the file
	   For i = 1 To UBound(strArr)
		   'Write information as integers (THIS IS A MUST!)
		   filePart = BaseA_to_Base10(64, strArr(i), 1)

		   ' No byte position is specified so writing begins at byte 1
		   Put #1, , filePart
	   Next
	Close File #1
End Sub

Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt
	Dim char As String, i, e, sum As Integer
	Define Base64 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"

	'Find BaseA's character range
	Dim sBaseACharRange As String
	sBaseACharRange = Left$(Base64, BaseA)

	For i = Len(Value) To 1 Step -1
		char = Mid$(Value, i, 1)
		If BaseA > 64 Then
			'Base 256
			e = Asc(char)
		Else
			'Base 0 --> 64
			e = InStr(1, sBaseACharRange, char) - 1

			'Error -999999 <-- Character is not not found in Base definition
			If e = -1 Then
				  BaseA_to_Base10 = -999999
				  Exit Function
			  End If
		End If

		'Calculate sum. This will be eventually returned
		sum = sum + e * BaseA ^ (Len(Value) - i)
	Next

	'Negatives for signed bytes
	If signedByte And sum > BaseA ^ Len(Value) / 2 Then
		sum = sum - BaseA ^ Len(Value)
	End If

	'Return sum
	BaseA_to_Base10 = sum
End Function

Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
	Dim i As Integer, j As Integer
	j = 1

	ReDim strArr(Int(Len(someString) / delimitLength))

	For i = 1 To Len(someString) Step delimitLength
		strArr(j) = Mid$(someString, i, delimitLength)
		j = j + 1
	Next
End Sub
)

;~~~~~~~~~~~~~~~~~~~~~~~~~~ EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
;Developers: Sancarn
;Contributors:
;GUID: {}

;TODO:
  ; filepath variable declarations
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB

;String to do actions on is MBSource
MB := MBSource
sFilePaths := []
sFileVars := []

;Main Regex: Include\s+"(.*)"\s*,\s*(\w+)\s+as\s+string
pattern := "iO)" . "Include\s+"((?!.*Include).*?)"\s*,\s*(\w+)\s+as\s+string"

;What does the regex mean?
;~~~~~~~~~~~~~~~~~~~~~~~~~
;The desired match should consist of 'Include "<some characters>" , <some variable name> as string'
;The following is an illegal match 'Include "<some characters> Include" , <some variable name> as string'
;Prefix Option "i" makes the regex case insensitive.
;Prefix Option "O" makes the regex return an object.
;The following match is legal: 'Include "someImage.png", someImage as string' in 'Include "someScript.mb"Include "someImage.png", someImage as string'

;Test this regex
;~~~~~~~~~~~~~~~~~~~~~~~~~
;https://regex101.com/r/zA3tP7/1

match = RegExMatch(MB, pattern, mObj, 1)

If match <> "" {
   while match <> ""
   {
      ;Get captured strings
      sFilePaths.push(match1)
      sFileVars.push(match2)

      ;Remove the match from MB
      MB := ImportFiles_MidInvert(MB,match, mObj.Len())

      ;Find the next match
      match = RegExMatch(MB, pattern, mObj, match)
   }

  ;All 'Include "someFile", asdf as string' have been removed from MB. MB therefore contains the 'most complete' script so far
  ;Next steps, generate
  ; filepath variable declarations
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB
}

ImportFiles_MidInvert(sSrc, iStart, iLen){
  ;This function does the oppisite of mid. Instead of extracting a part of a string and returning the extracted part, in this case we are returning the part after extraction. You can imagine this as if we were replacing the string returned from mid() with null.
  ;Examples
  ;~~~~~~~~~~~~~~~~
  ;MidInvert("https://regex101.com/r/zA3tP7/1",6,11)  returns "https.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",1,8)   returns "regex101.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",30,8)  returns "1"

  ;If iStart is less than 1 then there is no leftPart
  if (iStart > 1){
    leftPart := subStr(sSrc,1,iStart-1)
  }

  ;If iStart+iLen is greater than the length of the string, there can't be a right part
  if iStart+iLen >= strlen(sSrc){
    rightPart := subStr(sSrc,iStart + iLen)
  }

  ;Return concatenation of the left and right parts.
  return leftPart . rightPart
}

;In the Header we define declares which need to be added to the Header of the script (or to the .def files if they exist)
Header := "
Declare Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
Declare Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt 'as long
Declare Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
"

;In the footer we define the inner workings of the functions/subroutines declared in header
Footer := "
'~~~~~~~~~~~~~~~~~~~~~~~~~~ GENERATED BY EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
	Dim strArr() As String

	'get array of character pairs		'splitStringToArray sub-routine ported to MapBasic
	Call splitStringToArray(strToWrite, 3, strArr)

	'Write binary file
	Dim i As Integer, filePart As SmallInt, nFileNum As Integer

	If Not FileExists(sFilePath) then
		Open File sFilePath for Output as #1
		Close File #1
	End If

	' Open the file in binary mode.  Locks are optional
	Open File sFilePath For Binary Access Read Write As #1
	   ' Put the data in the file
	   For i = 1 To UBound(strArr)
		   'Write information as integers (THIS IS A MUST!)
		   filePart = BaseA_to_Base10(64, strArr(i), 1)

		   ' No byte position is specified so writing begins at byte 1
		   Put #1, , filePart
	   Next
	Close File #1
End Sub

Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt
	Dim char As String, i, e, sum As Integer
	Define Base64 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"

	'Find BaseA's character range
	Dim sBaseACharRange As String
	sBaseACharRange = Left$(Base64, BaseA)

	For i = Len(Value) To 1 Step -1
		char = Mid$(Value, i, 1)
		If BaseA > 64 Then
			'Base 256
			e = Asc(char)
		Else
			'Base 0 --> 64
			e = InStr(1, sBaseACharRange, char) - 1

			'Error -999999 <-- Character is not not found in Base definition
			If e = -1 Then
				  BaseA_to_Base10 = -999999
				  Exit Function
			  End If
		End If

		'Calculate sum. This will be eventually returned
		sum = sum + e * BaseA ^ (Len(Value) - i)
	Next

	'Negatives for signed bytes
	If signedByte And sum > BaseA ^ Len(Value) / 2 Then
		sum = sum - BaseA ^ Len(Value)
	End If

	'Return sum
	BaseA_to_Base10 = sum
End Function

Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
	Dim i As Integer, j As Integer
	j = 1

	ReDim strArr(Int(Len(someString) / delimitLength))

	For i = 1 To Len(someString) Step delimitLength
		strArr(j) = Mid$(someString, i, delimitLength)
		j = j + 1
	Next
End Sub
"

;~~~~~~~~~~~~~~~~~~~~~~~~~~ EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
;Developers: Sancarn
;Contributors:
;GUID: {}

;TODO:
  ; filepath variable declarations
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB

;String to do actions on is MBSource
MB := MBSource
sFilePaths := []
sFileVars := []

;Main Regex: Include\s+"(.*)"\s*,\s*(\w+)\s+as\s+string
pattern := "iO)" . "Include\s+"((?!.*Include).*?)"\s*,\s*(\w+)\s+as\s+string"

;What does the regex mean?
;~~~~~~~~~~~~~~~~~~~~~~~~~
;The desired match should consist of 'Include "<some characters>" , <some variable name> as string'
;The following is an illegal match 'Include "<some characters> Include" , <some variable name> as string'
;Prefix Option "i" makes the regex case insensitive.
;Prefix Option "O" makes the regex return an object.
;The following match is legal: 'Include "someImage.png", someImage as string' in 'Include "someScript.mb"Include "someImage.png", someImage as string'

;Test this regex
;~~~~~~~~~~~~~~~~~~~~~~~~~
;https://regex101.com/r/zA3tP7/1

match = RegExMatch(MB, pattern, mObj, 1)

If match <> "" {
   while match <> ""
   {
      ;Get captured strings
      sFilePaths.push(match1)
      sFileVars.push(match2)

      ;Remove the match from MB
      MB := ImportFiles_MidInvert(MB,match, mObj.Len())

      ;Find the next match
      match = RegExMatch(MB, pattern, mObj, match)
   }

  ;All 'Include "someFile", asdf as string' have been removed from MB. MB therefore contains the 'most complete' script so far
  ;Next steps, generate
  ; filepath variable declarations
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB
}

ImportFiles_MidInvert(sSrc, iStart, iLen){
  ;This function does the oppisite of mid. Instead of extracting a part of a string and returning the extracted part, in this case we are returning the part after extraction. You can imagine this as if we were replacing the string returned from mid() with null.
  ;Examples
  ;~~~~~~~~~~~~~~~~
  ;MidInvert("https://regex101.com/r/zA3tP7/1",6,11)  returns "https.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",1,8)   returns "regex101.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",30,8)  returns "1"

  ;If iStart is less than 1 then there is no leftPart
  if (iStart > 1){
    leftPart := subStr(sSrc,1,iStart-1)
  }

  ;If iStart+iLen is greater than the length of the string, there can't be a right part
  if iStart+iLen >= strlen(sSrc){
    rightPart := subStr(sSrc,iStart + iLen)
  }

  ;Return concatenation of the left and right parts.
  return leftPart . rightPart
}


Updated remap.ahk

Updated remap.ahk

#IfWinActive ahk_exe np21x64w.exe
*Esc::ControlSend,,{Blind}{Esc Down}
*Esc Up::ControlSend,,{Blind}{Esc Up}
*LWin::ControlSend,,{Blind}{LWin Down}
*LWin Up::ControlSend,,{Blind}{LWin Up}

; Muhenkan (PC98 NFER key) -> {vk1D}
*LAlt::ControlSend,,{Blind}{vk1D Down}
*LAlt Up::ControlSend,,{Blind}{vk1D Up}

; Henkan (PC98 XFER key) -> {vk1C}
*RAlt::ControlSend,,{Blind}{vk1C Down}
*RAlt Up::ControlSend,,{Blind}{vk1C Up}

RControl::LAlt

;Kana / かな -> {vkF2}
LWin & LAlt::ControlSend,,{Blind}{vkF2}
Ctrl & Space::ControlSend,,{Blind}^{Space}

;Ro key
LWin & /::ControlSend,,{Blind}{vke2 Down}
LWin & / up::ControlSend,,{Blind}{vke2 Up}

;IME ON/OF -> {vkF3}, {vkF4}

;Close emulator
LWin & Delete::WinClose
#if

#IfWinActive ahk_exe fgfs.exe
*Up::ControlSend,,{Blind}{PgUp Down}
*Up Up::ControlSend,,{Blind}{PgUp Up}
*Down::ControlSend,,{Blind}{PgDn Down}
*Down Up::ControlSend,,{Blind}{PgDn Up}
*Left::ControlSend,,{Blind}{Insert Down}
*Left Up::ControlSend,,{Blind}{Insert Up}
*Right::ControlSend,,{Blind}{Enter Down}
*Right Up::ControlSend,,{Blind}{Enter Up}
#if

#IfWinActive ahk_exe dosbox-x.exe
LWin::F13
LAlt::F14
LControl::F15
Esc::F16
RControl::F17
RAlt::F18
MButton::F19
#If

#IfWinActive ahk_exe np21x64w.exe
*Esc::ControlSend,,{Blind}{Esc Down}
*Esc Up::ControlSend,,{Blind}{Esc Up}
*LWin::ControlSend,,{Blind}{LWin Down}
*LWin Up::ControlSend,,{Blind}{LWin Up}

; Muhenkan (PC98 NFER key) -> {vk1D}
*LAlt::ControlSend,,{Blind}{vk1D Down}
*LAlt Up::ControlSend,,{Blind}{vk1D Up}

; Henkan (PC98 XFER key) -> {vk1C}
*RAlt::ControlSend,,{Blind}{vk1C Down}
*RAlt Up::ControlSend,,{Blind}{vk1C Up}

RControl::LAlt

;Kana / かな -> {vkF2}
LWin & LAlt::ControlSend,,{Blind}{vkF2}
Ctrl & Space::ControlSend,,{Blind}^{Space}

;Ro key
LWin & /::ControlSend,,{Blind}{vke2 Down}
LWin & / up::ControlSend,,{Blind}{vke2 Up}

;IME ON/OF -> {vkF3}, {vkF4}

;Close emulator
LWin & Delete::WinClose
#if

#IfWinActive ahk_exe fgfs.exe
*Up::ControlSend,,{Blind}{PgUp Down}
*Up Up::ControlSend,,{Blind}{PgUp Up}
*Down::ControlSend,,{Blind}{PgDn Down}
*Down Up::ControlSend,,{Blind}{PgDn Up}
*Left::ControlSend,,{Blind}{Insert Down}
*Left Up::ControlSend,,{Blind}{Insert Up}
*Right::ControlSend,,{Blind}{Enter Down}
*Right Up::ControlSend,,{Blind}{Enter Up}
#if

#IfWinActive ahk_exe dosbox-x.exe
LWin::F13
LAlt::F14
LControl::F15
#If


Update MBWindow.ahk

Update MBWindow.ahk

#IfWinActive ahk_exe MapInfoPro.exe ;THIS WILL NEED EXTENSION THROUGH "isMapBasicWindow()"
$Enter::    ;$ so Enter can be re-used

    If Not isMapBasicWindow() {
        send, {Enter}
        return
    }

    ;Get the MapBasic source from the MapBasic Window
    old_clipboard := ClipboardAll
	Clipboard=
	send, ^c
	clipwait,0.1
	MBSource := clipboard
	clipboard := old_clipboard

	If (needsCompiling(MBSource)) {
	    Compile(MBSource)
	} else {
	    send,{Enter}
	}
return

isMapBasicWindow(){
    ;TO DO: This should have more (fast) checks.
    MapInfo = ComObjGet("MapInfo.Application.x64")
    return MapInfo.Eval("ActiveWindow()") = 1002
}

needsCompiling(src){
	;Separated RegEx - This may require simplifying...:
	i := 0
	i := i + regexmatch(src,"i)\bAlter\b\s+\b(Control|MapInfoDialog)\b")			;matches {Alter Control,Alter MapInfoDialog}
	i := i + regexmatch(src,"i)\bCall\b")						        ;matches Call
	i := i + regexmatch(src,"i)\bDeclare\b\s+\b(Function|Sub)\b")				;matches {Declare Function, Declare Sub}
	i := i + regexmatch(src,"i)\bDefine\b")						        ;matches Define
	i := i + regexmatch(src,"i)\bDialog\b")						        ;matches {Dialog, Dialog Preserve, Dialog Remove}
	i := i + regexmatch(src,"i)\bDim\s+\w+\s*(,\s*\w+\s*)+\s+as\b")				;matches Dim {2 variable declarations} as
	i := i + regexmatch(src,"i)\bDo\s+Case\s+(.|\s)*?\bEnd\s+Case\b")			;matches Do Case … End Case,
	i := i + regexmatch(src,"i)\bDo\b\s+(.|\s)*?\bLoop\b")				    	;matches Do … Loop
	i := i + regexmatch(src,"i)\bEnd\s+Program\b")					        ;matches End Program
	i := i + regexmatch(src,"i)\bExit\s+(Do|For|Function|Sub)\b")				;matches {Exit Do, Exit For, Exit Function, Exit Sub}
	i := i + regexmatch(src,"i)\bFor\b(.|\s)*?\bNext\b")				    	;matches For … Next,
	i := i + regexmatch(src,"i)\bFunction\b(.|\s)*\bEnd\s+Function\b")			;matches Function … End Function
	i := i + regexmatch(src,"i)\bGoTo\b")			            			;matches GoTo
	i := i + regexmatch(src,"i)\bSub\b(.|\s)*\bEnd\s+Sub\b")				;matches Sub … End Sub
	i := i + regexmatch(src,"i)\bIf\b(.|\s)*?\bThen\b(.|\s)*?\bEnd\s+If\b")			;matches If .*? then … End If
	i := i + regexmatch(src,"i)\bInclude\b\s+\b"".*""\b")				    	;matches Include “…”
	i := i + regexmatch(src,"i)\bOnError\s+GoTo\b")					        ;matches OnError GoTo
	i := i + regexmatch(src,"i)\bOpen\s+File\b")					    	;matches Open File
	i := i + regexmatch(src,"i)\bProgressBar\b")    					;matches ProgressBar
	i := i + regexmatch(src,"i)\bResume\b")			    				;matches Resume
	i := i + regexmatch(src,"i)\bSet\s+Handler\b")		    				;matches Set Handler
	i := i + regexmatch(src,"i)\bType\b(.|\s)*?\bEnd\s+Type\b") 				;matches Type … End Type
	i := i + regexmatch(src,"i)\bWhile\b(.|\s)*?\bWend\b")		    			;matches While … Wend
	return i > 0
}

#IfWinActive ahk_exe MapInfoPro.exe ;THIS WILL NEED EXTENSION THROUGH "isMapBasicWindow()"
$Enter::    ;$ so Enter can be re-used

    If Not isMapBasicWindow() {
        send, {Enter}
        return
    }

    ;Get the MapBasic source from the MapBasic Window
    old_clipboard := ClipboardAll
	Clipboard=
	send, ^c
	clipwait,0.1
	MBSource := clipboard
	clipboard := old_clipboard

	MBSource := preCompile(MBSource)

	If (MBSource <> "") {
	    Compile(MBSource)
	} else {
	    send,{Enter}
	}
return

isMapBasicWindow(){
    ;TO DO: This should have more (fast) checks.
    MapInfo = ComObjGet("MapInfo.Application.x64")
    return MapInfo.Eval("ActiveWindow()") = 1002
}

preCompile(src){
	;Separated RegEx - This may require simplifying...:
	i := 0
	i := i + regexmatch(src,"i)\bAlter\b\s+\b(Control|MapInfoDialog)\b")			;matches {Alter Control,Alter MapInfoDialog}
	i := i + regexmatch(src,"i)\bCall\b")						        ;matches Call
	i := i + regexmatch(src,"i)\bDeclare\b\s+\b(Function|Sub)\b")				;matches {Declare Function, Declare Sub}
	i := i + regexmatch(src,"i)\bDefine\b")						        ;matches Define
	i := i + regexmatch(src,"i)\bDialog\b")						        ;matches {Dialog, Dialog Preserve, Dialog Remove}
	i := i + regexmatch(src,"i)\bDim\s+\w+\s*(,\s*\w+\s*)+\s+as\b")				;matches Dim {2 variable declarations} as
	i := i + regexmatch(src,"i)\bDo\s+Case\s+(.|\s)*?\bEnd\s+Case\b")			;matches Do Case … End Case,
	i := i + regexmatch(src,"i)\bDo\b\s+(.|\s)*?\bLoop\b")				    	;matches Do … Loop
	i := i + regexmatch(src,"i)\bEnd\s+Program\b")					        ;matches End Program
	i := i + regexmatch(src,"i)\bExit\s+(Do|For|Function|Sub)\b")				;matches {Exit Do, Exit For, Exit Function, Exit Sub}
	i := i + regexmatch(src,"i)\bFor\b(.|\s)*?\bNext\b")				    	;matches For … Next,
	i := i + regexmatch(src,"i)\bFunction\b(.|\s)*\bEnd\s+Function\b")			;matches Function … End Function
	i := i + regexmatch(src,"i)\bGoTo\b")			            			;matches GoTo
	i := i + regexmatch(src,"i)\bSub\b(.|\s)*\bEnd\s+Sub\b")				;matches Sub … End Sub
	i := i + regexmatch(src,"i)\bIf\b(.|\s)*?\bThen\b(.|\s)*?\bEnd\s+If\b")			;matches If .*? then … End If
	i := i + regexmatch(src,"i)\bInclude\b\s+\b"".*""\b")				    	;matches Include “…”
	i := i + regexmatch(src,"i)\bOnError\s+GoTo\b")					        ;matches OnError GoTo
	i := i + regexmatch(src,"i)\bOpen\s+File\b")					    	;matches Open File
	i := i + regexmatch(src,"i)\bProgressBar\b")    					;matches ProgressBar
	i := i + regexmatch(src,"i)\bResume\b")			    				;matches Resume
	i := i + regexmatch(src,"i)\bSet\s+Handler\b")		    				;matches Set Handler
	i := i + regexmatch(src,"i)\bType\b(.|\s)*?\bEnd\s+Type\b") 				;matches Type … End Type
	i := i + regexmatch(src,"i)\bWhile\b(.|\s)*?\bWend\b")		    			;matches While … Wend

	if (i>0) {
	    return src
	} else {
	    return ""
	}
}


[outlook] Add spell check drop down to outlook

link print screen to application option menu

; Autohotkey configuration file
; AHK Version v.1.1.32.00
; Franklin Chou (franklin.chou@nelsonmullins.com)
; 22 Mar. 2020
; Tested to work on Lenovo X1 Yoga, Gen. 4

#SingleInstance Force
#Persistent

GLOBAL_DEBUG_MODE := 1
Return

CapsLock::Ctrl
LCtrl::Return
;LCtrl::CapsLock

; DEBUG TOOLS -----------------------------------------------------------------

#c::
  If(GLOBAL_DEBUG_MODE > 0) {
    ; WinGetTitle, title, A
    WinGetClass, title, A
    MsgBox %title%
  }
Return

f12::
  If(GLOBAL_DEBUG_MODE > 0) {
    Reload
  }
Return

#'::
  If(GLOBAL_DEBUG_MODE > 0) {
    WinGet windows, List
    Loop %windows% {
      id := windows%A_Index%
      WinGetTitle wt, ahk_id %id%
      r .= wt . "`n"
    }
    MsgBox %r%
  }
Return

; TIMEKEEPER ------------------------------------------------------------------

; Shift focus to the timekeeper app
#!e::
  timekeeper_app := WinExist("ahk_class WindowsForms10.Window.8.app.0.262fb3d")
  ;MsgBox %timekeeper_app%
  If(timekeeper_app > 0) {
    WinActivate, ahk_id %timekeeper_app%
  } Else {
    Run, DTE.exe, C:\Program Files (x86)\DTEAxiom
  }
Return

; Start the timer on the selected item in the daily view
#IfWinActive ahk_class WindowsForms10.Window.8.app.0.262fb3d
  >+s::
    WinGetActiveTitle, active_title
    match_result := RegExMatch(active_title, "^Entries for")
    ; each item in the dropdown is approximately 25 pixels
    ; so item 4 (Start Timer) is 100 pixels down from the context menu
    drop_down := 100
    If(match_result > 0) {
      WinMove, 100, 100
      MouseMove, 100, 280
      Send {RButton}
      Sleep, 10 ; need to sleep to allow submenu time to come up
      MouseMove, 170, 300 + drop_down
      Send {LButton}
    }
Return

; WORD/OUTLOOK ----------------------------------------------------------------
#If WinActive("ahk_class OpusApp") || WinActive("ahk_class rctrl_renwnd32")
  PrintScreen::AppsKey
Return

; Autohotkey configuration file
; AHK Version v.1.1.30.01
; Franklin Chou (franklin.chou@nelsonmullins.com)
; 22 Mar. 2020
; Tested to work on Lenovo X1 Yoga, Gen. 4

#SingleInstance Force
#Persistent

GLOBAL_DEBUG_MODE := 0
Return

CapsLock::Ctrl
LCtrl::Return
;LCtrl::CapsLock

; DEBUG TOOLS -----------------------------------------------------------------

#c::
  If(GLOBAL_DEBUG_MODE > 0) {
    WinGetTitle, title, A
    MsgBox %GLOBAL_DEBUG_MODE% ;%title%
  }
Return

f12::
  If(GLOBAL_DEBUG_MODE > 0) {
    Reload
  }
Return

#'::
  If(GLOBAL_DEBUG_MODE > 0) {
    WinGet windows, List
    Loop %windows% {
      id := windows%A_Index%
      WinGetTitle wt, ahk_id %id%
      r .= wt . "`n"
    }
    MsgBox %r%
  }
Return

; TIMEKEEPER ------------------------------------------------------------------

; Shift focus to the timekeeper app
#!e::
  timekeeper_app := WinExist("ahk_class WindowsForms10.Window.8.app.0.262fb3d")
  ;MsgBox %timekeeper_app%
  If(timekeeper_app > 0) {
    WinActivate, ahk_id %timekeeper_app%
  } Else {
    Run, DTE.exe, C:\Program Files (x86)\DTEAxiom
  }
Return

; Start the timer on the selected item in the daily view
#IfWinActive ahk_class WindowsForms10.Window.8.app.0.262fb3d
  >+s::
    WinGetActiveTitle, active_title
    match_result := RegExMatch(active_title, "^Entries for")
    ; each item in the dropdown is approximately 25 pixels
    ; so item 4 (Start Timer) is 100 pixels down from the context menu
    drop_down := 100
    If(match_result > 0) {
      WinMove, 100, 100
      MouseMove, 100, 280
      Send {RButton}
      Sleep, 10 ; need to sleep to allow submenu time to come up
      MouseMove, 170, 300 + drop_down
      Send {LButton}
    }
Return

; WORD ------------------------------------------------------------------------
#IfWinActive ahk_class OpusApp
   PrintScreen::AppsKey
Return

; SYMBOL KEYS -----------------------------------------------------------------
>+s::send §