I'm posting up my work on a interactive tutorial
here is a dropbox link to the Zip (download this if you like to test it out)
Looking for feedback and i'd like to work together on this projekt if others find my work okay to work out from.
I'll be glad to give more info as to my idea's with this version
Images:
Spoiler
here is the main script (you'll need more to run it)
Spoiler
Please give all the input you like and just ask if you have any issuseCode: Select all
#Persistent
#singleinstance force
#include res\SCI.ahk
DetectHiddenWindows, On
#NoEnv
SetBatchLines, -1
;~ DllCall("Kernel32.dll\LoadLibrary", "Str", "SciLexer.dll")
SysGet, Border, 33 ; 32, 33 = SM_CXSIZEFRAME, SM_CYSIZEFRAME
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
sCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32646,"UInt") ;IDC_SIZEALL
OnMessage(WM_MOUSEHOVER := 0x200, "MouseMove")
OnMessage(0x46, "WM_WINDOWPOSCHANGING")
FileRead, xml, lessonSets\Learner Xml.xml
XmlObj := loodxml(xml)
lessonnumber := 1
global Info := {}
global Buttons := {}
Main := {}
;~ ; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
StartGui()
return
start:
;~ msgbox % cStyle
;~ colors[cStyle][
;~ https://kuler.adobe.com/create/color-wheel/?base=2&rule=Shades&selected=4&name=My%20Kuler%20Theme&mode=rgb&rgbvalues=0.38097054039034406,0.6965790293760442,0.75,0.25398036026022935,0.4643860195840295,0.5,0.5079607205204587,0.928772039168059,1,0.12699018013011468,0.23219300979201474,0.25,0.45716464846841287,0.8358948352512531,0.9
if (cStyle = 0)
colors := ["61B2BF","41767F","82EDFF","203B40","75D5E5"] ; cyan
;~ https://kuler.adobe.com/create/color-wheel/?base=2&rule=Analogous&selected=0&name=My%20Kuler%20Theme&mode=rgb&rgbvalues=0.18570123250815695,0.5962083107161846,1,0.16898812158242282,0.7375526886512855,0.91,0.235701232508157,1,0.9749795284274647,0.16898812158242282,0.91,0.6760215168743932,0.18570123250815695,1,0.5124188724463774
else if (cStyle = 1)
Colors := ["2F98FF","2BBCE8","3CFFF9","2BE8AC","2FFF83"] ; green and blue
;~ https://kuler.adobe.com/create/color-wheel/?base=2&rule=Monochromatic&selected=0&name=My%20Kuler%20Theme&mode=rgb&rgbvalues=0.1178506162540785,0.5,0.48748976421373236,0.5357012325081569,1,0.9848004803784839,0.235701232508157,1,0.9749795284274647,0.26785061625407847,0.5,0.49240024018924194,0.1885609860065256,0.8,0.7799836227419719
else if (cStyle = 2)
Colors := ["1E7F7C","89FFFB","3CFFF9","447F7E","30CCC7"] ; green
;~ https://kuler.adobe.com/create/color-wheel/?base=2&rule=Monochromatic&selected=0&name=My%20Kuler%20Theme&mode=rgb&rgbvalues=0.1178506162540785,0.5,0.48748976421373236,0.5357012325081569,1,0.9848004803784839,0.235701232508157,1,0.9749795284274647,0.26785061625407847,0.5,0.49240024018924194,0.1885609860065256,0.8,0.7799836227419719
else if (cStyle = 3)
Colors := ["006DBF","00497F","0092FF","002440","0083E5"] ; Deep blue
Gui Main: +hwndMainHwnd +Resize
Gui Main: Margin, 0,0
Gui Main: Color, % colors[1]
OnMessage(0x200, "WM_MOUSEMOVE")
SysGet, Mon, MonitorWorkArea, 1
Main := {Hwnd: MainHwnd, x: MonLeft, y: MonTop, w: MonRight, h: MonBottom}
; ==================== Scite ====================
gosub, Set_scite_Vars
SciRact := {x:395, y:95, w:(Main.w-395), h:(Main.h-200)}
;~ Gui, Main: Add, Custom, % " ClassScintilla x" SciRact.x " y" SciRact.y " w" SciRact.w " h" SciRact.h " HwndHSC vSC +E0x20000" ; creates a Scintilla control
sci := new scintilla(MainHwnd, SciRact.x, SciRact.y, SciRact.w, SciRact.h, "res\SciLexer.dll")
sci.Notify := "SCI_NOTIFY"
;~ SetSciMargin(sci)
; Set Autohotkey Lexer and default options
sci.SetWrapMode(true), sci.SetLexer(SCLEX_AHKL)
sci.StyleSetFont(STYLE_DEFAULT, "Courier New"), sci.StyleSetSize(STYLE_DEFAULT, 10)
sci.StyleSetBack(STYLE_DEFAULT, 0x232C31)
sci.StyleSetFore(STYLE_DEFAULT, 0xDCD3CE)
sci.SetCaretFore(STYLE_DEFAULT, 0xDCD3CE)
sci.SetSelFore(1, 0x232C31)
sci.SetSelBack(1, 0xDCD3CE)
sci.SetCaretFore(0xDCD3CE)
sci.StyleClearAll()
; Set Style Colors
gosub, SetStyle
; Set up keyword lists, the variables are set at the beginning of the code
Loop 9
{
lstN:=a_index-1
sci.SetKeywords(lstN, ( lstN = 0 ? Dir
: lstN = 1 ? Com
: lstN = 2 ? Param
: lstN = 3 ? Flow
: lstN = 4 ? Fun
: lstN = 5 ? BIVar
: lstN = 6 ? Keys
: lstN = 7 ? UD1
: lstN = 8 ? UD2
: null))
}
redo:
Gui Main: show, Maximize, AHk Learner ; autosize doesnt recognize the scintilla control, width & height + 10px border
;~ WinSet, Style, -0xC40000, % "Ahk_id " sci.hwnd
WinGetPos, Mx, My, Mw, Mh, % "Ahk_id " MainHwnd
; ============ Submit ============
{
SubmitHwnd := SubmitGui(MainHwnd)
WinGetPos, Sx, Sy, Sw, Sh, % "Ahk_id " SubmitHwnd
Buttons[ButtonName := "Button1", "ButtonText"] := "Save & Submit"
Buttons[ButtonName, "xOffset"] := 50
Buttons[ButtonName, "yOffset"] := Sh - 70
Button1Hwnd := MakeButton("Button1", 0xDD . colors[3], 0xFF . colors[2], SubmitHwnd)
Buttons[Button1Hwnd, "GuiName"] := ButtonName
Buttons[Button1Hwnd, "OwnerHwnd"] := SubmitHwnd
Buttons[Button1Hwnd, "OwnerName"] := "Submit"
}
; ============ Left Main ============
{
LeftMainHwnd := LeftMainGui(MainHwnd)
WinGetPos, LMx, LMy, LMw, LMh, % "Ahk_id " LeftMainHwnd
Buttons[ButtonName := "Button2", "ButtonText"] := "Video"
Buttons[ButtonName, "xOffset"] := 50
Buttons[ButtonName, "yOffset"] := LMh - 70
Button2Hwnd := MakeButton("Button2", 0xDD . colors[3], 0xFF . colors[2], LeftMainHwnd)
Buttons[Button2Hwnd, "GuiName"] := "Button2"
Buttons[Button2Hwnd, "OwnerHwnd"] := LeftMainHwnd
Buttons[Button2Hwnd, "OwnerName"] := "LeftMain"
}
; ============ Left Top ============
{
LeftTopHwnd := LeftTopGui(LeftMainHwnd)
WinGetPos, LTx, LTy, LTw, LTh, % "Ahk_id " LeftTopHwnd
Buttons[ButtonName := "ChooseButton", "ButtonText"] := lessonnumber . "|" . XmlObj.getElementsByTagName("lesson").length
Buttons[ButtonName, "xOffset"] := "30"
Buttons[ButtonName, "yOffset"] := "5"
ChooseBHwnd := MakeButton(ButtonName, 0xDD . colors[3], 0xFF . colors[2], LeftTopHwnd)
Buttons[ChooseBHwnd, "GuiName"] := ButtonName
Buttons[ChooseBHwnd, "OwnerHwnd"] := LeftTopHwnd
Buttons[ChooseBHwnd, "OwnerName"] := "LeftTop"
}
; ============ Main Top ============
{
MainTopHwnd := MainTopGui(MainHwnd)
}
; ============ checkpoint ============
{
checkpointHwnd := CheckpointGui(LeftMainHwnd)
}
; ============ Instructions ============
{
InstHwnd := InstGui(CheckpointHwnd)
}
; ============ Console ============
{
ConsoleHwnd := ConsoleGui(MainTopHwnd)
}
; Put some text in the control (optional)
Text := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/code/precode").text
if (Text != "")
sci.SetText(unused, XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/code/precode").text "`n`n")
else
sci.ClearAll()
sci.SetMarginWidthN(1, 0)
sci.GrabFocus()
sci.GOTOPOS(XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/code/caretpos").text)
return
MakeGuipBack(MainOwnerHwnd, childHwnd, GuiNumber)
{
WinGetPos, Cx, Cy, Cw, Ch, % "Ahk_id " childHwnd
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
;~ msgbox % info[GuiNumber, "Offset"]
x := Cx-info[childHwnd, "Offset"], y := Cy-info[childHwnd, "Offset"]
Width := Cw+(info[childHwnd, "Offset"]*2), Height := Ch+(info[childHwnd, "Offset"]*2)
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
Gui, %GuiNumber%: -Caption +E0x80000 +HwndHwnd1 +Owner%MainOwnerHwnd%
info[Hwnd1, "GuiName"] := GuiNumber
; Show the window
Gui, %GuiNumber%: Show, NA, %GuiNumber%
info[childHwnd, "OwnerName"] := GuiNumber
info[childHwnd, "OwnerHwnd"] := Hwnd1
Gui, % info[childHwnd, "GuiName"] ": +Owner" . hwnd1
; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
hbm := CreateDIBSection(Width, Height)
; Get a device context compatible with the screen
hdc := CreateCompatibleDC()
; Select the bitmap into the device context
obm := SelectObject(hdc, hbm)
; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromHDC(hdc)
; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)
; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
pBrush := Gdip_BrushCreateSolid(0x77E5E4E2)
; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
pBrush_Black := Gdip_BrushCreateSolid(0xFF000000)
; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
;~ Gdip_SetClipRect(G, 20, 20, Width-40, Height-40, 4)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20)
Gdip_FillRoundedRectangle(G, pBrush_Black, 10, 10, Width-20, Height-20, 10)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)
Gdip_DeleteBrush(pBrush_Black)
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd1, hdc, x, y, Width, Height)
; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui
OnMessage(0x201, "WM_LBUTTONDOWN")
;~ OnMessage(0x46, "WM_WINDOWPOSCHANGING")
Gui, %GuiNumber%: Show, x%x% y%y% w%Width% h%Height%
; Select the object back into the hdc
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
return hwnd1
}
MakeHatchBack(MainOwnerHwnd, childHwnd, GuiNumber)
{
WinGetPos, Cx, Cy, Cw, Ch, % "Ahk_id " childHwnd
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
x := Cx, y := Cy
Width := Cw, Height := Ch
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
Gui, %GuiNumber%: -Caption +E0x80000 +HwndHwnd1 +Owner%MainOwnerHwnd%
; Show the window
Gui, %GuiNumber%: Show, NA
info[childHwnd, "OwnerName"] := GuiNumber
info[childHwnd, "OwnerHwnd"] := Hwnd1
Gui, % info[childHwnd, "GuiName"] ": +Owner" . hwnd1
; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
hbm := CreateDIBSection(Width, Height)
; Get a device context compatible with the screen
hdc := CreateCompatibleDC()
; Select the bitmap into the device context
obm := SelectObject(hdc, hbm)
; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromHDC(hdc)
; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)
; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
;~ pBrush := Gdip_BrushCreateSolid(0x77007700)
pBrush := Gdip_BrushCreateHatch(0x00000000, 0x77232C31, HatchStyleDiagonalCross := 5)
; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
;~ pBrush_Black := Gdip_BrushCreateSolid(0xFF000000)
; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
;~ Gdip_SetClipRect(G, 20, 20, Width-40, Height-40, 4)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 3)
;~ Gdip_FillRoundedRectangle(G, pBrush_Black, 10, 10, Width-20, Height-20, 10)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)
;~ Gdip_DeleteBrush(pBrush_Black)
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd1, hdc, x, y, Width, Height)
; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui
OnMessage(0x201, "WM_LBUTTONDOWN")
;~ OnMessage(0x46, "WM_WINDOWPOSCHANGING")
;~ Cx-=10
;~ Cy-=10
;~ Gui, %GuiNumber%: Show, x%x% y%y% w%Width% h%Height%
; Select the object back into the hdc
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
return hwnd1
}
MakeInstGui(MainOwnerHwnd, childHwnd, GuiNumber)
{
WinGetPos, Cx, Cy, Cw, Ch, % "Ahk_id " childHwnd
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
Width := 150, Height := 40
xOffset := Cx+(Cw/2)-(width/2)
yOffset := Cy-(Height/2)
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
Gui, %GuiNumber%: +HwndHwnd1 -Caption +E0x80000 +LastFound +ToolWindow +OwnDialogs
; Show the window
Gui, %GuiNumber%: Show, NA
Gui, %GuiNumber%: +Owner%childHwnd%
; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
hbm := CreateDIBSection(Width, Height)
; Get a device context compatible with the screen
hdc := CreateCompatibleDC()
; Select the bitmap into the device context
obm := SelectObject(hdc, hbm)
; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromHDC(hdc)
; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)
; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
Outer_pBrush := Gdip_BrushCreateSolid(0xDD5599C7)
pBrush := Gdip_BrushCreateSolid(0xFFFFFFFF) ; 95B9C7
; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
Gdip_FillRoundedRectangle(G, Outer_pBrush, 0, 0, Width, Height, 6)
Gdip_FillRoundedRectangle(G, pBrush, 3, 3, Width-6, Height-6, 3)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)
; We can specify the font to use. Here we use Arial as most systems should have this installed
Font = Verdana
; Next we can check that the user actually has the font that we wish them to use
; If they do not then we can do something about it. I choose to give a wraning and exit!
If !Gdip_FontFamilyCreate(Font)
{
MsgBox, 48, Font error!, The font you have specified does not exist on the system
ExitApp
}
; There are a lot of things to cover with the function Gdip_TextToGraphics
; The 1st parameter is the graphics we wish to use (our canvas)
; The 2nd parameter is the text we wish to write. It can include new lines `n
; The 3rd parameter, the options are where all the action takes place...
; You can write literal x and y coordinates such as x20 y50 which would place the text at that position in pixels
; or you can include the last 2 parameters (Width and Height of the Graphics we will use) and then you can use x10p
; which will place the text at 10% of the width and y30p which is 30% of the height
; The same percentage marker may be used for width and height also, so w80p makes the bounding box of the rectangle the text
; will be written to 80% of the width of the graphics. If either is missed (as I have missed height) then the height of the bounding
; box will be made to be the height of the graphics, so 100%
; Any of the following words may be used also: Regular,Bold,Italic,BoldItalic,Underline,Strikeout to perform their associated action
; To justify the text any of the following may be used: Near,Left,Centre,Center,Far,Right with different spelling of words for convenience
; The rendering hint (the quality of the antialiasing of the text) can be specified with r, whose values may be:
; SystemDefault = 0
; SingleBitPerPixelGridFit = 1
; SingleBitPerPixel = 2
; AntiAliasGridFit = 3
; AntiAlias = 4
; The size can simply be specified with s
; The colour and opacity can be specified for the text also by specifying the ARGB as demonstrated with other functions such as the brush
; So cffff0000 would make a fully opaque red brush, so it is: cARGB (the literal letter c, follwed by the ARGB)
; The 4th parameter is the name of the font you wish to use
; As mentioned previously, you don not need to specify the last 2 parameters, the width and height, unless
; you are planning on using the p option with the x,y,w,h to use the percentage
Options = y25p Centre cFF000000 r4 s15 Bold
Gdip_TextToGraphics(G, "Instructions", Options, Font, Width, Height)
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd1, hdc, xOffset, yOffset, Width, Height)
; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui
OnMessage(0x201, "WM_LBUTTONDOWN")
; Select the object back into the hdc
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
Return hwnd1
}
MakeButton(GuiNumber, BorderColor, InnerColor, OwnerHwnd=0)
{
static xOffset, yOffset
if (OwnerHwnd)
{
WinGetPos, Cx, Cy, Cw, Ch, % "Ahk_id " OwnerHwnd
xOffset := Cx+Buttons[GuiNumber, "xOffset"]
yOffset := Cy+Buttons[GuiNumber, "yOffset"]
}
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
Width := 150, Height := 40
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
Gui, %GuiNumber%: +HwndHwnd1 -Caption +E0x80000 +LastFound +OwnDialogs
; Show the window
Gui, %GuiNumber%: Show, NA
if (OwnerHwnd)
Gui, %GuiNumber%: +Owner%OwnerHwnd%
; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
hbm := CreateDIBSection(Width, Height)
; Get a device context compatible with the screen
hdc := CreateCompatibleDC()
; Select the bitmap into the device context
obm := SelectObject(hdc, hbm)
; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromHDC(hdc)
; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)
; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
Outer_pBrush := Gdip_BrushCreateSolid(BorderColor)
pBrush := Gdip_BrushCreateSolid(InnerColor) ; 95B9C7
; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
Gdip_FillRoundedRectangle(G, Outer_pBrush, 0, 0, Width, Height, 6)
Gdip_FillRoundedRectangle(G, pBrush, 3, 3, Width-6, Height-6, 3)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)
; We can specify the font to use. Here we use Arial as most systems should have this installed
Font = Verdana
; Next we can check that the user actually has the font that we wish them to use
; If they do not then we can do something about it. I choose to give a wraning and exit!
If !Gdip_FontFamilyCreate(Font)
{
MsgBox, 48, Font error!, The font you have specified does not exist on the system
ExitApp
}
; There are a lot of things to cover with the function Gdip_TextToGraphics
; The 1st parameter is the graphics we wish to use (our canvas)
; The 2nd parameter is the text we wish to write. It can include new lines `n
; The 3rd parameter, the options are where all the action takes place...
; You can write literal x and y coordinates such as x20 y50 which would place the text at that position in pixels
; or you can include the last 2 parameters (Width and Height of the Graphics we will use) and then you can use x10p
; which will place the text at 10% of the width and y30p which is 30% of the height
; The same percentage marker may be used for width and height also, so w80p makes the bounding box of the rectangle the text
; will be written to 80% of the width of the graphics. If either is missed (as I have missed height) then the height of the bounding
; box will be made to be the height of the graphics, so 100%
; Any of the following words may be used also: Regular,Bold,Italic,BoldItalic,Underline,Strikeout to perform their associated action
; To justify the text any of the following may be used: Near,Left,Centre,Center,Far,Right with different spelling of words for convenience
; The rendering hint (the quality of the antialiasing of the text) can be specified with r, whose values may be:
; SystemDefault = 0
; SingleBitPerPixelGridFit = 1
; SingleBitPerPixel = 2
; AntiAliasGridFit = 3
; AntiAlias = 4
; The size can simply be specified with s
; The colour and opacity can be specified for the text also by specifying the ARGB as demonstrated with other functions such as the brush
; So cffff0000 would make a fully opaque red brush, so it is: cARGB (the literal letter c, follwed by the ARGB)
; The 4th parameter is the name of the font you wish to use
; As mentioned previously, you don not need to specify the last 2 parameters, the width and height, unless
; you are planning on using the p option with the x,y,w,h to use the percentage
Options = y25p Centre cFF000000 r4 s15 Bold
Gdip_TextToGraphics(G, Buttons[GuiNumber, "ButtonText"], Options, Font, Width, Height)
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd1, hdc, xOffset, yOffset, Width, Height)
; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui
OnMessage(0x201, "WM_LBUTTONDOWN")
; Select the object back into the hdc
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
Return Hwnd1
}
MakeChooseButton(GuiNumber, BorderColor, InnerColor, OwnerHwnd=0)
{
static xOffset, yOffset
if (OwnerHwnd)
{
WinGetPos, Cx, Cy, Cw, Ch, % "Ahk_id " OwnerHwnd
xOffset := Cx+Buttons[GuiNumber, "xOffset"]
yOffset := Cy+Buttons[GuiNumber, "yOffset"]
}
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
Width := 100, Height := 30
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
Gui, %GuiNumber%: +HwndHwnd1 -Caption +E0x80000 +LastFound +OwnDialogs
; Show the window
Gui, %GuiNumber%: Show, NA
if (OwnerHwnd)
Gui, %GuiNumber%: +Owner%OwnerHwnd%
; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
hbm := CreateDIBSection(Width, Height)
; Get a device context compatible with the screen
hdc := CreateCompatibleDC()
; Select the bitmap into the device context
obm := SelectObject(hdc, hbm)
; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromHDC(hdc)
; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)
; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
Outer_pBrush := Gdip_BrushCreateSolid(0xDD5599C7)
pBrush := Gdip_BrushCreateSolid(0xFFFFFFFF) ; 95B9C7
; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
Gdip_FillRoundedRectangle(G, Outer_pBrush, 0, 0, Width, Height, 6)
Gdip_FillRoundedRectangle(G, pBrush, 3, 3, Width-6, Height-6, 3)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)
; We can specify the font to use. Here we use Arial as most systems should have this installed
Font = Verdana
; Next we can check that the user actually has the font that we wish them to use
; If they do not then we can do something about it. I choose to give a wraning and exit!
If !Gdip_FontFamilyCreate(Font)
{
MsgBox, 48, Font error!, The font you have specified does not exist on the system
ExitApp
}
; There are a lot of things to cover with the function Gdip_TextToGraphics
; The 1st parameter is the graphics we wish to use (our canvas)
; The 2nd parameter is the text we wish to write. It can include new lines `n
; The 3rd parameter, the options are where all the action takes place...
; You can write literal x and y coordinates such as x20 y50 which would place the text at that position in pixels
; or you can include the last 2 parameters (Width and Height of the Graphics we will use) and then you can use x10p
; which will place the text at 10% of the width and y30p which is 30% of the height
; The same percentage marker may be used for width and height also, so w80p makes the bounding box of the rectangle the text
; will be written to 80% of the width of the graphics. If either is missed (as I have missed height) then the height of the bounding
; box will be made to be the height of the graphics, so 100%
; Any of the following words may be used also: Regular,Bold,Italic,BoldItalic,Underline,Strikeout to perform their associated action
; To justify the text any of the following may be used: Near,Left,Centre,Center,Far,Right with different spelling of words for convenience
; The rendering hint (the quality of the antialiasing of the text) can be specified with r, whose values may be:
; SystemDefault = 0
; SingleBitPerPixelGridFit = 1
; SingleBitPerPixel = 2
; AntiAliasGridFit = 3
; AntiAlias = 4
; The size can simply be specified with s
; The colour and opacity can be specified for the text also by specifying the ARGB as demonstrated with other functions such as the brush
; So cffff0000 would make a fully opaque red brush, so it is: cARGB (the literal letter c, follwed by the ARGB)
; The 4th parameter is the name of the font you wish to use
; As mentioned previously, you don not need to specify the last 2 parameters, the width and height, unless
; you are planning on using the p option with the x,y,w,h to use the percentage
Options = y25p Centre cFF000000 r4 s15 Bold
Gdip_TextToGraphics(G, "1|5", Options, Font, Width, Height)
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd1, hdc, xOffset, yOffset, Width, Height)
; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui
OnMessage(0x201, "WM_LBUTTONDOWN")
; Select the object back into the hdc
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
Return hwnd1
}
;#######################################################################
; This function is called every time the user clicks on the gui
; The PostMessage will act on the last found window (this being the gui that launched the subroutine, hence the last parameter not being needed)
WM_LBUTTONDOWN()
{
global colors
MouseGetPos,,, Winid
if (Buttons[Winid, "GuiName"] = "button1")
{
MakeButton(A_Gui, 0xDD . colors[4], 0xFF . colors[1], Buttons[Winid, "OwnerHwnd"])
turnOff(Winid)
gosub SubRoutine1
return
}
else if (Buttons[Winid, "GuiName"]= "button2")
{
MakeButton(A_Gui, 0xDD . colors[4], 0xFF . colors[1], Buttons[Winid, "OwnerHwnd"])
turnOff(Winid)
gosub SubRoutine2
return
}
else if (Buttons[Winid, "GuiName"]= "Choosebutton")
{
MakeButton(A_Gui, 0xDD . colors[4], 0xFF . colors[1], Buttons[Winid, "OwnerHwnd"])
turnOff(Winid)
gosub SubRoutine3
return
}
else if (Buttons[Winid, "GuiName"])
{
MakeButton(A_Gui, 0xDD . colors[4], 0xFF . colors[1], Buttons[Winid, "OwnerHwnd"])
return
}
if (A_gui = info[Winid, "GuiName"])
if info[Winid, "OwnerHwnd"]
PostMessage, 0xA1, 2,,, % "AHk_id " info[Winid, "OwnerHwnd"]
else
PostMessage, 0xA1, 2,,, % info[Winid, "GuiName"]
}
;#######################################################################
WM_WINDOWPOSCHANGING(wParam, lParam, msg, hwnd)
{
global ConsoleHwnd, SubmitHwnd, ChooseBHwnd, button1hWnd, button2hWnd
if (A_Gui = info[ConsoleHwnd, "OwnerName"]) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
x := NumGet(lParam+8), y := NumGet(lParam+12)
x += info[ConsoleHwnd, "Offset"], y += info[ConsoleHwnd, "Offset"]
Gui, % info[ConsoleHwnd, "GuiName"] . ": Show", X%x% Y%y% NA
}
else if (A_Gui = info[SubmitHwnd, "OwnerName"]) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
x := NumGet(lParam+8), y := NumGet(lParam+12)
;~ x += 20, y += 20
Gui, % info[SubmitHwnd, "GuiName"] . ": Show", X%x% Y%y% NA
}
else if (A_Gui = Buttons[ChooseBHwnd, "OwnerName"]) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
x := NumGet(lParam+8), y := NumGet(lParam+12)
x += Buttons[Buttons[ChooseBHwnd, "GuiName"], "xOffset"], y += Buttons[Buttons[ChooseBHwnd, "GuiName"], "yOffset"]
Gui, % Buttons[ChooseBHwnd, "GuiName"] . ": Show", X%x% Y%y% NA
}
else if (A_Gui = Buttons[Button1Hwnd, "OwnerName"]) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
x := NumGet(lParam+8), y := NumGet(lParam+12)
x += Buttons[Buttons[Button1Hwnd, "GuiName"], "xOffset"], y += Buttons[Buttons[Button1Hwnd, "GuiName"], "yOffset"]
Gui, % Buttons[Button1Hwnd, "GuiName"] . ": Show", X%x% Y%y% NA
}
else if (A_Gui = Buttons[Button2Hwnd, "OwnerName"]) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
x := NumGet(lParam+8), y := NumGet(lParam+12)
x += Buttons[Buttons[Button2Hwnd, "GuiName"], "xOffset"], y += Buttons[Buttons[Button2Hwnd, "GuiName"], "yOffset"]
Gui, % Buttons[Button2Hwnd, "GuiName"] . ": Show", X%x% Y%y% NA
}
}
;#######################################################################
TurnOff(hwnd)
{
global colors
static lastId
lastId := hWnd
SetTimer, State, 10
return
state:
if (GetKeyState("LButton", "P")=0)
{
SetTimer, State, off
MakeButton(Buttons[lastId, "GuiName"], 0xDD . colors[3], 0xFF . colors[2], Buttons[lastId, "OwnerHwnd"])
}
return
}
;~ keystate:
;~ if (GetKeyState("LButton", "P")=0)
;~ {
;~ MouseGetPos,,, Winid
;~ SetTimer, keyState, off
;~ MakeButton(Buttons[Winid, "GuiName"], 0xDD . colors[3], 0xFF . colors[2], Buttons[Winid, "OwnerHwnd"])
;~ }
;~ return
;#######################################################################
WM_MOUSEMOVE(wparam, lparam, msg, hwnd)
{
global ConsoleHwnd, OverButton, SubmitHwnd, colors, hCurs, sCurs
if (A_Gui = Buttons[hwnd, "GuiName"])
{
DllCall("SetCursor","UInt",hCurs)
if !(OverButton)
MakeButton(A_Gui, 0xDD . colors[3], 0xFF . colors[4], Buttons[Hwnd, "OwnerHwnd"])
OverButton := A_Gui
return
}
else if (A_Gui = info[ConsoleHwnd, "OwnerName"])
{
DllCall("SetCursor","UInt",sCurs)
return
}
else
{
if (OverButton)
MakeButton(OverButton, 0xDD . colors[3], 0xFF . colors[2])
OverButton := false
return
}
}
;#######################################################################
^Esc::
MainGuiClose:
Exit:
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
ExitApp
; save and submit rutine
SubRoutine1:
{
;~ msgbox % A_ThisLabel " and " VDvisible
if (VDvisible)
{
HideVideo(Video_Doc)
VDvisible := false
}
result := EvalCE(text := SciUtil_GetText(sci.hwnd))
if Errorlevel
ShowMsg("`nError!`nPlease try again!`n", 3000)
if (result = "")
;~ MsgBox MyError! not a AHk command
ShowMsg("Error! not a AHk command`nPlease try again!", 3000)
else if (result = 0) ; return from succesful command
{
;~ GuiControl, Console:, ConsoleEdit, Succes!
cCase := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/criteria/case").text
if (cCase = 1)
{
cSucces := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/criteria/succes").text
if RegExMatch(text, cSucces)
{
ShowMsg("`n Succes! `n")
sleep 3000
DestroyMsg()
}
else
{
ShowMsg("Error! not the right command`nPlease try again!", 3000)
return
}
}
lessonnumber++
if (lessonnumber > XmlObj.getElementsByTagName("lesson").length)
lessonnumber := 1
SetTimer, redo, -1000
}
else ; return result as string
{
;;;;; finde ud af hvordan et result er godt nok
GuiControl, Console:, ConsoleEdit, % result . "_"
settimer, Blink, 500
cCase := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/criteria/case").text
if (cCase = 1)
{
cRegEx := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/criteria/regex").text
if RegExMatch(result, cRegEx)
{
ShowMsg("`n Succes! `n")
sleep 3000
DestroyMsg()
}
else
{
ShowMsg("Error! not the right command`nPlease try again!", 3000)
return
}
}
if (cCase = 2)
{
if (StrLen(result) > XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/criteria/succes").text)
{
ShowMsg("`n " XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/criteria/text").text " " result " `n")
sleep 3000
DestroyMsg()
}
else
{
ShowMsg("Error! the string is to short`nPlease try again!", 3000)
return
}
}
lessonnumber++
if (lessonnumber > XmlObj.getElementsByTagName("lesson").length)
lessonnumber := 1
SetTimer, redo, -1000
;~ ControlSetText, Console:ConsoleEdit, % result
}
}
Return
SubRoutine2:
;~ msgbox % A_ThisLabel " and " VDvisible
settimer, Blink, off
;~ msgbox
if !(VDvisible)
{
ShowVideo(Video_Doc, html)
VDvisible := true
}
else
{
HideVideo(Video_Doc)
VDvisible := false
}
Return
SubRoutine3:
loop % XmlObj.getElementsByTagName("lesson").length
Menu, Choose, Add, % XmlObj.getElementsByTagName("lesson").item[A_index-1].selectSingleNode("lessonname").text, MenuHandler
Menu, Choose, Color, Silver
Menu, Choose, Show
return
MenuHandler:
;~ Msgbox % A_ThisMenuItem
lessonnumber := A_ThisMenuItemPos
;~ msgbox % lessonnumber
goto redo
return
Blink:
times++
if (times > 50)
SetTimer, Blink, off
Toggle := !Toggle
if Toggle
{
GuiControlGet, MyText, Console:, ConsoleEdit
MyText := RegExReplace(MyText, "_$")
}
else
{
GuiControlGet, MyText, Console:, ConsoleEdit
MyText .= "_"
}
GuiControl, Console:, ConsoleEdit, % Mytext
return
Pause::
Reload
return
ShowVideo(Video_Doc, html)
{
Video_doc.document.body.innerHTML := html
GuiControl, Console:Show, Video_doc
return true
}
HideVideo(Video_Doc, html="About:tabs")
{
Video_doc.document.body.innerHTML := html
;~ Video_Doc.parentwindow.Navigate("About:tabs")
GuiControl, Console:Hide, Video_doc
return true
}
EvalEE(string) ; Evaluates dynamic expression, Result -> ClipBoard or Errorlevel
{
Com=
(
autotrim blockinput clipwait control controlclick controlfocus controlget controlgetfocus
controlgetpos controlgettext controlmove controlsend controlsendraw controlsettext coordmode
critical detecthiddentext detecthiddenwindows drive driveget drivespacefree edit endrepeat envadd
envdiv envget envmult envset envsub envupdate fileappend filecopy filecopydir filecreatedir
filecreateshortcut filedelete filegetattrib filegetshortcut filegetsize filegettime filegetversion
fileinstall filemove filemovedir fileread filereadline filerecycle filerecycleempty fileremovedir
fileselectfile fileselectfolder filesetattrib filesettime formattime getkeystate groupactivate
groupadd groupclose groupdeactivate gui guicontrol guicontrolget hideautoitwin hotkey if ifequal
ifexist ifgreater ifgreaterorequal ifinstring ifless iflessorequal ifmsgbox ifnotequal ifnotexist
ifnotinstring ifwinactive ifwinexist ifwinnotactive ifwinnotexist imagesearch inidelete iniread
iniwrite input inputbox keyhistory keywait listhotkeys listlines listvars menu mouseclick
mouseclickdrag mousegetpos mousemove msgbox outputdebug pixelgetcolor pixelsearch postmessage
process progress random regdelete regread regwrite reload run runas runwait send sendevent
sendinput sendmessage sendmode sendplay sendraw setbatchlines setcapslockstate setcontroldelay
setdefaultmousespeed setenv setformat setkeydelay setmousedelay setnumlockstate setscrolllockstate
setstorecapslockmode settitlematchmode setwindelay setworkingdir shutdown sort soundbeep soundget
soundgetwavevolume soundplay soundset soundsetwavevolume splashimage splashtextoff splashtexton
splitpath statusbargettext statusbarwait stringcasesense stringgetpos stringleft stringlen
stringlower stringmid stringreplace stringright stringsplit stringtrimleft stringtrimright
stringupper sysget thread tooltip transform traytip urldownloadtofile winactivate winactivatebottom
winclose winget wingetactivestats wingetactivetitle wingetclass wingetpos wingettext wingettitle
winhide winkill winmaximize winmenuselectitem winminimize winminimizeall winminimizeallundo winmove
winrestore winset winsettitle winshow winwait winwaitactive winwaitclose winwaitnotactive
fileencoding
)
loop, parse, String, `n
laststring := A_LoopField
Prifix := RegExReplace(laststring, "^(\w+).*", "$1")
;~ msgbox %Com%||%prifix%||
if instr(Com, Prifix, 0)
Return execute(string)
else
return evaluate(string)
}
EvalCE(string) ; Evaluates dynamic expression, Result -> ClipBoard or Errorlevel
{
global XmlObj, lessonnumber, content
Com=
(
autotrim blockinput clipwait control controlclick controlfocus controlget controlgetfocus
controlgetpos controlgettext controlmove controlsend controlsendraw controlsettext coordmode
critical detecthiddentext detecthiddenwindows drive driveget drivespacefree edit endrepeat envadd
envdiv envget envmult envset envsub envupdate fileappend filecopy filecopydir filecreatedir
filecreateshortcut filedelete filegetattrib filegetshortcut filegetsize filegettime filegetversion
fileinstall filemove filemovedir fileread filereadline filerecycle filerecycleempty fileremovedir
fileselectfile fileselectfolder filesetattrib filesettime formattime getkeystate groupactivate
groupadd groupclose groupdeactivate gui guicontrol guicontrolget hideautoitwin hotkey if ifequal
ifexist ifgreater ifgreaterorequal ifinstring ifless iflessorequal ifmsgbox ifnotequal ifnotexist
ifnotinstring ifwinactive ifwinexist ifwinnotactive ifwinnotexist imagesearch inidelete iniread
iniwrite input inputbox keyhistory keywait listhotkeys listlines listvars menu mouseclick
mouseclickdrag mousegetpos mousemove msgbox outputdebug pixelgetcolor pixelsearch postmessage
process progress random regdelete regread regwrite reload run runas runwait send sendevent
sendinput sendmessage sendmode sendplay sendraw setbatchlines setcapslockstate setcontroldelay
setdefaultmousespeed setenv setformat setkeydelay setmousedelay setnumlockstate setscrolllockstate
setstorecapslockmode settitlematchmode setwindelay setworkingdir shutdown sort soundbeep soundget
soundgetwavevolume soundplay soundset soundsetwavevolume splashimage splashtextoff splashtexton
splitpath statusbargettext statusbarwait stringcasesense stringgetpos stringleft stringlen
stringlower stringmid stringreplace stringright stringsplit stringtrimleft stringtrimright
stringupper sysget thread tooltip transform traytip urldownloadtofile winactivate winactivatebottom
winclose winget wingetactivestats wingetactivetitle wingetclass wingetpos wingettext wingettitle
winhide winkill winmaximize winmenuselectitem winminimize winminimizeall winminimizeallundo winmove
winrestore winset winsettitle winshow winwait winwaitactive winwaitclose winwaitnotactive
fileencoding
)
ifExist $temp$.ahk
{
FileDelete $temp$.ahk
if ErrorLevel
return
}
; Remove comments, both ';' type and '/**/' type, from text.
rstring := RegexReplace( RegexReplace( string, "(?:^|\s+);\V*" ), "sm)^\h*/\*.*?`n\h*\*/" )
;~ msgbox |%rString%|
insertcode := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/code/insertcode").text
appendcode := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/code/appendcode").text
loop, parse, rString, `n
if (A_LoopField != "")
laststring := A_LoopField
Prefix := RegExReplace(laststring, "^(\w+).*", "$1")
if instr(Com, Prefix, 0) or instr(rString, "::")
{
content = #NoTrayIcon`n%insertcode%`n%rString%`n%appendcode%`nExitApp
FileAppend, %content% , $temp$.ahk
RunWait $temp$.ahk,, UseErrorLevel ; Run AHK to execute temp script
Return %ErrorLevel%
}
else
{
rString := RegExReplace(rString, "`n")
content = #NoTrayIcon`n%insertcode%`nClipBoard:=%rString%`n%appendcode%
FileAppend, %content%, $temp$.ahk
RunWait $temp$.ahk,, UseErrorLevel ; Run AHK to execute temp script
if Errorlevel
{
ErrorLevel := ErrorLevel
Return ""
}
else
return clipboard
}
}
; Evaluates any dynamic expression.
; On error, returns nothing and leaves ErrorLevel set.
evaluate(string)
{
global ahkPath
global tmpPath
ifExist %tmpPath%
{
FileDelete %tmpPath%
if ErrorLevel
return
}
FileAppend, ; Create temp script
(
#NoTrayIcon
x:=%string%
FileDelete %tmpPath%
FileAppend `%x`%, %tmpPath%
), %tmpPath%
if ErrorLevel
return
RunWait %ahkPath% %tmpPath%, , Min UseErrorLevel
if ErrorLevel
return
FileRead result, %tmpPath%
if ErrorLevel
return
FileDelete %tmpPath%
Return result
}
; Executes any dynamic script.
; On error, returns nothing and leaves ErrorLevel set.
; The second, optional parameter says whether to wait for it to
; finish executing or not.
; If not, the script must delete itself, and no value is returned.
; This is the default.
; Otherwise, if the script places anything into %outputString%,
; %outputString% is be returned.
; Otherwise, ErrorLevel will be returned.
execute(string, waitForExec=0)
{
global ahkPath
global tmpPath
ifExist %tmpPath%
{
FileDelete %tmpPath%
if ErrorLevel
return
}
FileAppend, ; Create temp script
(
#NoTrayIcon
%string%
FileDelete %tmpPath%
if `%outputString`%
FileAppend `%outputString`%, %tmpPath%
else
FileAppend ErrorLevel, %tmpPath%
), %tmpPath%
if ErrorLevel
return
if %waitForExec%
{
RunWait %ahkPath% %tmpPath%, , Min UseErrorLevel
if ErrorLevel
return 0
FileRead result, %tmpPath%
if ErrorLevel
return 0
FileDelete %tmpPath%
Return result
}
else
Run %ahkPath% %tmpPath%, , Min UseErrorLevel
}
Set_scite_Vars:
; Command list
Dir=
(
#allowsamelinecomments #clipboardtimeout #commentflag #errorstdout #escapechar #hotkeyinterval
#hotkeymodifiertimeout #hotstring #if #iftimeout #ifwinactive #ifwinexist #include #includeagain
#installkeybdhook #installmousehook #keyhistory #ltrim #maxhotkeysperinterval #maxmem #maxthreads
#maxthreadsbuffer #maxthreadsperhotkey #menumaskkey #noenv #notrayicon #persistent #singleinstance
#usehook #warn #winactivateforce
)
Com=
(
autotrim blockinput clipwait control controlclick controlfocus controlget controlgetfocus
controlgetpos controlgettext controlmove controlsend controlsendraw controlsettext coordmode
critical detecthiddentext detecthiddenwindows drive driveget drivespacefree edit endrepeat envadd
envdiv envget envmult envset envsub envupdate fileappend filecopy filecopydir filecreatedir
filecreateshortcut filedelete filegetattrib filegetshortcut filegetsize filegettime filegetversion
fileinstall filemove filemovedir fileread filereadline filerecycle filerecycleempty fileremovedir
fileselectfile fileselectfolder filesetattrib filesettime formattime getkeystate groupactivate
groupadd groupclose groupdeactivate gui guicontrol guicontrolget hideautoitwin hotkey if ifequal
ifexist ifgreater ifgreaterorequal ifinstring ifless iflessorequal ifmsgbox ifnotequal ifnotexist
ifnotinstring ifwinactive ifwinexist ifwinnotactive ifwinnotexist imagesearch inidelete iniread
iniwrite input inputbox keyhistory keywait listhotkeys listlines listvars menu mouseclick
mouseclickdrag mousegetpos mousemove msgbox outputdebug pixelgetcolor pixelsearch postmessage
process progress random regdelete regread regwrite reload run runas runwait send sendevent
sendinput sendmessage sendmode sendplay sendraw setbatchlines setcapslockstate setcontroldelay
setdefaultmousespeed setenv setformat setkeydelay setmousedelay setnumlockstate setscrolllockstate
setstorecapslockmode settitlematchmode setwindelay setworkingdir shutdown sort soundbeep soundget
soundgetwavevolume soundplay soundset soundsetwavevolume splashimage splashtextoff splashtexton
splitpath statusbargettext statusbarwait stringcasesense stringgetpos stringleft stringlen
stringlower stringmid stringreplace stringright stringsplit stringtrimleft stringtrimright
stringupper sysget thread tooltip transform traytip urldownloadtofile winactivate winactivatebottom
winclose winget wingetactivestats wingetactivetitle wingetclass wingetpos wingettext wingettitle
winhide winkill winmaximize winmenuselectitem winminimize winminimizeall winminimizeallundo winmove
winrestore winset winsettitle winshow winwait winwaitactive winwaitclose winwaitnotactive
fileencoding
)
Param=
(
ltrim rtrim join ahk_id ahk_pid ahk_class ahk_group processname minmax controllist statuscd
filesystem setlabel alwaysontop mainwindow nomainwindow useerrorlevel altsubmit hscroll vscroll
imagelist wantctrla wantf2 vis visfirst wantreturn backgroundtrans minimizebox maximizebox
sysmenu toolwindow exstyle check3 checkedgray readonly notab lastfound lastfoundexist alttab
shiftalttab alttabmenu alttabandmenu alttabmenudismiss controllisthwnd hwnd deref pow bitnot
bitand bitor bitxor bitshiftleft bitshiftright sendandmouse mousemove mousemoveoff
hkey_local_machine hkey_users hkey_current_user hkey_classes_root hkey_current_config hklm hku
hkcu hkcr hkcc reg_sz reg_expand_sz reg_multi_sz reg_dword reg_qword reg_binary reg_link
reg_resource_list reg_full_resource_descriptor caret reg_resource_requirements_list
reg_dword_big_endian regex pixel mouse screen relative rgb low belownormal normal abovenormal
high realtime between contains in is integer float number digit xdigit alpha upper lower alnum
time date not or and topmost top bottom transparent transcolor redraw region id idlast count
list capacity eject lock unlock label serial type status seconds minutes hours days read parse
logoff close error single shutdown menu exit reload tray add rename check uncheck togglecheck
enable disable toggleenable default nodefault standard nostandard color delete deleteall icon
noicon tip click show edit progress hotkey text picture pic groupbox button checkbox radio
dropdownlist ddl combobox statusbar treeview listbox listview datetime monthcal updown slider
tab tab2 iconsmall tile report sortdesc nosort nosorthdr grid hdr autosize range xm ym ys xs xp
yp font resize owner submit nohide minimize maximize restore noactivate na cancel destroy
center margin owndialogs guiescape guiclose guisize guicontextmenu guidropfiles tabstop section
wrap border top bottom buttons expand first lines number uppercase lowercase limit password
multi group background bold italic strike underline norm theme caption delimiter flash style
checked password hidden left right center section move focus hide choose choosestring text pos
enabled disabled visible notimers interrupt priority waitclose unicode tocodepage fromcodepage
yes no ok cancel abort retry ignore force on off all send wanttab monitorcount monitorprimary
monitorname monitorworkarea pid base useunsetlocal useunsetglobal localsameasglobal str astr wstr
int64 int short char uint64 uint ushort uchar float double int64p intp shortp charp uint64p uintp
ushortp ucharp floatp doublep ptr
)
Flow=
(
break continue else exit exitapp gosub goto loop onexit pause repeat return settimer sleep
suspend static global local byref while until for
)
Fun=
(
abs acos asc asin atan ceil chr cos dllcall exp fileexist floor getkeystate numget numput
registercallback il_add il_create il_destroy instr islabel isfunc ln log lv_add lv_delete
lv_deletecol lv_getcount lv_getnext lv_gettext lv_insert lv_insertcol lv_modify lv_modifycol
lv_setimagelist mod onmessage round regexmatch regexreplace sb_seticon sb_setparts sb_settext
sin sqrt strlen substr tan tv_add tv_delete tv_getchild tv_getcount tv_getnext tv_get tv_getparent
tv_getprev tv_getselection tv_gettext tv_modify varsetcapacity winactive winexist trim ltrim rtrim
fileopen strget strput object isobject objinsert objremove objminindex objmaxindex objsetcapacity
objgetcapacity objgetaddress objnewenum objaddref objrelease objclone _insert _remove _minindex
_maxindex _setcapacity _getcapacity _getaddress _newenum _addref _release _clone comobjcreate
comobjget comobjconnect comobjerror comobjactive comobjenwrap comobjunwrap comobjparameter
comobjmissing comobjtype comobjvalue comobjarray
)
BIVar=
(
a_ahkpath a_ahkversion a_appdata a_appdatacommon a_autotrim a_batchlines a_caretx a_carety
a_computername a_controldelay a_cursor a_dd a_ddd a_dddd a_defaultmousespeed a_desktop
a_desktopcommon a_detecthiddentext a_detecthiddenwindows a_endchar a_eventinfo a_exitreason
a_formatfloat a_formatinteger a_gui a_guievent a_guicontrol a_guicontrolevent a_guiheight
a_guiwidth a_guix a_guiy a_hour a_iconfile a_iconhidden a_iconnumber a_icontip a_index a_ipaddress1
a_ipaddress2 a_ipaddress3 a_ipaddress4 a_isadmin a_iscompiled a_issuspended a_keydelay a_language
a_lasterror a_linefile a_linenumber a_loopfield a_loopfileattrib a_loopfiledir a_loopfileext
a_loopfilefullpath a_loopfilelongpath a_loopfilename a_loopfileshortname a_loopfileshortpath
a_loopfilesize a_loopfilesizekb a_loopfilesizemb a_loopfiletimeaccessed a_loopfiletimecreated
a_loopfiletimemodified a_loopreadline a_loopregkey a_loopregname a_loopregsubkey
a_loopregtimemodified a_loopregtype a_mday a_min a_mm a_mmm a_mmmm a_mon a_mousedelay a_msec
a_mydocuments a_now a_nowutc a_numbatchlines a_ostype a_osversion a_priorhotkey a_programfiles
a_programs a_programscommon a_screenheight a_screenwidth a_scriptdir a_scriptfullpath a_scriptname
a_sec a_space a_startmenu a_startmenucommon a_startup a_startupcommon a_stringcasesense a_tab a_temp
a_thishotkey a_thismenu a_thismenuitem a_thismenuitempos a_tickcount a_timeidle a_timeidlephysical
a_timesincepriorhotkey a_timesincethishotkey a_titlematchmode a_titlematchmodespeed a_username
a_wday a_windelay a_windir a_workingdir a_yday a_year a_yweek a_yyyy clipboard clipboardall comspec
programfiles a_thisfunc a_thislabel a_ispaused a_iscritical a_isunicode a_ptrsize errorlevel
true false
)
Keys=
(
shift lshift rshift alt lalt ralt control lcontrol rcontrol ctrl lctrl rctrl lwin rwin appskey
altdown altup shiftdown shiftup ctrldown ctrlup lwindown lwinup rwindown rwinup lbutton rbutton
mbutton wheelup wheeldown xbutton1 xbutton2 joy1 joy2 joy3 joy4 joy5 joy6 joy7 joy8 joy9 joy10 joy11
joy12 joy13 joy14 joy15 joy16 joy17 joy18 joy19 joy20 joy21 joy22 joy23 joy24 joy25 joy26 joy27
joy28 joy29 joy30 joy31 joy32 joyx joyy joyz joyr joyu joyv joypov joyname joybuttons joyaxes
joyinfo space tab enter escape esc backspace bs delete del insert ins pgup pgdn home end up down
left right printscreen ctrlbreak pause scrolllock capslock numlock numpad0 numpad1 numpad2 numpad3
numpad4 numpad5 numpad6 numpad7 numpad8 numpad9 numpadmult numpadadd numpadsub numpaddiv numpaddot
numpaddel numpadins numpadclear numpadup numpaddown numpadleft numpadright numpadhome numpadend
numpadpgup numpadpgdn numpadenter f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
f20 f21 f22 f23 f24 browser_back browser_forward browser_refresh browser_stop browser_search
browser_favorites browser_home volume_mute volume_down volume_up media_next media_prev media_stop
media_play_pause launch_mail launch_media launch_app1 launch_app2 blind click raw wheelleft
wheelright
)
UD1 =
UD2 =
return
SetStyle2:
{
; ======================================================================================================================
; Set Style Colors =====================================================================================================
; ======================================================================================================================
sci.StyleSetFore(SCE_AHKL_IDENTIFIER , 0xDCD3CE) ;000000)
sci.StyleSetFore(SCE_AHKL_COMMENTDOC , 0x008888)
sci.StyleSetFore(SCE_AHKL_COMMENTLINE , 0x008800)
sci.StyleSetFore(SCE_AHKL_COMMENTBLOCK , 0x008800), sci.StyleSetBold(SCE_AHKL_COMMENTBLOCK, true)
sci.StyleSetFore(SCE_AHKL_COMMENTKEYWORD , 0xA50000), sci.StyleSetBold(SCE_AHKL_COMMENTKEYWORD, true)
sci.StyleSetFore(SCE_AHKL_STRING , 0xE3E658 ) ; A2A2A2 --> e3e658
sci.StyleSetFore(SCE_AHKL_STRINGOPTS , 0x00E658)
sci.StyleSetFore(SCE_AHKL_STRINGBLOCK , 0xE3E658), sci.StyleSetBold(SCE_AHKL_STRINGBLOCK, true)
sci.StyleSetFore(SCE_AHKL_STRINGCOMMENT , 0xFF0000)
sci.StyleSetFore(SCE_AHKL_LABEL , 0x0000DD)
sci.StyleSetFore(SCE_AHKL_HOTKEY , 0x00AADD)
sci.StyleSetFore(SCE_AHKL_HOTSTRING , 0x00BBBB)
sci.StyleSetFore(SCE_AHKL_HOTSTRINGOPT , 0x990099)
sci.StyleSetFore(SCE_AHKL_HEXNUMBER , 0x880088)
sci.StyleSetFore(SCE_AHKL_DECNUMBER , 0xFF9000)
sci.StyleSetFore(SCE_AHKL_VAR , 0xCC8870) ; FF9000)
sci.StyleSetFore(SCE_AHKL_VARREF , 0x990055)
sci.StyleSetFore(SCE_AHKL_OBJECT , 0x008888)
sci.StyleSetFore(SCE_AHKL_USERFUNCTION , 0x0000DD)
sci.StyleSetFore(SCE_AHKL_DIRECTIVE , 0x4A0000), sci.StyleSetBold(SCE_AHKL_DIRECTIVE, true)
sci.StyleSetFore(SCE_AHKL_COMMAND , 0x0355fa), sci.StyleSetBold(SCE_AHKL_COMMAND, true) ; 0000DD)
sci.StyleSetFore(SCE_AHKL_PARAM , 0x0085DD)
sci.StyleSetFore(SCE_AHKL_CONTROLFLOW , 0xe500e5) ;0000DD)
sci.StyleSetFore(SCE_AHKL_BUILTINFUNCTION, 0xaaaaee) ; 444444) ;fbb3f3) ;DD00DD)
sci.StyleSetFore(SCE_AHKL_BUILTINVAR , 0xEE3010), sci.StyleSetBold(SCE_AHKL_BUILTINVAR, true)
sci.StyleSetFore(SCE_AHKL_KEY , 0xE3E658), sci.StyleSetBold(SCE_AHKL_KEY, true), sci.StyleSetItalic(SCE_AHKL_KEY, true) ; A2A2A2
sci.StyleSetFore(SCE_AHKL_USERDEFINED1 , 0x000000)
sci.StyleSetFore(SCE_AHKL_USERDEFINED2 , 0x000000)
sci.StyleSetFore(SCE_AHKL_ESCAPESEQ , 0x660000), sci.StyleSetItalic(SCE_AHKL_ESCAPESEQ, true)
sci.StyleSetFore(SCE_AHKL_ERROR , 0xFF0000)
return
}
SetStyle:
{
; ======================================================================================================================
; Set Style Colors =====================================================================================================
; ======================================================================================================================
sci.SetMarginWidthN(0,"30")
sci.StyleSetFore(STYLE_LINENUMBER, 0x232C31), sci.StyleSetBold(STYLE_LINENUMBER, false)
sci.StyleSetFore(SCE_AHKL_IDENTIFIER , 0xDCD3CE) ;000000)
sci.StyleSetFore(SCE_AHKL_COMMENTDOC , 0x008888)
sci.StyleSetFore(SCE_AHKL_COMMENTLINE , 0x008800)
sci.StyleSetFore(SCE_AHKL_COMMENTBLOCK , 0x008800), sci.StyleSetBold(SCE_AHKL_COMMENTBLOCK, true)
sci.StyleSetFore(SCE_AHKL_COMMENTKEYWORD , 0xA50000), sci.StyleSetBold(SCE_AHKL_COMMENTKEYWORD, true)
sci.StyleSetFore(SCE_AHKL_STRING , 0xE3E658 ) ; A2A2A2 --> e3e658
sci.StyleSetFore(SCE_AHKL_STRINGOPTS , 0x00E658)
sci.StyleSetFore(SCE_AHKL_STRINGBLOCK , 0xE3E658), sci.StyleSetBold(SCE_AHKL_STRINGBLOCK, true)
sci.StyleSetFore(SCE_AHKL_STRINGCOMMENT , 0xFF0000)
sci.StyleSetFore(SCE_AHKL_LABEL , 0x0000DD)
sci.StyleSetFore(SCE_AHKL_HOTKEY , 0x00AADD)
sci.StyleSetFore(SCE_AHKL_HOTSTRING , 0x00BBBB)
sci.StyleSetFore(SCE_AHKL_HOTSTRINGOPT , 0x990099)
sci.StyleSetFore(SCE_AHKL_HEXNUMBER , 0x880088)
sci.StyleSetFore(SCE_AHKL_DECNUMBER , 0xFF9000)
sci.StyleSetFore(SCE_AHKL_VAR , 0xCC8870) ; FF9000)
sci.StyleSetFore(SCE_AHKL_VARREF , 0x990055)
sci.StyleSetFore(SCE_AHKL_OBJECT , 0x008888)
sci.StyleSetFore(SCE_AHKL_USERFUNCTION , 0x0000DD)
sci.StyleSetFore(SCE_AHKL_DIRECTIVE , 0x4A0000), sci.StyleSetBold(SCE_AHKL_DIRECTIVE, true)
sci.StyleSetFore(SCE_AHKL_COMMAND , 0x0355fa), sci.StyleSetBold(SCE_AHKL_COMMAND, true) ; 0000DD)
sci.StyleSetFore(SCE_AHKL_PARAM , 0x0085DD)
sci.StyleSetFore(SCE_AHKL_CONTROLFLOW , 0xe500e5) ;0000DD)
sci.StyleSetFore(SCE_AHKL_BUILTINFUNCTION, 0xaaaaee) ; 444444) ;fbb3f3) ;DD00DD)
sci.StyleSetFore(SCE_AHKL_BUILTINVAR , 0xEE3010), sci.StyleSetBold(SCE_AHKL_BUILTINVAR, true)
sci.StyleSetFore(SCE_AHKL_KEY , 0xE3E658), sci.StyleSetBold(SCE_AHKL_KEY, true), sci.StyleSetItalic(SCE_AHKL_KEY, true) ; A2A2A2
sci.StyleSetFore(SCE_AHKL_USERDEFINED1 , 0x000000)
sci.StyleSetFore(SCE_AHKL_USERDEFINED2 , 0x000000)
sci.StyleSetFore(SCE_AHKL_ESCAPESEQ , 0x660000), sci.StyleSetItalic(SCE_AHKL_ESCAPESEQ, true)
sci.StyleSetFore(SCE_AHKL_ERROR , 0xFF0000)
return
}
; ======================================================================================================================
; SCI Functions ========================================================================================================
; ======================================================================================================================
SCI_SetFont(HSCI, FontName, Size := 9) {
SCI_STYLESETFONT(HSCI, 32, FontName)
SCI_STYLESETSIZE(HSCI, 32, Size)
}
; ----------------------------------------------------------------------------------------------------------------------
SCI_SetLineNumbers(HSCI, NumStr := "_99999") {
Return SCI_SETMARGINWIDTHN(HSCI, 0, StrLen(NumStr) ? SCI_TEXTWIDTH(HSCI, 33, NumStr) : 0)
}
; ======================================================================================================================
; SCI Messages =========================================================================================================
; ======================================================================================================================
SCI_STYLESETFONT(HSCI, StyleIndex, FontName) {
; SCI_STYLESETFONT = 2056
Return DllCall("User32.dll\SendMessage", "Ptr", HSCI, "Int", 2056, "Ptr", StyleIndex, "AStr", FontName, "Int")
}
; ----------------------------------------------------------------------------------------------------------------------
SCI_STYLESETSIZE(HSCI, StyleIndex, Size) {
; SCI_STYLESETSIZE = 2055
Return DllCall("User32.dll\SendMessage", "Ptr", HSCI, "Int", 2055, "Ptr", StyleIndex, "Int", Size, "Int")
}
; ----------------------------------------------------------------------------------------------------------------------
SCI_SETMARGINWIDTHN(HSCI, MarginIndex, Width) {
; SCI_SETMARGINWIDTHN = 2242
Return DllCall("User32.dll\SendMessage", "Ptr", HSCI, "Int", 2242, "Ptr", MarginIndex, "Ptr", Width, "Int")
}
; ----------------------------------------------------------------------------------------------------------------------
SCI_TEXTWIDTH(HSCI, StyleIndex, String) {
; SCI_TEXTWIDTH = 2276
Return DllCall("User32.dll\SendMessage", "Ptr", HSCI, "Int", 2276, "Ptr", StyleIndex, "AStr", String, "Int")
}
SCI_Margin_Back(HSCI, Index, SC_Margin_Back=2)
{
Return DllCall("User32.dll\SendMessage", "Ptr", HSCI, "Int", 2240, "Ptr", Index, "Int", SC_Margin_Back, "Int")
}
;~ SendMessage hSci, %SCI_SetMarginTypeN, 1, %SC_Margin_Back
;~ SendMessage hSci, %SCI_SetMarginTypeN, 1, %SC_Margin_Fore
SetSciMargin(lSci, n0=40, n1=10)
{
lSci.SetMarginWidthN(0,n0),lSci.SetMarginWidthN(1,0),lSci.SetMarginWidthN(2,n1)
}
; This function handles the Click notifications and tells Scintilla to Fold/Unfold
SCI_NOTIFY(wParam, lParam, msg, hwnd, sciObj) {
line := sciObj.LineFromPosition(sciObj.position)
if (sciObj.scnCode = SCN_MARGINCLICK)
sciObj.ToggleFold(line)
}
loodxml(xmldata)
{
doc := ComObjCreate("MSXML2.DOMDocument.6.0")
doc.async := false
doc.loadXML(xmldata)
myErr := doc.parseError
if myErr.reason
msgbox % "You have error " myErr.reason " on line " myErr.line
else
return doc
}
; ============ Submit ============
SubmitGui(ownerHwnd)
{
global Sci, border, colors
;RegularButton.ahk - Readymade Code testing a Graphical Button
Gui, Submit: New
Gui, Submit: +hwndHwnd -0xC40000 +ToolWindow +Owner%ownerHwnd%
Gui, Submit: Margin,0,0
Gui, Submit: Color, 232C31
WinSet, TransColor, 232C31, Ahk_id %Hwnd%
WinGetPos, Mx, My, Mw, Mh, % "Ahk_id " ownerHwnd
ControlGetPos, SciX, SciY, SciW, SciH,, % "AHk_id " Sci.hwnd
Sx := SciX-Border
Sy := SciY+SciH-Border
Sw := Mw-Sx
Sh := Mh-Sy
Gui, Submit: Show, x%Sx% y%Sy% w%Sw% h%Sh%, Submit
info[Hwnd, "GuiName"] := "Submit"
MakehatchBack(ownerHwnd, Hwnd, 20)
return Hwnd
}
; ============ LeftMain ============
LeftMainGui(ownerHwnd)
{
global Sci, Border, colors
Gui, LeftMain: New
Gui, LeftMain: +HwndHwnd -0xC40000 +ToolWindow +Owner%ownerHwnd%
Gui, LeftMain: Margin,0,0
Gui, LeftMain: Color, % colors[5]
WinGetPos, Mx, My, Mw, Mh, % "Ahk_id " ownerHwnd
ControlGetPos, SciX, SciY, SciW, SciH,, % "AHk_id " Sci.hwnd
LMx := Mx
LMy := SciY-Border
LMw := SciX
LMh := Mh-LMy
Gui, LeftMain: Show, x%LMx% y%LMy% w%LMw% h%LMh%, LeftMain
return Hwnd
}
; ============ Left Top ============
LeftTopGui(ownerHwnd)
{
global Sci, Border, colors
Gui, LeftTop: New
Gui, LeftTop: +HwndHwnd -0xC40000 +ToolWindow +Owner%ownerHwnd%
Gui, LeftTop: Margin,0,0
Gui, LeftTop: Color, % colors[4]
WinGetPos, Mx, My, Mw, Mh, % "Ahk_id " ownerHwnd
ControlGetPos, SciX, SciY, SciW, SciH,, % "AHk_id " Sci.hwnd
LTy := My-50
LTw := Mw
LTh := 50
Gui, LeftTop: Show, x%Mx% y%LTy% w%LTw% h%LTh%, LeftTop
return Hwnd
}
; ============ Main Top ============
MainTopGui(OwnerHwnd)
{
global Sci, Border, colors, LTy
static TopText, TopText2
Gui, MainTop: New
Gui, MainTop: +HwndHwnd -0xC40000 +ToolWindow +Owner%OwnerHwnd%
Gui, MainTop: Margin,0,0
Gui, MainTop: Color, 212121
WinGetPos, Mx, My, Mw, Mh, % "Ahk_id " OwnerHwnd
ControlGetPos, SciX, SciY, SciW, SciH,, % "AHk_id " Sci.hwnd
MTx := SciX-Border
MTy := LTy
MTw := SciW
MTh := 50
Gui, MainTop: Font, % "s10 bold c" colors[3]
Gui, MainTop: Add, Text, +BackgroundTrans x20 y20 w100 h%MTh% vTopText, File:
;~ Gui, MainTop: Add, Progress, x70 y0 w100 h%MTh% w100 Background232C31 -Border
Gui, MainTop: Font, cwhite s10 bold, Verdana
Gui, MainTop: Add, Text, 0x5 x70 y0 w100 h%MTh%
Gui, MainTop: Add, Text, +BackgroundTrans x80 y20 w100 h%MTh% vTopText2, Script.ahk
Gui, MainTop: Show, x%MTx% y%MTy% w%MTw% h%MTh%, MainTop
return Hwnd
}
; ============ checkpoint ============
CheckpointGui(OwnerHwnd)
{
global Sci, XmlObj, Border, colors, lessonnumber
static checkpointHeader, checkpointInner
Gui, checkpoint: New
Gui, checkpoint: +HwndHwnd -0xC40000 +ToolWindow +Owner%OwnerHwnd%
Gui, checkpoint: Margin,0,0
Gui, checkpoint: Color, % colors[3]
WinGetPos, Mx, My, Mw, Mh, % "Ahk_id " OwnerHwnd
ControlGetPos, SciX, SciY, SciW, SciH,, % "AHk_id " Sci.hwnd
CPx := Mx
CPy := My
CPw := Mw
;~ CPh := LMh-250
CPTw := CPw-40
Gui, checkpoint: Font, cBlack s20 bold, Verdana
Gui, checkpoint: Add, Text, x20 y10 w%CPTw% vcheckpointHeader, % XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/checkpoint/header").text
Gui, checkpoint: Font, cBlack s10 bold, Verdana
Gui, checkpoint: Add, Text, x20 y80 w%CPTw% vcheckpointInner, % XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/checkpoint/content").text . "`n`n`n`n"
Gui, checkpoint: Show, x%CPx% y%CPy% w%CPw%, checkpoint
return Hwnd
}
; ============ Instructions ============
InstGui(OwnerHwnd)
{
global Sci, XmlObj, Border, colors, lessonnumber, LeftMainHwnd
static InstHeader, InstInner
Gui, Inst: New
Gui, Inst: +HwndHwnd -0xC40000 +ToolWindow +Owner%OwnerHwnd%
Gui, Inst: Margin,0,0
Gui, Inst: Color, % colors[2]
WinGetPos, CPx, CPy, CPw, CPh, % "Ahk_id " OwnerHwnd
WinGetPos, LMx, LMy, LMw, LMh, % "Ahk_id " LeftMainHwnd
ControlGetPos, SciX, SciY, SciW, SciH,, % "AHk_id " Sci.hwnd
CPTw := CPw-40
Ix := LMx
Iy := CPy+CPh
Iw := LMw
;~ Ih := 150
ITw := Iw-40
Gui, Inst: Font, cBlack s20, Verdana
Gui, Inst: Add, Text, x20 y20 w%Iw% vInstHeader, % XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/instructions/header").text
Gui, Inst: Font, cBlack s10 bold, Verdana
Gui, Inst: Add, Text, x20 y90 w%CPTw% vInstInner, % XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/instructions/content").text . "`n`n`n`n"
Gui, Inst: Show, x%Ix% y%Iy% w%Iw%, Instructions
MakeInstGui(LeftMainHwnd, Hwnd, 30)
return Hwnd
}
; ============ Console ============
ConsoleGui(OwnerHwnd)
{
global Sci, XmlObj, Border, colors, lessonnumber, Video_doc, ConsoleEdit, Html, Vd_visible
Gui, Console: New
Gui, Console: +HwndHwnd -0xC40000 +ToolWindow +Owner%OwnerHwnd%
Gui, Console: Color, Black
Gui, Console: Font, cWhite, Verdana
ControlGetPos, SciX, SciY, SciW, SciH,, % "AHk_id " Sci.hwnd
Cx := SciX+(SciW/2)
Cy := SciY-50
Cw := (SciW/2)-50
Ch := SciH-300
CEw := Cw-40
CEdw := Cw+50
CEdh := Ch+50
;~ Gui, Console: Add, ActiveX, x-10 y-15 w%CEdw% h%CEdh% vVideo_doc +hwndvdHwnd, HTMLFile
Gui, Console: Add, ActiveX, x-10 y-15 w%CEdw% h%CEdh% vVideo_doc +hwndvdHwnd, Shell.Explorer
Video_doc.silent := true
Video_doc.Navigate("about:blank")
Gui, Console: Add, Text, x1 y1 w%CEw% R20 vConsoleEdit, |
GuiControl, Console:hide, Video_doc
VDvisible := false
Gui, Console: Show, x%Cx% y%Cy% w%Cw% h%Ch%, Console
Src := XmlObj.selectSingleNode("//lesson[lessonnumber=" . lessonnumber . "]/video/youtubeid").text
;~ Cw := Floor(Cw), Ch := Floor(Ch)
;~ msgbox % Cw " and " Ch
;~ html =
;~ (
;~ <html><head></head><body bgcolor="Black">
;~ <embed width="%Cw%" height="%Ch%" src="%Src%" type="application/x-shockwave-flash">
;~ </body></html>
;~ )
;~ html =
;~ (
;~ <HTML><HEAD><TITLE></TITLE></HEAD><BODY topMargin=0 leftMargin=0 scroll=no>
;~ <OBJECT width="100`%" height="100`%"><param name="movie" value="http://www.youtube.com/embed/%src%"></param>
;~ <param name="allowFullScreen" value="true" />
;~ <EMBED width="100`%" height="100`%" src="http://www.youtube.com/embed/%src%" type="application/x-shockwave-flash" allowfullscreen="true">
;~ </EMBED></OBJECT></BODY></HTML>
;~ )
;~ html=
;~ (
;~ <!DOCTYPE html>
;~ <iframe width='%Cw%' height='%Ch%' src='http://www.youtube.com/embed/%src%' frameborder='0'>
;~ </iframe>
;~ )
Html =
(
<HTML>
<BODY topMargin=0 leftMargin=0 scroll=no>
<EMBED
width='%Cw%' height='%Ch%'
src="http://www.youtube.com/v/%src%&autoplay=1&fs=1"
type="application/x-shockwave-flash"
allowfullscreen="true">
</EMBED>
</BODY>
</HTML>
)
;~ msgbox % html
;~ Video_doc.body.innerHTML := html
info[Hwnd, "GuiName"] := "Console"
info[Hwnd, "Offset"] := 20
MakeGuipBack(OwnerHwnd, Hwnd, "ConsoleBorder")
return Hwnd
}
; function til at vise en besked på skærmen
ShowMsg(Text, Duration=3000) {
; splash Text
static Splash_GuiText
global Splash_Gui_Hwnd, colors
if WinExist("Ahk_id " Splash_Gui_Hwnd)
{
;~ loading(0)
DestroyMsg()
}
Gui, Splash_Gui: Margin, 0,0
Gui, Splash_Gui: Color, % colors[1]
Gui, Splash_Gui: Font, bold s20 , Verdana ; Preferred font.
Gui, Splash_Gui: +ToolWindow +AlwaysOnTop -Caption ; no title, no taskbar icon
Gui, Splash_Gui: Add, Text, x5 y5 vSplash_GuiText, %Text%
Gui, Splash_Gui: +HwndSplash_Gui_Hwnd
WinSet, Transparent, 240, ahk_id %Splash_Gui_Hwnd%
Gui, Splash_Gui: Show, NoActivate
If Duration
settimer, Destroy, -%Duration%
return
Destroy:
DestroyMsg()
return
}
; fjern en ShowMsg() besked
DestroyMsg() {
Gui, Splash_Gui: Destroy
}
StartGui()
{
global doc
WM_KEYDOWN = 0x100
GoSub, GetHTML
OnMessage(WM_KEYDOWN, "WM_KeyDown")
Gui Add, ActiveX, w350 h300 x0 y0 vdoc, HTMLFile
doc.write(html)
Gui, Show, w350 h300 Center, AHk Learner
ComObjConnect(doc, "Doc_")
return
GuiClose:
{
doc := ""
Gui, Destroy
ObjRelease(pipa)
ExitApp
}
GetHTML:
{
html =
(%` ; `%
<html>
<style type="text/css">
body {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, PowderBlue), color-stop(1, #E6E0B0) );
background:-moz-linear-gradient( center top, PowderBlue 5%, #7E6E0B0 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='PowderBlue', endColorstr='#E6E0B0');
background-color:PowderBlue;
}
.button {
-moz-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
-webkit-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
box-shadow:inset 0px 1px 0px 0px #bbdaf7;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5) );
background:-moz-linear-gradient( center top, #79bbff 5%, #378de5 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5');
background-color:#79bbff;
-webkit-border-top-left-radius:37px;
-moz-border-radius-topleft:37px;
border-top-left-radius:37px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:37px;
-moz-border-radius-bottomright:37px;
border-bottom-right-radius:37px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:0;
border:2px solid #84bbf3;
display:inline-block;
color:#ffffff;
font-family:Arial;
font-size:15px;
font-weight:bold;
font-style:normal;
height:65px;
line-height:65px;
width:131px;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #528ecc;
}
.button:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff) );
background:-moz-linear-gradient( center top, #378de5 5%, #79bbff 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff');
background-color:#378de5;
}.button:active {
position:relative;
top:1px;
}</style>
<body style='background-color:PowderBlue;overflow:auto'>
<center><H3><b>AHk interactive tutorial</b></H3>
<a href="#" id="startButton" class="button">start tutorial</a></center>
</br></br></br></br>
Tutorial Color Style: <select id='color'>
<option value='cyan'>cyan</option>
<option value='GandB'>green and blue</option>
<option value='green'>green</option>
<option value='Dblue'>Deep blue</option>
</select>
</body>
</html>
)
return
}
}
Doc_OnClick(doc) {
global cStyle
id := doc.parentWindow.event.srcElement.id
if (id = "startButton")
{
cStyle := doc.getelementbyid("color").selectedIndex
gui, Destroy
SetTimer, start, -10
}
}
WM_KEYDOWN(wParam, lParam, nMsg, hWnd) {
global doc
static fields := "hWnd,nMsg,wParam,lParam,A_EventInfo,A_GuiX,A_GuiY"
WinGetClass, ClassName, ahk_id %hWnd%
if (ClassName = "Internet Explorer_Server") {
; http://www.autohotkey.com/community/viewtopic.php?p=562260#p562260
pipa := ComObjQuery(doc, "{00000117-0000-0000-C000-000000000046}")
VarSetCapacity(kMsg, 48)
Loop Parse, fields, `,
NumPut(%A_LoopField%, kMsg, (A_Index-1)*A_PtrSize)
; Loop 2 ; only necessary for Shell.Explorer Object
r := DllCall(NumGet(NumGet(1*pipa)+5*A_PtrSize), "ptr",pipa, "ptr",&kMsg)
; until wParam != 9 || doc.activeElement != ""
ObjRelease(pipa)
if r = 0 ; S_OK: the message was translated to an accelerator.
return 0
}
}
#Include res\Gdip.ahk
#Include res\sciUtil.ahk
#Include res\RemoteBuf.ahk
Best
BlackHolyMan