Post by jeeswg » 07 Mar 2019, 00:48
- People talk about porting AutoHotkey or equivalent functionality to other systems, but nothing ever happens.
- I could work on it from time to time, or assist, but I'd need to get a foothold.
- Classic functionality would be to retrieve the window title, and text, in Notepad, or the Notepad equivalent.
- In the example below I show how to do this in Notepad via AutoHotkey commands, and then via the DllCall function (the DllCall code can be easily translated into C++).
- I would greatly appreciate if others could provide similar code, in any programming language, for other systems (e.g. Linux/Mac/iOS/Android).
- Other basic examples would be appreciated also, such as sending key presses and clicks. And the fundamental example for creating hotkeys: receiving key presses.
- Also, examples of existing programs with any of this functionality would be much appreciated, especially if they are open source.
- And, any examples of window inspectors such as AccViewer (for Windows) would be useful, to get an idea of what text can be retrieved from windows/GUIs.
- Thanks.
Code: Select all
q:: ;Notepad - get window title and Edit control text
;get title/text using built-in commands
WinGetTitle, vWinTitle, A
ControlGetText, vText, Edit1, A
vOutput1 := vWinTitle "`r`n" vText
;get title via DllCall
hWnd := DllCall("user32\GetForegroundWindow", "Ptr")
vChars := 1+DllCall("user32\GetWindowTextLength", "Ptr",hWnd)
VarSetCapacity(vWinTitle, vChars*2, 0)
DllCall("user32\GetWindowText", "Ptr",hWnd, "Ptr",&vWinTitle, "Int",vChars)
VarSetCapacity(vWinTitle, -1)
;get text via DllCall
vCtlID := 15 ;Edit control
;vCtlID := 1025 ;msctls_statusbar32 control
hCtl := DllCall("user32\GetDlgItem", "Ptr",hWnd, "Int",vCtlID, "Ptr")
vChars := 1+DllCall("user32\SendMessage", "Ptr",hCtl, "UInt",0xE, "UPtr",0, "Ptr",0, "Ptr") ;WM_GETTEXTLENGTH := 0xE
VarSetCapacity(vText, vChars*2, 0)
DllCall("user32\SendMessage", "Ptr",hCtl, "UInt",0xD, "UPtr",vChars, "Ptr",&vText, "Ptr") ;WM_GETTEXT := 0xD
VarSetCapacity(vText, -1)
vOutput2 := vWinTitle "`r`n" vText
MsgBox, % vOutput1
vScriptName := A_ScriptName
DllCall("user32\MessageBox", "Ptr",0, "Ptr",&vOutput2, "Ptr",&vScriptName, "UInt",0)
return
==================================================
LINKS (LINUX) (IRONAHK)
GitHub - Paris/IronAHK: Cross platform .NET rewrite of the popular AutoHotkey scripting language for desktop automation.
https://github.com/Paris/IronAHK
IronAHK - .NET port of AutoHotkey for Windows, Linux, Mac... - Offtopic - AutoHotkey Community
https://autohotkey.com/board/topic/31480-ironahk-net-port-of-autohotkey-for-windows-linux-mac/
IronAHK (alpha): cross platform .NET rewrite of AutoHotkey - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/50354-ironahk-alpha-cross-platform-net-rewrite-of-autohotkey/
naming conventions - Why are many ports of languages to .net prefixed with 'Iron'? - Stack Overflow
https://stackoverflow.com/questions/1194309/why-are-many-ports-of-languages-to-net-prefixed-with-iron
IronAHK still a thing? - Utilities - AutoHotkey Community
https://autohotkey.com/board/topic/102633-ironahk-still-a-thing/
LINKS (LINUX)
Linux AutoHotkey version - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=12971
We want AHK for Linux! - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=60112
Autohotkey like function for Linux - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=81&t=64772
Another alternative to AHK for Linux / Unix - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=22&t=17630
Replicating AutoHotKey's magic on a linux/unix/mac osx computer (thoughts on linux/osx port?) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=22&t=9806
AHK alternative for Ubuntu? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=22&t=3685
AHK in Linux? - Offtopic - AutoHotkey Community
https://autohotkey.com/board/topic/4157-ahk-in-linux/
My experience porting AHK scripts to Linux. - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=22&t=65552
==================================================
LINKS (MAC/IOS)
Can I run AHK on a Mac that is running Windows with Parallels? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=19244
Autohotkey for Mac - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=27043
AutoHotKey Equivalent for Mac - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=35638
Writing AHK Interpreters for Mac - Any plans for the future / current projects? And other Qs... - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=62690
==================================================
LINKS (ANDROID)
Ahk Text expansion on Android? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=66383
- People talk about porting AutoHotkey or equivalent functionality to other systems, but nothing ever happens.
- I could work on it from time to time, or assist, but I'd need to get a foothold.
- Classic functionality would be to retrieve the window title, and text, in Notepad, or the Notepad equivalent.
- In the example below I show how to do this in Notepad via AutoHotkey commands, and then via the DllCall function (the DllCall code can be easily translated into C++).
- I would greatly appreciate if others could provide similar code, in any programming language, for other systems (e.g. Linux/Mac/iOS/Android).
- Other basic examples would be appreciated also, such as sending key presses and clicks. And the fundamental example for creating hotkeys: receiving key presses.
- Also, examples of existing programs with any of this functionality would be much appreciated, especially if they are open source.
- And, any examples of window inspectors such as AccViewer (for Windows) would be useful, to get an idea of what text can be retrieved from windows/GUIs.
- Thanks.
[code]
q:: ;Notepad - get window title and Edit control text
;get title/text using built-in commands
WinGetTitle, vWinTitle, A
ControlGetText, vText, Edit1, A
vOutput1 := vWinTitle "`r`n" vText
;get title via DllCall
hWnd := DllCall("user32\GetForegroundWindow", "Ptr")
vChars := 1+DllCall("user32\GetWindowTextLength", "Ptr",hWnd)
VarSetCapacity(vWinTitle, vChars*2, 0)
DllCall("user32\GetWindowText", "Ptr",hWnd, "Ptr",&vWinTitle, "Int",vChars)
VarSetCapacity(vWinTitle, -1)
;get text via DllCall
vCtlID := 15 ;Edit control
;vCtlID := 1025 ;msctls_statusbar32 control
hCtl := DllCall("user32\GetDlgItem", "Ptr",hWnd, "Int",vCtlID, "Ptr")
vChars := 1+DllCall("user32\SendMessage", "Ptr",hCtl, "UInt",0xE, "UPtr",0, "Ptr",0, "Ptr") ;WM_GETTEXTLENGTH := 0xE
VarSetCapacity(vText, vChars*2, 0)
DllCall("user32\SendMessage", "Ptr",hCtl, "UInt",0xD, "UPtr",vChars, "Ptr",&vText, "Ptr") ;WM_GETTEXT := 0xD
VarSetCapacity(vText, -1)
vOutput2 := vWinTitle "`r`n" vText
MsgBox, % vOutput1
vScriptName := A_ScriptName
DllCall("user32\MessageBox", "Ptr",0, "Ptr",&vOutput2, "Ptr",&vScriptName, "UInt",0)
return
[/code]
==================================================
LINKS (LINUX) (IRONAHK)
GitHub - Paris/IronAHK: Cross platform .NET rewrite of the popular AutoHotkey scripting language for desktop automation.
[url]https://github.com/Paris/IronAHK[/url]
IronAHK - .NET port of AutoHotkey for Windows, Linux, Mac... - Offtopic - AutoHotkey Community
[url]https://autohotkey.com/board/topic/31480-ironahk-net-port-of-autohotkey-for-windows-linux-mac/[/url]
IronAHK (alpha): cross platform .NET rewrite of AutoHotkey - Scripts and Functions - AutoHotkey Community
[url]https://autohotkey.com/board/topic/50354-ironahk-alpha-cross-platform-net-rewrite-of-autohotkey/[/url]
naming conventions - Why are many ports of languages to .net prefixed with 'Iron'? - Stack Overflow
[url]https://stackoverflow.com/questions/1194309/why-are-many-ports-of-languages-to-net-prefixed-with-iron[/url]
IronAHK still a thing? - Utilities - AutoHotkey Community
[url]https://autohotkey.com/board/topic/102633-ironahk-still-a-thing/[/url]
LINKS (LINUX)
Linux AutoHotkey version - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=13&t=12971[/url]
We want AHK for Linux! - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=13&t=60112[/url]
Autohotkey like function for Linux - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=81&t=64772[/url]
Another alternative to AHK for Linux / Unix - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=22&t=17630[/url]
Replicating AutoHotKey's magic on a linux/unix/mac osx computer (thoughts on linux/osx port?) - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=22&t=9806[/url]
AHK alternative for Ubuntu? - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=22&t=3685[/url]
AHK in Linux? - Offtopic - AutoHotkey Community
[url]https://autohotkey.com/board/topic/4157-ahk-in-linux/[/url]
My experience porting AHK scripts to Linux. - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=22&t=65552[/url]
==================================================
LINKS (MAC/IOS)
Can I run AHK on a Mac that is running Windows with Parallels? - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=5&t=19244[/url]
Autohotkey for Mac - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=5&t=27043[/url]
AutoHotKey Equivalent for Mac - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=23&t=35638[/url]
Writing AHK Interpreters for Mac - Any plans for the future / current projects? And other Qs... - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=5&t=62690[/url]
==================================================
LINKS (ANDROID)
Ahk Text expansion on Android? - AutoHotkey Community
[url]https://autohotkey.com/boards/viewtopic.php?f=5&t=66383[/url]