Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f4::
- getSelectionCoords(x_start, x_end, y_start, y_end)
- return
- ; creates a click-and-drag selection box to specify an area
- getSelectionCoords(ByRef x_start, ByRef x_end, ByRef y_start, ByRef y_end) {
- ;Mask Screen
- Gui, Color, FFFFFF
- Gui +LastFound
- WinSet, Transparent, 50
- Gui, -Caption
- Gui, +AlwaysOnTop
- Gui, Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%,"AutoHotkeySnapshotApp"
- ;Drag Mouse
- CoordMode, Mouse, Screen
- CoordMode, Tooltip, Screen
- WinGet, hw_frame_m,ID,"AutoHotkeySnapshotApp"
- hdc_frame_m := DllCall( "GetDC", "uint", hw_frame_m)
- KeyWait, LButton, D
- MouseGetPos, scan_x_start, scan_y_start
- Loop
- {
- Sleep, 10
- KeyIsDown := GetKeyState("LButton")
- if (KeyIsDown = 1)
- {
- MouseGetPos, scan_x, scan_y
- DllCall( "gdi32.dll\Rectangle", "uint", hdc_frame_m, "int", 0,"int",0,"int", A_ScreenWidth,"int",A_ScreenWidth)
- DllCall( "gdi32.dll\Rectangle", "uint", hdc_frame_m, "int", scan_x_start,"int",scan_y_start,"int", scan_x,"int",scan_y)
- } else {
- break
- }
- }
- ;KeyWait, LButton, U
- MouseGetPos, scan_x_end, scan_y_end
- Gui Destroy
- if (scan_x_start < scan_x_end)
- {
- x_start := scan_x_start
- x_end := scan_x_end
- } else {
- x_start := scan_x_end
- x_end := scan_x_start
- }
- if (scan_y_start < scan_y_end)
- {
- y_start := scan_y_start
- y_end := scan_y_end
- } else {
- y_start := scan_y_end
- y_end := scan_y_start
- }
- }
- f1::
- RunWait, C:\Users\Thom\Desktop\Capture2Text_v3.9\Capture2Text.exe %x_start% %y_start% %x_end% %y_end%
- ;msgbox, %clipboard%
- ComObjCreate("SAPI.SpVoice").Speak(Clipboard)
- return
- f2:: ;change voice type
- if (SUCCEEDED(SpGetCategoryFromId(SPCAT_VOICES := "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices", cpSpObjectTokenCategory)))
- {
- hr := DllCall(NumGet(NumGet(cpSpObjectTokenCategory+0)+18*A_PtrSize), "Ptr", cpSpObjectTokenCategory, "Ptr", 0, "Ptr", 0, "Ptr*", cpSpEnumTokens)
- if (SUCCEEDED(hr))
- {
- hr := DllCall(NumGet(NumGet(cpSpEnumTokens+0)+8*A_PtrSize), "Ptr", cpSpEnumTokens, "UInt*", tokenCount)
- if (SUCCEEDED(hr))
- {
- voices := Object()
- Loop %tokenCount% {
- hr := DllCall(NumGet(NumGet(cpSpEnumTokens+0)+7*A_PtrSize), "Ptr", cpSpEnumTokens, "UInt", A_Index - 1, "Ptr*", pToken)
- if (FAILED(hr)) {
- MsgBox Bailing out
- ExitApp 1
- }
- hr := DllCall(NumGet(NumGet(pToken+0)+6*A_PtrSize), "Ptr", pToken, "Ptr", 0, "Ptr*", pszValue)
- if (FAILED(hr)) {
- MsgBox Bailing out
- ExitApp 2
- }
- hr := DllCall(NumGet(NumGet(pToken+0)+16*A_PtrSize), "Ptr", pToken, "Ptr*", pszCoMemTokenId)
- if (FAILED(hr)) {
- MsgBox Bailing out
- ExitApp 3
- }
- voices[StrGet(pszCoMemTokenId, "UTF-16")] := StrGet(pszValue, "UTF-16")
- DllCall("ole32\CoTaskMemFree", "Ptr", pszValue)
- DllCall("ole32\CoTaskMemFree", "Ptr", pszCoMemTokenId)
- ObjRelease(pToken)
- }
- prompt := "Pick a voice by its number:"
- for k, v in voices
- prompt .= "`r`n" . A_Index . ": " v
- InputBox, TheChosenOne,, %prompt%
- if (ErrorLevel == 0) {
- for k, v in voices {
- if (A_Index == TheChosenOne) {
- hr := DllCall(NumGet(NumGet(cpSpObjectTokenCategory+0)+19*A_PtrSize), "Ptr", cpSpObjectTokenCategory, "WStr", k)
- break
- }
- }
- }
- }
- ObjRelease(cpSpEnumTokens)
- }
- ObjRelease(cpSpObjectTokenCategory)
- }
- SpGetCategoryFromId(pszCategoryId, ByRef ppCategory, fCreateIfNotExist := False)
- {
- static CLSID_SpObjectTokenCategory := "{A910187F-0C7A-45AC-92CC-59EDAFB77B53}"
- ,ISpObjectTokenCategory := "{2D3D3845-39AF-4850-BBF9-40B49780011D}"
- hr := 0
- try {
- cpTokenCategory := ComObjCreate(CLSID_SpObjectTokenCategory, ISpObjectTokenCategory)
- } catch e {
- ; No, A_LastError or ErrorLevel doesn't contain the error code on its own and I CBA to use CoCreateInstance directly
- if (RegExMatch(e.Message, "0[xX][0-9a-fA-F]+", errCode)) { ; https://stackoverflow.com/a/9221391
- hr := errCode + 0
- } else {
- hr := 0x80004005
- }
- }
- if (SUCCEEDED(hr))
- {
- hr := DllCall(NumGet(NumGet(cpTokenCategory+0)+15*A_PtrSize), "Ptr", cpTokenCategory, "WStr", pszCategoryId, "Int", fCreateIfNotExist)
- }
- if (SUCCEEDED(hr))
- {
- ppCategory := cpTokenCategory
- }
- else
- {
- if (cpTokenCategory)
- ObjRelease(cpTokenCategory)
- }
- return hr
- }
- SUCCEEDED(hr)
- {
- return hr != "" && hr >= 0x00
- }
- FAILED(hr)
- {
- return hr == "" || hr < 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement