(Excuse me, new to AHK)
I understand that there isn't necessarily a console for AHK, but I am wondering if there is a way to send messages similar to the send command in CMD. For example, my script would open up a window similar to console and would send messages about what the script is doing. I am just looking for the best way in your opinion to do this.
Thank you,
legislator
AHK Console Topic is solved
-
- Posts: 119
- Joined: 25 Dec 2015, 10:01
Re: AHK Console
euhm you can use tooltips for this 
you can also use traytips
For example if your script is sending a message you could use TrayTip,Sending A Message, 1
for tooltip you can do the same just swap TrayTip with Tooltip
This is the traytip one
ToolTip:

you can also use traytips
For example if your script is sending a message you could use TrayTip,Sending A Message, 1
for tooltip you can do the same just swap TrayTip with Tooltip
This is the traytip one
Code: Select all
#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.
ScriptName = TrayTip
TrayTip,%ScriptName%, Press A to test, 1
A::
TrayTip,%ScriptName%,Sending A Message,1
return
ToolTip:
Code: Select all
ScriptName = ToolTip
TrayTip,%ScriptName%,Press A to test, 1
A::
{
mousegetpos, x, y
tooltip, Sending A Message, (x + 20), (y + 20), 1
SetTimer, RemoveToolTip, 1000
}
Sleep 1000
gosub Test2
return
Test2:
{
tooltip, Sending A Message 2, (x + 20), (y + 20), 1
SetTimer, RemoveToolTip, 1000
}
return
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return
Re: AHK Console
At runtime you could right-click at the scripts trayicon and select 'Open'. It will show the most recently executed commands. Check out its additional features at its menu bar. Good luck 

-
- Posts: 119
- Joined: 25 Dec 2015, 10:01
Re: AHK Console
BoBo wrote:At runtime you could right-click at the scripts trayicon and select 'Open'. It will show the most recently executed commands. Check out its additional features at its menu bar. Good luck


i currently made a example its not completely working as it should but you might think that it is useful

made one here https://github.com/SkrillexAkaCraft/Console
Re: AHK Console
It's quite possible that there are other scripts similar to this, any links are welcome, but I've had a go at creating a console for AutoHotkey:
Code: Select all
q::
Print("hello world")
Print(1+2+3+4)
return
Print(vOutput)
{
static hGui, hEdit, vText, vWinW := 400, vWinH := 400
if !hGui
{
Gui, New, +HwndhGui
Gui, Font, s18 w700 cC0C0C0, Courier New
Gui, Color,, 000000
Gui, Add, Edit, % Format("+HwndhEdit x0 y0 w{} h{}", vWinW, vWinH)
Gui, Show, % Format("w{} h{}", vWinW, vWinH)
vText := vOutput
}
else
{
ControlGetText, vText,, % "ahk_id " hEdit
vText .= "`r`n" vOutput
}
ControlSetText,, % vText, % "ahk_id " hEdit
vLen := StrLen(vText)
SendMessage, 0xB1, % vLen, % vLen,, % "ahk_id " hEdit ;EM_SETSEL := 0xB1
PostMessage, 0xB7, 0, 0,, % "ahk_id " hEdit ;EM_SCROLLCARET := 0xB7
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: AHK Console
That's cool* stuff!jeeswg wrote:It's quite possible that there are other scripts similar to this, any links are welcome, but I've had a go at creating a console for AutoHotkey: [...]

* OMG, yesterday I'd to learn that 'cool' is so 80'

Re: AHK Console
:offtopic: BoBo you make me laugh often.
@jeeswg looks very good. This is better than a MsgBox for debugging. @RUNIE's m() is very good, and most handy, but this can stay open and you can keep printing to it.
Performance is really good, even if I see you are setting the entire text with the new concatenated. Don't take that as criticism, because I wouldn't have the experience to do something like this so well. :D Will have to spend more time with it, but haven't caught any issue's yet. :P
@jeeswg looks very good. This is better than a MsgBox for debugging. @RUNIE's m() is very good, and most handy, but this can stay open and you can keep printing to it.
Performance is really good, even if I see you are setting the entire text with the new concatenated. Don't take that as criticism, because I wouldn't have the experience to do something like this so well. :D Will have to spend more time with it, but haven't caught any issue's yet. :P
try it and see
...
...
Re: AHK Console Topic is solved
@jeeswg, thank you
have you an idea with EM_xxx , how to create an easy editor , needed :
- search text ( and continue search with F3)
- search text and replace ( yes,all,no,cancel )
example , mark text and use alt+F6 > send text to edit
have you an idea with EM_xxx , how to create an easy editor , needed :
- search text ( and continue search with F3)
- search text and replace ( yes,all,no,cancel )
example , mark text and use alt+F6 > send text to edit
Code: Select all
;- created =20150209
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
edcol1=white
edcol2=yellow
edcol3=red
GUI,2:+AlwaysOnTop
Gui,2: Color, ControlColor, Black
Gui,2: Font, CDefault, FixedSys
Gui,2:Add, Edit, x5 y10 w800 h100 c%edcol1% vF1,
GUI,2:show, NA W820 H130 X20 Y0, Mark Text and use alt+F6
return
;----------------------------------------------------------
2GuiClose:
ExitApp
*~$!F6::
sc=ahk_class AutoHotkeyGUI
classNN=Edit1
C2=
Clipboard := ""
Send, ^c
sleep,100
clipwait,1
C2:=clipboard
if (ErrorLevel)
return
IfWinNotActive ,%SC%,,WinActivate,%SC%
WinWaitActive,%SC%
;sendevent,%c2%
;- or
ControlSend,%classnn%,%c2%`n,%sc%
return
;=========================================================
Last edited by garry on 16 Sep 2017, 05:06, edited 1 time in total.
Re: AHK Console
You're quite right derz00, I had similar concerns while writing it, I've since gone back to the script, and resolved those issues, essentially by using EM_REPLACESEL.
SkrillexAkaCraft and icuurd12b42 (see link lower down) also used EM_REPLACESEL:
GitHub - SkrillexAkaCraft/Console
https://github.com/SkrillexAkaCraft/Console
==================================================
@garry: I wrote this script just for fun really, I'd either use MsgBox/ToolTip/Progress, or, store the 'console' text in a variable and use something like DebugVars to copy the text to clipboard/display the text somewhere. I did recreate a classic Find dialog once, so I might check for and improve that script. To do a Replace dialog would be easier than a Find dialog, so I'll have a go at that as well.
Btw icuurd12b42 is working on a console window:
Debug Window, A AHK gui based console window - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=37113
Btw garry have you checked re. AHK v2, to make your code as forwards compatible as possible?
AHK v1 to AHK v2 conversion tips/changes summary - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37&t=36787
SkrillexAkaCraft and icuurd12b42 (see link lower down) also used EM_REPLACESEL:
GitHub - SkrillexAkaCraft/Console
https://github.com/SkrillexAkaCraft/Console
Code: Select all
q:: ;console
Print("hello world")
Print(1+2+3+4)
return
Print(vOutput)
{
static hGui, hEdit, vWinW := 400, vWinH := 400
if !hGui
{
Gui, New, +HwndhGui
Gui, Font, s18 w700 cC0C0C0, Courier New
;Gui, Font, cC0C0C0, Fixedsys
Gui, Color,, 000000
Gui, Add, Edit, % Format("+HwndhEdit x0 y0 w{} h{}", vWinW, vWinH)
Gui, Show, % Format("w{} h{}", vWinW, vWinH)
}
vOutput .= "`r`n"
SendMessage, 0xE, 0, 0,, % "ahk_id " hEdit ;WM_GETTEXTLENGTH := 0xE
vLen := ErrorLevel
SendMessage, 0xB1, % vLen, % vLen,, % "ahk_id " hEdit ;EM_SETSEL := 0xB1
SendMessage, 0xC2, 0, % &vOutput,, % "ahk_id " hEdit ;EM_REPLACESEL := 0xC2
;PostMessage, 0xB7, 0, 0,, % "ahk_id " hEdit ;EM_SCROLLCARET := 0xB7
}
@garry: I wrote this script just for fun really, I'd either use MsgBox/ToolTip/Progress, or, store the 'console' text in a variable and use something like DebugVars to copy the text to clipboard/display the text somewhere. I did recreate a classic Find dialog once, so I might check for and improve that script. To do a Replace dialog would be easier than a Find dialog, so I'll have a go at that as well.
Btw icuurd12b42 is working on a console window:
Debug Window, A AHK gui based console window - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=37113
Btw garry have you checked re. AHK v2, to make your code as forwards compatible as possible?
AHK v1 to AHK v2 conversion tips/changes summary - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37&t=36787
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA