How to embed Notepad in a GUI?
Is there a simple method like this one to embed IE, https://www.autohotkey.com/boards/viewtopic.php?t=46702#p210448?
EDITED: I would like to embed in a GUI both of them, IE and Notepad.
How to embed Notepad in a GUI?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: How to embed Notepad in a GUI?
A standard (AHK) edit control almost has the same functionality as notepad so why would you want to do so?
If you need a "bit more" functionality try the Edit library by jballi, check the "editor" example https://www.autohotkey.com/boards/viewtopic.php?t=5063 which is just like notepad. Simply expand that example and embed a browser.
If you need a "bit more" functionality try the Edit library by jballi, check the "editor" example https://www.autohotkey.com/boards/viewtopic.php?t=5063 which is just like notepad. Simply expand that example and embed a browser.
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: How to embed Notepad in a GUI?
Thank you, ahk7!
Edit, of course, this was my first attempt, but: There seems to be a data limit for Edit, e.g. a 300 kB file can not be displayed and edited in Edit.
Edit, of course, this was my first attempt, but: There seems to be a data limit for Edit, e.g. a 300 kB file can not be displayed and edited in Edit.
Re: How to embed Notepad in a GUI?
You could try the scintilla control 32 bit version here https://github.com/RaptorX/scintilla-wrapper
[ If you need 64bit I have a patched version here https://github.com/RaptorX/scintilla-wrapper/issues/5 ]
[ If you need 64bit I have a patched version here https://github.com/RaptorX/scintilla-wrapper/issues/5 ]
Re: How to embed Notepad in a GUI?
possible alternative: use any editor as normal and dock your ahk gui to it https://www.autohotkey.com/boards/viewtopic.php?f=6&t=30912 ?
-
- Posts: 4326
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to embed Notepad in a GUI?
EM_SETLIMITTEXTnewbieforever wrote: ↑There seems to be a data limit
Re: How to embed Notepad in a GUI?
I think it's the variable size or AHK cannot create a control with too much text in it
AHK shows an error with this
This works fine but it takes some time until I see the gui(the clipboard contains 3.79mb text
AHK shows an error with this
Code: Select all
Gui,Add,Edit,x0 y0 W640 h480,% Clipboard
Gui,Show,Center, w640 h480
Return
Code: Select all
Gui,Add,Edit,x0 y0 W640 h480,
GuiControl,,Edit1,% Clipboard
Gui,Show,Center, w640 h480
Return
-
- Posts: 4326
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to embed Notepad in a GUI?
Hmm,I didn't know that,thanks
But why is it so much faster,is it because AHK is trying to wrap the text so the text will not be wider than the edit control?
Seems that's the case(notepad also instantly displays the text if I disable word wrap)
But why is it so much faster,is it because AHK is trying to wrap the text so the text will not be wider than the edit control?
Seems that's the case(notepad also instantly displays the text if I disable word wrap)
-
- Posts: 4326
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to embed Notepad in a GUI?
Yes, that's how it is.
Re: How to embed Notepad in a GUI?
just an example , tried movetogether script from wolf_II
Code: Select all
;- movetogether from user wolf_II
;- https://www.autohotkey.com/boards/viewtopic.php?p=199402#p199402
#warn
#NoEnv
setworkingdir,%a_scriptdir%
wa:=a_screenwidth
ha:=a_screenheight
xx:=100
Handles := []
;------------ ahk script --------------------
;- create ahk GUI
Gui,2: New, hwndhwin1, Window 1
Gui,2: -DPIScale
SS_REALSIZECONTROL := 0x40
Gui,2:default
Gui,2:Color,Black,Black
Gui,2:Font,s12 cYellow ,Lucida Console
;------------------------------------------------------
;url:="https://autohotkey.com/boards/"
f1:="https://autohotkey.com/boards/"
x1:=(wa*1)/xx,y1:=(ha*1)/xx,w1:=(wa*48)/xx,h1:=(ha*2.7)/xx
Gui,2: Add, Edit,x%x1% y%y1% w%w1% h%h1% vURL,%f1%
x1:=(wa*50)/xx,y1:=(ha*1)/xx,w1:=(wa*2.5)/xx,h1:=(ha*2.7)/xx
Gui,2: Add, Button, x%x1% y%y1% w%w1% h%h1% Default gA1, Go
x1:=(wa*53)/xx,y1:=(ha*1)/xx,w1:=(wa*2.5)/xx,h1:=(ha*2.7)/xx
Gui,2: Add, Button, x%x1% y%y1% w%w1% h%h1% gBrB, <
x1:=(wa*56)/xx,y1:=(ha*1)/xx,w1:=(wa*2.5)/xx,h1:=(ha*2.7)/xx
Gui,2: Add, Button, x%x1% y%y1% w%w1% h%h1% gBrF, >
xxa:="Shell.Explorer"
;xxa:="Mozilla.Browser"
x1:=(wa*1)/xx,y1:=(ha*5)/xx,w1:=(wa*59)/xx,h1:=(ha*88)/xx
Gui,2: Add, ActiveX,x%x1% y%y1% w%w1% h%h1% vWB,%xxa%
wb.silent := true
x1:=(wa*.1)/xx,y1:=(ha*.1)/xx,w1:=(wa*59.9)/xx,h1:=(ha*94)/xx
Gui,2:Show, x%x1% y%y1% w%w1% h%h1%,TEST
gosub,a1
Handles.Push(hwin1)
;=================================================
;----------- next-attached window ----------
run,notepad,,,pid2
;-------------------------------------------------
WinWaitActive, ahk_pid %pid2%
x1:=(wa*59.9)/xx,y1:=(ha*.1)/xx,w1:=(wa*40)/xx,h1:=(ha*96)/xx
WinMove, ahk_pid %pid2%, , x1,y1,w1,h1 ;- move 2nd-script to the right position
IfWinNotActive ,ahk_pid %pid2%,,WinActivate,ahk_pid %pid2% ;- Activate 2nd-script
WinWaitActive,ahk_pid %pid2%
Handles.Push(WinExist("A")) ;- 2nd-script is lastactive
MoveTogether(Handles)
settimer,closethisscript,500 ;- close this script also if 2nd-script was closed
Return
;-------------------------------------------------------------------------------------------------------------
closethisscript:
process, exist, %PID2%
status1 = %ErrorLevel%
if (status1 = 0) ;- close this ahk-script if PID2 not exist
{
exitapp
}
return
;-----------------------------------
2Guiescape:
2Guiclose:
WinClose, ahk_pid %pid2%
WinWaitClose,ahk_pid %pid2%
exitapp
;------------------------------------
a1:
Gui,2: Submit, NoHide
WB.Navigate(URL)
return
;--------------
Brb:
try{WB.GoBack()
}catch e{
;xxx:=e.Message
;msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
return
}
return
BrF:
try{WB.GoForward()
}catch e{
;xxx:=e.Message
;msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
return
}
return
;----------------
class WB_events
{
NavigateComplete2(wb, NewURL)
{
GuiControl,2:Text, URL, %NewURL% ;- Update the URL edit control.
}
}
;====================================
;----------- ATTACH from user 'wolf_II' ----------------------------------------
MoveTogether(wParam, lParam = "", _ = "", hWnd = "") { ; using DeferWindowPos
;-------------------------------------------------------------------------------
; call MoveTogether(Handles) with an array of handles
; to set up a bundle of AHK Gui's that move together
;---------------------------------------------------------------------------
; https://autohotkey.com/boards/viewtopic.php?p=199402#p199402
; version 2018.02.08
static init := OnMessage(0xA1, "MoveTogether") ; WM_NCLBUTTONDOWN
static Handles
If IsObject(wParam) ; detect a set up call
Return, Handles := wParam ; store the array of handles
If (wParam != 2) ; HTCAPTION
Return
; changing AHK settings here will have no side effects
CoordMode, Mouse, Screen ; for MouseGetPos
SetBatchLines, -1 ; for onMessage
SetWinDelay, -1 ; for WinActivate, WinMove
M_old_X := lParam & 0xFFFF, M_old_Y := lParam >> 16 & 0xFFFF
WinActivate, ahk_id %hWnd%
Win := {}
For each, Handle in Handles {
WinGetPos, X, Y, W, H, ahk_id %Handle%
Win[Handle] := {X: X, Y: Y, W: W, H: H}
}
While GetKeyState("LButton", "P") {
MouseGetPos, M_new_X, M_new_Y
dX := M_new_X - M_old_X, M_old_X := M_new_X
, dY := M_new_Y - M_old_Y, M_old_Y := M_new_Y
If GetKeyState("Shift", "P")
WinMove, ahk_id %hWnd%,, Win[hWnd].X += dX, Win[hWnd].Y += dY
Else { ; DeferWindowPos cycle
hDWP := DllCall("BeginDeferWindowPos", "Int", Handles.Length(), "Ptr")
For each, Handle in Handles
hDWP := DllCall("DeferWindowPos", "Ptr", hDWP
, "Ptr", Handle, "Ptr", 0
, "Int", Win[Handle].X += dX
, "Int", Win[Handle].Y += dY
, "Int", Win[Handle].W
, "Int", Win[Handle].H
, "UInt", 0x214, "Ptr")
DllCall("EndDeferWindowPos", "Ptr", hDWP)
}
}
}
;=================================== END script ====================================
-
- Posts: 4326
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to embed Notepad in a GUI?
@garry
How about Gui,2: New, hwndhwin1 +Resize, Window 1 ?
How about Gui,2: New, hwndhwin1 +Resize, Window 1 ?
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: How to embed Notepad in a GUI?
Interesting:newbieforever wrote: ↑28 Mar 2020, 05:13There seems to be a data limit for Edit, e.g. a 300 kB file can not be displayed and edited in Edit.
This doesn't work with larger files (f1):
Code: Select all
FileRead, Code, % f1
;;;
Gui Add, Edit, w1080 h200 vvEdit, %Code% ;;; Error: Can't create control.
Code: Select all
FileRead, Code, % f1
;;;
Gui Add, Edit, w1080 h200 vvEdit
GuiControl, , vEdit, %Code%
Re: How to embed Notepad in a GUI?
@teadrinker, resize is only for the GUI , notepad is only attached ( not embedded in GUI )
-
- Posts: 4326
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to embed Notepad in a GUI?
But what if I want to make resizable GUI?
Re: How to embed Notepad in a GUI?
yes you can resize the GUI ... but the notepad doesn't follow ( it's only attached to the GUI )
-
- Posts: 4326
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to embed Notepad in a GUI?
It's the inconvenience of this approach.
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: How to embed Notepad in a GUI?
Thanks to ahk7, teadrinker, garry.
In the meantime I experimented with the "workaround" Edit, but the functionality limitations compared to Notepad are too big for my purpose.
So may I put my original question once again into the foreground:
Of course I see and know that there are workaround solutions to link a notepad window with a GUI (as shown above by garry, for example).
But I ask again, is it really the case that embedding Notepad in a similar simple way as it can be done for IE is not possible?
In the meantime I experimented with the "workaround" Edit, but the functionality limitations compared to Notepad are too big for my purpose.
So may I put my original question once again into the foreground:
Of course I see and know that there are workaround solutions to link a notepad window with a GUI (as shown above by garry, for example).
But I ask again, is it really the case that embedding Notepad in a similar simple way as it can be done for IE is not possible?
-
- Posts: 4326
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to embed Notepad in a GUI?
Nope.newbieforever wrote: ↑is it really the case that embedding Notepad in a similar simple way as it can be done for IE is not possible?
What functionality are you missing?newbieforever wrote: ↑the functionality limitations compared to Notepad are too big
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: How to embed Notepad in a GUI?
... The whole standard functionality of Notepad ... searching/replacing, simple encoding management when saving ... ...
Another (off topic) question: Is there a simple command to refresh the embedded IE?
Who is online
Users browsing this forum: CuriousDad, rc76 and 225 guests