First GUI
Code: Select all
#SingleInstance force
#NoEnv
MyTitle := "Left"
MyMessage := "Loading, Please wait..."
PleasantNotify(MyTitle, MyMessage , 600, 210, "vc hc", "15")
return
PleasantNotify(title, message, pnW=700, pnH=300, position="b r", time=10) {
global pn_title, pn_msg, PN_hwnd, w, h
Notify_Destroy()
Gui, Notify: +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
PN_hwnd := WinExist()
WinSet, ExStyle, +0x20
WinSet, Transparent, 0
Gui, Notify: Color, 0xF2F2F0
Gui, Notify: Font, c0x07D82F s18 wBold, Segoe UI
Gui, Notify: Add, Text, % " x" 20 " y" 12 " w" pnW-20 " vpn_title", % title
Gui, Notify: Font, cBlack s15 wRegular
Gui, Notify: Add, Text, % " x" 20 " y" 56 " w" pnW-20 " h" pnH-56 " vpn_msg", % message
RealW := pnW + 50
RealH := pnH + 20
;;; Second GUI position here
;;;
Gui, Notify: Show, W%RealW% H%RealH% NoActivate
WinMove(PN_hwnd, position)
if A_ScreenDPI = 96
WinSet, Region,0-0 w%pnW% h%pnH% R40-40,%A_ScriptName%
/* For Screen text size 125%
if A_ScreenDPI = 120
WinSet, Region, 0-0 w800 h230 R40-40, %A_ScriptName%
*/
winfade("ahk_id " PN_hwnd,210,5)
if (time <> "P")
{
Closetick := time*1000
SetTimer, ByeNotify, % Closetick
}
}
Notify_Destroy() {
global PN_hwnd
ByeNotify:
SetTimer, ByeNotify, Off
winfade("ahk_id " PN_hwnd,0,5)
Gui, Notify: Destroy
return
}
pn_mod_title(title) {
global pn_title
GuiControl, Notify: Text,pn_title, % title
}
pn_mod_msg(message) {
global pn_msg
GuiControl, Notify: Text,pn_msg, % message
}
WinMove(hwnd,position) {
SysGet, Mon, MonitorWorkArea
WinGetPos,ix,iy,w,h, ahk_id %hwnd%
x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ? (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
y := InStr(position,"t") ? MonTop : InStr(position,"vc") ? (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
WinMove, ahk_id %hwnd%,,x,y
}
winfade(w:="",t:=128,i:=1,d:=10) {
w:=(w="")?("ahk_id " WinActive("A")):w
t:=(t>255)?255:(t<0)?0:t
WinGet,s,Transparent,%w%
s:=(s="")?255:s ;prevent trans unset bug
WinSet,Transparent,%s%,%w%
i:=(s<t)?abs(i):-1*abs(i)
while(k:=(i<0)?(s>t):(s<t)&&WinExist(w)) {
WinGet,s,Transparent,%w%
s+=i
WinSet,Transparent,%s%,%w%
sleep %d%
}
}
Code: Select all
;; # -*- coding: utf-8 -*-
;activex gui 2 - test joedf - 2014/09/19
#SingleInstance, off
OnExit,OnExit
HTML_page =
( Ltrim Join
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' charset='UTF-8'>
<style>
@charset "utf-8";
body{font-family:sans-serif;background-color:#1A1A1A;color:white}
#title{font-size:36px;}
input{margin:4px;Border: 2px white solid;background-color:black;color:white;}
p{font-size:16px;border:solid 1px #666;padding:4px;}
#footer{text-align:center;}
</style>
</head>
<body>
<div id="MyTextBox" charset="UTF-8">1234567890-=\ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$^&*()_+|~</div>
<p id="footer">
<input type="button" id="MyButton2" value="Change Content with AHK">
<input type="button" id="MyButton3" value="Greetings from AHK">
</p>
</body>
</html>
)
Gui Add, ActiveX, x0 y0 w640 h480 vWB, Shell.Explorer ; The final parameter is the name of the ActiveX component.
WB.silent := true ;Surpress JS Error boxes
Display(WB,HTML_page)
;Wait for IE to load the page, before we connect the event handlers
while WB.readystate != 4 or WB.busy
sleep 10
;Use DOM access just like javascript!
MyButton1 := wb.document.getElementById("MyButton1")
MyButton2 := wb.document.getElementById("MyButton2")
MyButton3 := wb.document.getElementById("MyButton3")
ComObjConnect(MyButton2, "MyButton2_")
ComObjConnect(MyButton3, "MyButton3_")
Gui Show, w640 h480
return
GuiClose:
ExitApp
OnExit:
FileDelete,%A_Temp%\*.DELETEME.html ;clean tmp file
ExitApp
; Our Event Handlers
MyButton2_OnClick() {
global wb
data := "מִבְחָן"
wb.Document.getElementById("MyTextBox").innerHtml := data
}
MyButton3_OnClick() {
MyUTF8 := "שלום"
MsgBox, % MyUTF8
}
;------------------
Display(WB,html_str) {
Count:=0
while % FileExist(f:=A_Temp "\" A_TickCount A_NowUTC "-tmp" Count ".DELETEME.html")
Count+=1
FileAppend,%html_str%,%f%
WB.Navigate("file://" . f)
}