Skip to content

Commit

Permalink
Command Dialog is useable
Browse files Browse the repository at this point in the history
  • Loading branch information
SPFabGerman committed Feb 29, 2020
0 parents commit 797d953
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CommandList.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#Include, HelperFunctions.ahk

initCommands:
; === Add Commands Here ===
global CommandArray := ["reload", "stop", "help"]
CommandArray := sortArray(CommandArray)
global CommandCount := CommandArray.MaxIndex()
global commandArrayString := Join("|", CommandArray*)
Return

reload:
Reload
return

stop:
ExitApp
return

help:
MsgBox, , Autohotkey Shell Help, % "Available Commands:`n - " + Join("`n - ", CommandArray*)
11 changes: 11 additions & 0 deletions FoxitReader.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#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.

#IfWinActive ahk_class classFoxitReader
^t::
SendInput {Esc}{Alt}y1
Sleep 250
SendInput yb
return
26 changes: 26 additions & 0 deletions HelperFunctions.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
sortArray(arr,options="") { ; specify only "Flip" in the options to reverse otherwise unordered array items

if !IsObject(arr)
return 0
new := []
if (options="Flip") {
While (i := arr.MaxIndex()-A_Index+1)
new.Insert(arr[i])
return new
}
For each, item in arr
list .= item "`n"
list := Trim(list,"`n")
Sort, list, %options%
Loop, parse, list, `n, `r
new.Insert(A_LoopField)
return new

}

; Joins a string array together
Join(sep, params*) {
for index,param in params
str .= param . sep
return SubStr(str, 1, -StrLen(sep))
}
Binary file added Icons/fun_F.ico
Binary file not shown.
Binary file added Icons/fun_F.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Icons/num_1.ico
Binary file not shown.
Binary file added Icons/num_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions MainNumpadController.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#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.

CoordMode, ToolTip, Screen
global numLockOn := GetKeyState("NumLock", "T")
displayNumLock()
Gosub, initCommands
Gosub, createGUI

#Include, CommandList.ahk

; Removes Tooltip
removeTooltip:
ToolTip
return

; Changes Icon and Displays Tooltip, acording to numLockOn
displayNumLock(){
If (numLockOn = 1){
ToolTip, Numbers active, A_ScreenWidth, A_ScreenHeight-55
Menu, Tray, Icon, Icons/num_1.ico
}else{
ToolTip, Functions active, A_ScreenWidth, A_ScreenHeight-55
Menu, Tray, Icon, Icons/fun_F.ico
}
SetTimer, removeTooltip, -3000
return
}

; initializes the gui for later use
createGUI:
global ASH_Input_Box
global ASH_Input_List_Index
Gui, ASH:New,,Autohotkey SHell
Gui, ASH:Add, Edit, r1 vASH_Input_Box gASH_Input_Change,
Gui, ASH:Add, ListBox, r5 vASH_Input_List_Index +AltSubmit, %CommandArrayString%
GuiControl, Choose, ASH_Input_List_Index, 1
return

ASH_Input_Change:
GuiControlGet, ASH_Input_Box, ASH:
GuiControl, ChooseString, ASH_Input_List_Index, %ASH_Input_Box%
return

#IfWinActive, Autohotkey SHell
Enter::
Gui, ASH:Submit
Gosub, % CommandArray[ASH_Input_List_Index]
return

Down::
GuiControlGet, curIndex, ASH:, ASH_Input_List_Index,
curIndex := curIndex + 1
if (curIndex > CommandCount){
curIndex := CommandCount
}
GuiControl, ASH:Choose, ASH_Input_List_Index, %curIndex%
return

Up::
GuiControlGet, curIndex, ASH:, ASH_Input_List_Index,
curIndex := curIndex - 1
if (curIndex <= 0){
curIndex := 1
}
GuiControl, ASH:Choose, ASH_Input_List_Index, %curIndex%
return

Tab::return

Escape::
Gui, ASH:Hide
return

#IfWinActive

; Change NumLock State (numLockOn)
NumLock::
numLockOn := !numLockOn
SetNumLockState, %numLockOn%
displayNumLock()
return

; Show GUI
NumpadIns::
GuiControl, ASH:Choose, ASH_Input_List_Index, 1
GuiControl, ASH:Text, ASH_Input,
Gui, ASH:Show,,
return

0 comments on commit 797d953

Please sign in to comment.