Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AHK v1/Combined Example.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ KeyEvent(state){

#if cm1.IsActive
::aaa::JACKPOT
1::
1::
ToolTip % "KEY DOWN EVENT @ " A_TickCount
return

1 up::
ToolTip % "KEY UP EVENT @ " A_TickCount
return
Expand Down
4 changes: 2 additions & 2 deletions AHK v1/Context Example.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ return

#if cm1.IsActive
::aaa::JACKPOT
1::
1::
ToolTip % "KEY DOWN EVENT @ " A_TickCount
return

1 up::
ToolTip % "KEY UP EVENT @ " A_TickCount
return
Expand Down
12 changes: 6 additions & 6 deletions AHK v1/Development Tools/AhiScanCodeTester.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; REQUIRES AHK >= 1.1.32

/*
The purpose of this tool is to compare the keyboard events that AHK sees to the keyboard events that AHI sees
The purpose of this tool is to compare the keyboard events that AHK sees to the keyboard events that AHI sees
To use it, set the vid and pid variables below to the VID and PID of a keyboard...
... then run this script and press keys ONLY ON THAT KEYBOARD
Pressing keys on another keyboard will break the script!
Expand Down Expand Up @@ -69,26 +69,26 @@ AhiKeyEvent(keyEvents){
msgbox % "Expecting 1 or 2 AHI key events, but got " numEvents
ExitApp
}

; Note that keyEvents is a ZERO-BASED array!

ahiSc1 := keyEvents[0].Code
ahiState1 := keyEvents[0].state

if (numEvents == 2){
ahiSc2 := keyEvents[1].Code
ahiState2 := keyEvents[1].state
}

ahkSc1 := ahkKeyEvent.Code
if (ahkSc1 > 256){
ahkSc1 .= " (Ext " ahkSc1 - 256 ")"
}
ahkState1 := ahkKeyEvent.State

row := LV_Add(, GetKeyName("SC" DecToHex(ahkKeyEvent.Code)), ahkSc1, ahkState1, ahiSc1, ahiState1, ahiSc2, ahiState2)
LV_Modify(row, "Vis")

AhkKeyBuffer := []
}

Expand Down
12 changes: 6 additions & 6 deletions AHK v1/Lib/AutoHotInterception.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AutoHotInterception {
SetState(state){
this.Instance.SetState(state)
}

MoveCursor(x, y, cm := "Screen", mouseId := -1){
if (mouseId == -1)
mouseId := 11 ; Use 1st found mouse
Expand All @@ -108,7 +108,7 @@ class AutoHotInterception {
}
CoordMode, Mouse, % oldMode
}

GetDirection(cp, dp){
d := dp - cp
if (d > 0)
Expand Down Expand Up @@ -176,7 +176,7 @@ class AutoHotInterception {
SubscribeKeyboard(id, block, callback, concurrent := false) {
this.Instance.SubscribeKeyboard(id, block, callback, concurrent)
}

UnsubscribeKeyboard(id){
this.Instance.UnsubscribeKeyboard(id)
}
Expand All @@ -192,7 +192,7 @@ class AutoHotInterception {
SubscribeMouseButtons(id, block, callback, concurrent := false) {
this.Instance.SubscribeMouseButtons(id, block, callback, concurrent)
}

UnsubscribeMouseButtons(id){
this.Instance.UnsubscribeMouseButtons(id)
}
Expand Down Expand Up @@ -251,12 +251,12 @@ class AutoHotInterception {
this.id := id
result := this.parent.Instance.SetContextCallback(id, this.OnContextCallback.Bind(this))
}

OnContextCallback(state) {
Sleep 0
this.IsActive := state
}

Remove(){
this.parent.Instance.RemoveContextCallback(this.id)
}
Expand Down
4 changes: 2 additions & 2 deletions AHK v1/Monitor.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Loop 2 {

start := starts[devType]
UpdateWidth(0, 1) ; Reset max width

; Add device entries
Loop 10 {
i := start + A_Index
Expand Down Expand Up @@ -71,7 +71,7 @@ Loop 2 {
xpos := columnX[devType] + idW + maxWidths[devType]
Gui, Add, Button, % "x" xpos " y" rowY - vhOff " h14 w" copyW " hwndhwnd", Copy
GuiControl, +g, % hwnd, % fn

fn := Func("CopyClipboard").Bind(strings[A_index].handle)
Gui, Add, Button, % "x" xpos " y" rowY + vhOff " h14 w" copyW " hwndhwnd", Copy
GuiControl, +g, % hwnd, % fn
Expand Down
40 changes: 20 additions & 20 deletions AHK v1/RollMouse.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ class RollMouse {
MoveThreshold := {x: 4, y: 4}
; Good value for my mouse with FPS games: 4
; Good value for my laptop trackpad: 3

; The speed at which to move the mouse, can be decimals (eg 0.5)
; X and Y do not need to be equal
; Good value for my mouse with FPS games: x:2, y: 1 (don't need vertical roll so much)
;~ MoveFactor := {x: 1, y: 1}
MoveFactor := {x: 0.5, y: 0.25}
; Good value for my laptop trackpad: 0.2

; How fast (in ms) to send moves when rolling.
; High values for this will cause rolls to appear jerky instead of smooth
; if you halved this, double MoveFactor to get the same move amount, but at a faster frequency.
RollFreq := 1

; How long to wait after each move to decide whether a roll has taken place.
TimeOutRate := 50

; The amount that we are currently rolling by
LastMove := {x: 0, y: 0}

Expand All @@ -40,27 +40,27 @@ class RollMouse {
STATE_OVER_THRESH := 2
STATE_ROLLING := 3
StateNames := ["UNDER THRESHOLD", "OVER THRESHOLD", "ROLLING"]

State := 1

TimeOutFunc := 0
History := {} ; Movement history. The most recent item is first (Index 1), and old (high index) items get pruned off the end

; Was an option in old RollMouse
Friction := 0

__New(mouseId){
this.TimeOutFunc := this.DoRoll.Bind(this)
this.AHI := new AutoHotInterception()
this.mouseId := mouseId
this.AHI.SubscribeMouseMove(this.mouseId, false, this.MouseMove.Bind(this))
}

MouseMove(x, y){
static axes := {x: 1, y: 2}
;~ ToolTip % x ", " y
moved := {x: 0, y: 0}

for axis, index in axes {
obj := {}
obj.delta_move := %axis%
Expand All @@ -70,7 +70,7 @@ class RollMouse {
if (obj.abs_delta_move >= this.MoveThreshold[axis]){
moved[axis] := 1
}

this.UpdateHistory(axis, obj)
}

Expand All @@ -81,7 +81,7 @@ class RollMouse {
this.ChangeState(this.STATE_UNDER_THRESH)
}
}

UpdateHistory(axis, obj){
this.History[axis].InsertAt(1, obj)
; Enforce max number of entries
Expand All @@ -90,16 +90,16 @@ class RollMouse {
this.History[axis].RemoveAt(max, max - this.MOVE_BUFFER_SIZE)
}
}

DoRoll(){
static axes := {x: 1, y: 2}

;s := ""

if (this.State != this.STATE_ROLLING){
; If roll has just started, calculate roll vector from movement history
this.LastMove := {x: 0, y: 0}

for axis in axes {
;s .= axis ": "
trend := 0
Expand Down Expand Up @@ -127,7 +127,7 @@ class RollMouse {
this.LastMove[axis] := round(this.LastMove[axis] * this.MoveFactor[axis])
}
}

if (this.LastMove.x = 0 && this.LastMove.y = 0){
return
}
Expand Down Expand Up @@ -157,10 +157,10 @@ class RollMouse {
this.Debug("Changing State to : " this.StateNames[newstate])
this.State := newstate
}

; DO NOT return if this.State == newstate!
; We need to reset the timer!

if (this.State = this.STATE_UNDER_THRESH){
; Kill the timer
SetTimer % fn, Off
Expand All @@ -175,11 +175,11 @@ class RollMouse {
}
*/
}

InitHistory(){
this.History := {x: [], y: []}
}

Debug(text){
OutputDebug % "AHK| " text
}
Expand Down
2 changes: 1 addition & 1 deletion AHK v1/SubscribeAbsolute dragging example.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ProcessInput(newState, nx := "", ny := ""){
; x and y hold current x and current y
; state is the current state of the button
; stateChanged indicates whether state just changed or not

; ---- Start of your code ----
static dragStartX, dragStartY
tooltip % "Current Coords: " x ", " y, 0, 0, 1
Expand Down
2 changes: 1 addition & 1 deletion AHK v1/SubscribeAll Example.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ KeyEvent(code, state){
}

MouseButtonEvent(code, state){
ToolTip % "Mouse Button - Code: " code ", State: " state
ToolTip % "Mouse Button - Code: " code ", State: " state
}

^Esc::
Expand Down
22 changes: 11 additions & 11 deletions AHK v1/TabletLib/JSON.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class JSON
; the 'IsArray' property. If so, Array() will be called normally,
; otherwise, use a custom base object for arrays
static json_array := Func("Array").IsBuiltIn || ![].IsArray ? {IsArray: true} : 0

; sacrifice readability for minor(actually negligible) performance gain
(ch == "{")
? ( is_key := true
Expand All @@ -89,12 +89,12 @@ class JSON
; ch == "["
: ( value := json_array ? new json_array : []
, next := json_value_or_array_closing )

ObjInsertAt(stack, 1, value)

if (this.keys)
this.keys[value] := []

} else {
if (ch == q) {
i := pos
Expand All @@ -118,7 +118,7 @@ class JSON
, value := StrReplace(value, "\t", "`t")

pos := i ; update pos

i := 0
while (i := InStr(value, "\",, i+1)) {
if !(SubStr(value, i+1, 1) == "u")
Expand All @@ -133,7 +133,7 @@ class JSON
key := value, next := ":"
continue
}

} else {
value := SubStr(text, pos, i := RegExMatch(text, "[\]\},\s]|$",, pos)-pos)

Expand All @@ -160,7 +160,7 @@ class JSON
if (this.keys && this.keys.HasKey(holder))
this.keys[holder].Push(key)
}

} ; while ( ... )

return this.rev ? this.Walk(root, "") : root[""]
Expand All @@ -169,7 +169,7 @@ class JSON
ParseError(expect, text, pos, len:=1)
{
static q := Chr(34)

line := StrSplit(SubStr(text, 1, pos), "`n", "`r").Length()
col := pos - InStr(text, "`n",, -(StrLen(text)-pos+1))
msg := Format("{1}`n`nLine:`t{2}`nCol:`t{3}`nChar:`t{4}"
Expand All @@ -195,7 +195,7 @@ class JSON
if IsObject(value)
for i, k in this.keys[value]
value[k] := this.Walk.Call(this, value, k) ; bypass __Call

return this.rev.Call(holder, key, value)
}
}
Expand Down Expand Up @@ -254,7 +254,7 @@ class JSON
is_array := value.IsArray
; Array() is not overridden, rollback to old method of
; identifying array-like objects. Due to the use of a for-loop
; sparse arrays such as '[1,,3]' are detected as objects({}).
; sparse arrays such as '[1,,3]' are detected as objects({}).
if (!is_array) {
for i in value
is_array := i == A_Index
Expand All @@ -266,7 +266,7 @@ class JSON
Loop, % value.Length() {
if (this.gap)
str .= this.indent

v := this.Str(value, A_Index)
str .= (v != "") && value.HasKey(A_Index) ? v . "," : "null,"
}
Expand Down Expand Up @@ -294,7 +294,7 @@ class JSON

return is_array ? "[" . str . "]" : "{" . str . "}"
}

} else ; is_number ? value : "value"
return ObjGetCapacity([value], 1)=="" ? value : this.Quote(value)
}
Expand Down
2 changes: 1 addition & 1 deletion AHK v1/TabletLib/TabletLib.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Class Box {
StartY := 0
EndX := 0
EndY := 0

__New(name){
this.BoxName := name
}
Expand Down
Loading