Skip to content

Commit

Permalink
got rid of calls to tt in favor of a2tip
Browse files Browse the repository at this point in the history
.. and some ahk2 fixes #266
  • Loading branch information
ewerybody committed Apr 22, 2024
1 parent 1fd8fb0 commit 65b2460
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/Autohotkey/lib/clipboard.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ clipboard_get_files() {
if FileExist(line)
files.push(line)
}
if (files.length())
if (files.length)
return files
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Autohotkey/lib/dragtangle.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dragtangle(drag_func := ""
dragtangle_off() {
; WIP: Currently unsure this is triggered at all.
; msgbox, dragtangle_off!
; tt("dragtangle_off", 1)
; a2tip("dragtangle_off", 1)
Hotkey, Esc, dragtangle_off, Off
return
}
2 changes: 1 addition & 1 deletion lib/Autohotkey/lib/python.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
python_get_output(py_file, args := "") {
py_exe := python_get_console_path()
cmd = "%py_exe%" "%py_file%" %args%
shell := ComObjCreate("WScript.Shell")
shell := ComObject("WScript.Shell")
exec := shell.Exec(cmd)
errors := exec.StdErr.ReadAll()
if (errors)
Expand Down
26 changes: 13 additions & 13 deletions lib/Autohotkey/lib/teadrinkerocr.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
; https://www.autohotkey.com/boards/viewtopic.php?t=72674

;Standalone part
If (A_Args.Length() == 5) {
If (A_Args.Length == 5) {
rect := {x: A_Args.1, y: A_Args.2, w: A_Args.3, h: A_Args.4}
text := teadrinkerocr(rect, A_Args.5)
FileAppend, %Text%, *
FileAppend(text, "*")
}

; Library part
Expand Down Expand Up @@ -37,12 +37,12 @@ teadrinkerocr_get_available_languages() {
DllCall(NumGet(NumGet(LanguageList+0)+7*A_PtrSize), "ptr", LanguageList, "int*", count) ; count

lang_list := []
loop % count
loop(count)
{
DllCall(NumGet(NumGet(LanguageList+0)+6*A_PtrSize), "ptr", LanguageList, "int", A_Index-1, "ptr*", hString) ; get_Item
DllCall(NumGet(NumGet(LanguageFactory+0)+6*A_PtrSize), "ptr", LanguageFactory, "ptr", hString, "ptr*", LanguageTest) ; CreateLanguage
DllCall(NumGet(NumGet(OcrEngineStatics+0)+8*A_PtrSize), "ptr", OcrEngineStatics, "ptr", LanguageTest, "int*", bool) ; IsLanguageSupported
if (bool = 1) {
if (bool == 1) {
DllCall(NumGet(NumGet(LanguageTest+0)+6*A_PtrSize), "ptr", LanguageTest, "ptr*", hText)
buffer := DllCall("Combase.dll\WindowsGetStringRawBuffer", "ptr", hText, "uint*", length, "ptr")
lang_list.push(StrGet(buffer, "UTF-16"))
Expand Down Expand Up @@ -74,17 +74,17 @@ HBitmapToRandomAccessStream(hBitmap) {

VarSetCapacity(PICTDESC, sz := 8 + A_PtrSize*2, 0)
NumPut(sz, PICTDESC), NumPut(PICTYPE_BITMAP, PICTDESC, 4), NumPut(hBitmap, PICTDESC, 8)
riid := CLSIDFromString(IID_IPicture, GUID1)
riid := CLSIDFromString(IID_IPicture, &GUID1)
DllCall("OleAut32\OleCreatePictureIndirect", "Ptr", &PICTDESC, "Ptr", riid, "UInt", false, "PtrP", pIPicture, "UInt")
; IPicture::SaveAsFile
DllCall(NumGet(NumGet(pIPicture+0) + A_PtrSize*15), "Ptr", pIPicture, "Ptr", pIStream, "UInt", true, "UIntP", size, "UInt")
riid := CLSIDFromString(IID_IRandomAccessStream, GUID2)
riid := CLSIDFromString(IID_IRandomAccessStream, &GUID2)
DllCall("ShCore\CreateRandomAccessStreamOverStream", "Ptr", pIStream, "UInt", BSOS_DEFAULT, "Ptr", riid, "PtrP", pIRandomAccessStream, "UInt")
ObjRelease(pIPicture), ObjRelease(pIStream)
Return pIRandomAccessStream
}

CLSIDFromString(IID, ByRef CLSID) {
CLSIDFromString(IID, &CLSID) {
VarSetCapacity(CLSID, 16, 0)
if res := DllCall("ole32\CLSIDFromString", "WStr", IID, "Ptr", &CLSID, "UInt")
throw Exception("CLSIDFromString failed. Error: " . Format("{:#x}", res))
Expand Down Expand Up @@ -116,7 +116,7 @@ ocr(IRandomAccessStream, lang := "FirstFromAvailableLanguages")
DllCall(NumGet(NumGet(OcrEngineStatics+0)+9*A_PtrSize), "ptr", OcrEngineStatics, ptr, Language, "ptr*", OcrEngine) ; TryCreateFromLanguage
}
if (OcrEngine = 0) {
msgbox Can not use language "%lang%" for OCR, please install language pack.
msgbox 'Can not use language "' . lang .'" for OCR, please install language pack.'
ExitApp
}
CurrentLanguage := lang
Expand All @@ -128,7 +128,7 @@ ocr(IRandomAccessStream, lang := "FirstFromAvailableLanguages")
DllCall(NumGet(NumGet(BitmapFrame+0)+12*A_PtrSize), "ptr", BitmapFrame, "uint*", width) ; get_PixelWidth
DllCall(NumGet(NumGet(BitmapFrame+0)+13*A_PtrSize), "ptr", BitmapFrame, "uint*", height) ; get_PixelHeight
if (width > MaxDimension) or (height > MaxDimension) {
msgbox Image is to big - %width%x%height%.`nIt should be maximum - %MaxDimension% pixels
msgbox "Image is to big - " width "x" height ".`nIt should be maximum - " MaxDimension " pixels!"
ExitApp
}
BitmapFrameWithSoftwareBitmap := ComObjQuery(BitmapDecoder, IBitmapFrameWithSoftwareBitmap := "{FE287C9A-420C-4963-87AD-691436E08383}")
Expand Down Expand Up @@ -163,11 +163,11 @@ CreateClass(string, interface, ByRef Class) {
result := DllCall("Combase.dll\RoGetActivationFactory", "ptr", hString, "ptr", &GUID, "ptr*", Class)
if (result != 0) {
if (result = 0x80004002)
msgbox No such interface supported
msgbox "No such interface supported"
else if (result = 0x80040154)
msgbox Class not registered
msgbox "Class not registered"
else
msgbox error: %result%
msgbox "error: " . result
ExitApp
}
DeleteHString(hString)
Expand All @@ -190,7 +190,7 @@ WaitForAsync(ByRef Object) {
if (status != 0) {
if (status != 1) {
DllCall(NumGet(NumGet(AsyncInfo+0)+8*A_PtrSize), "ptr", AsyncInfo, "uint*", ErrorCode) ; IAsyncInfo.ErrorCode
msgbox AsyncInfo status error: %ErrorCode%
msgbox "AsyncInfo status error: " ErrorCode
ExitApp
}
ObjRelease(AsyncInfo)
Expand Down
2 changes: 1 addition & 1 deletion lib/Autohotkey/lib/time.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ time_unix() {
}

; Tell current time in miliseconds.
time_unix_ms(decimals=2) {
time_unix_ms(decimals:=2) {
T := time_unix()
T += A_MSec / 1000
T := Round(T, decimals)
Expand Down
2 changes: 1 addition & 1 deletion lib/cmds/check_update.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if (version == A_AhkVersion)
else
result := 1

FileAppend(result, '*')
FileAppend(result, '*')
4 changes: 2 additions & 2 deletions lib/cmds/get_coordinates.ahk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; get_coordinates
#Persistent
msg := "`nLeft Mouse Button To Pick`nEscape To Cancel"
tt(msg)
a2tip(msg)
cursor_set_cross()
CoordMode, Mouse, Screen

Expand Down Expand Up @@ -32,7 +32,7 @@ PickCoordinates:
data := get_coords_str()
FileAppend, %data%, *
eZttText := data
tt(data, 0.5,, 1)
a2tip(data, 0.5,, 1)
Return

Exit:
Expand Down
22 changes: 12 additions & 10 deletions lib/cmds/pick_scope_nfo.ahk
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
; pick_scope_nfo
#Persistent
tt("Left Mouse Button To Pick")
CoordMode, Mouse, Screen
SetTimer, WatchCursor, 50
#include <a2tip>
a2tip("Left Mouse Button To Pick")
CoordMode "Mouse", "Screen"
SetTimer WatchCursor, 50

Escape::ExitApp
RButton::ExitApp
Expand All @@ -18,20 +19,21 @@ WatchCursor:
return

get_scope_info() {
MouseGetPos,,, window_id
WinGetTitle, this_title, ahk_id %window_id%
WinGetClass, this_class, ahk_id %window_id%
WinGet, this_process, ProcessName, ahk_id %window_id%
MouseGetPos ,, &window_id
ahkid := "ahk_id " . window_id
this_title := WinGetTitle(ahkid)
this_class := WinGetClass(ahkid)
this_process := WinGetProcessName(ahkid)
return [this_title, this_class, this_process]
}


PickInfo:
SetTimer, WatchCursor, Off
SetTimer WatchCursor, Off
global eZttText
winfo := get_scope_info()
data := winfo[1] "`n" winfo[2] "`n" winfo[3]
FileAppend, %data%, *
FileAppend(data, "*")
eZttText := data
tt(data, 0.5,, 1)
a2tip(data, 0.5,, 1)
Return

0 comments on commit 65b2460

Please sign in to comment.