 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
codybear
Joined: 15 Sep 2009 Posts: 560
|
Posted: Wed Jul 14, 2010 10:37 pm Post subject: |
|
|
| SKAN wrote: | Thanks to everybody for the nice words.
I thank Sean... if not for his IE webcontrol code, this function would never exist.
| codybear wrote: | | using CSS to hide the vertical and horizontal scroll-bars |
Neat!. Thank you very much.  |
Woo, I helped SKAN.
This day will go down in history.  |
|
| Back to top |
|
 |
fincs
Joined: 05 May 2007 Posts: 1163 Location: Seville, Spain
|
Posted: Thu Jul 15, 2010 10:40 am Post subject: |
|
|
This script is awesome. BTW, I've given it a little bit of Unicode love (it was pretty easy to make it work with both versions):
| Code: | ; _ _ _____ _
; HtmDlg() - HTML DialogBox v0.51 | | | |_ (____ \ | | v0.51
; | |__ | | |_ ____ _ \ \| | ____
; Suresh Kumar A N (arian.suresh@gmail.com) | __)| | _)| \| | | | |/ _ |
; | | | | |__| | | | |__/ /| ( ( | |
; Created : 09-Jul-2010 |_| |_|\___)_|_|_|_____/ |_|\_|| |
; Last Mod : 13-Jul-2010 (_____|
;
; Usage : HtmDlg( URL, hwndOwner, Options, OptionsDelimiter )
; : For Options, please refer the bottom of this script
;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HtmDlg( _URL="", _Owner=0, _Options="", _ODL="," ) {
; HTML DialogBox v0.50 - scripted by SKAN : www.autohotkey.com/forum/viewtopic.php?t=60215
static _Ins, _hDLG, _DlgT, _DlgP, _STRU, _pIWEB, _pV, BDef=1, BEsc=0
If ( A_EventInfo = 0xCBF ) { ; nested CallBackFunction
hWnd := _URL, uMsg := _Owner, wP := _Options, lP := _ODL
If ( uMsg=0x112 && wP=0xF060 ) ; WM_SYSCOMMAND && SC_ClOSE
Return DllCall( "EndDialog", UInt,_hDLG, UInt,BDEf := BEsc )
If ( uMsg=0x111 && (wP>>16)=0 ) ; WM_COMMAND && BN_CLICKED
Return DllCall( "EndDialog", UInt,_hDLG, UInt,BDef := (wP=2) ? BEsc : wP-100 )
Return False
}
If ! ( _Ins ) {
_Ins := DllCall( "GetModuleHandle", Str,A_AhkPath )
_DT=
( Ltrim Join
61160CD3AFCDD0118A3EGC04FC9E26EZPCHC88OAZO8G4DG53G2H53G68G65G6CG6CG2H44G6CG67Q58ZHDG741
G74G6CG41G78G57G69G6EK7BG38G38G35G36G46G39G36G31G2DG33G34G3H41G2DG31G31G44G3H2DG41G39G3
6G42G2DG3H3H43G3H34G46G44G37G3H35G41G32G7DT14NFBFFQ65GFFFF8Y14NFBFFQ66GFFFF8Y14NFBFFQ67
GFFFF8Y14NFBFFQ68GFFFF8Y14NFBFFQ69GFFFF8Y14NFBFFQ6AGFFFF8Y14NFBFFQ6BGFFFF8Y14NFBFFQ6CGF
FFF8Y14NFBFFQ6DGFFFF8T
)
Loop 20 ; Decompressing Nulls : www.autohotkey.com/forum/viewtopic.php?p=198560#198560
StringReplace,_DT,_DT,% Chr(70+21-A_Index),% SubStr("000000000000000000000",A_Index),All
VarSetCapacity( _STRU, ( _DTLEN := StrLen(_DT) // 2 ) + 256, 0 )
Loop %_DTLEN% ; Creating Binary Structure from Hex
NumPut( "0x" . SubStr(_DT, 2*A_Index-1,2),_STRU,A_Index-1,"Char" )
_pIWEB := &_STRU, _pV := &_STRU+16, _DlgT := &_STRU+32
If ! DllCall( "GetModuleHandle", Str,"atl.dll" )
DllCall( "LoadLibrary", Str,"atl.dll" )
DllCall( "atl\AtlAxWinInit" )
_DlgP := RegisterCallback( A_ThisFunc,0,4,0xCBF )
}
_hDLG := DllCall( "CreateDialogIndirectParam", UInt,_Ins, UInt,_DlgT, UInt, ( _Owner="" )
? DllCall("FindWindow", Str,"AutoHotkey", Str,A_ScriptFullPath " - AutoHotkey v"
. A_AhkVersion ) : _Owner, UInt,_DlgP, UInt,0 )
If ! A_IsUnicode {
VarSetCapacity( _WU,StrLen(_URL)*2+2 ), sLen := StrLen(_URL)+1
DllCall( "MultiByteToWideChar", UInt,0, UInt,0, UInt,&_URL, Int,-1, UInt,&_WU, Int,sLen )
} else
_WU := _URL, sLen := (StrLen(_URL)+1)*2
_hHTM := DllCall( "GetDlgItem", UInt,_hDLG, UInt,2000, UInt )
; www.autohotkey.com/forum/viewtopic.php?p=103987#103987 WebBrowser Control Demo by Sean
; ---------------------------------------------------------------------------------------
DllCall( "atl\AtlAxGetControl", UInt,_hHTM, UIntP,_ppunk )
DllCall( NumGet( NumGet( _ppunk+0 )+4*0 ), UInt,_ppunk, UInt,_pIWEB, UIntP,_ppwb )
DllCall( NumGet( NumGet( _ppunk+0 )+4*2 ), UInt,_ppunk ), _pwb := NumGet( _ppwb+0 )
DllCall( NumGet(_pwb+4*11),UInt,_ppwb, UInt,&_WU, UInt,_pV,UInt,_pV,UInt,_pV,UInt,_pV )
; ---------------------------------------------------------------------------------------
Slee:=-1, HtmD:=1
Butt:="OK", BWid:=75, BHei:=23, BSpH:=5, BSpV:=8, BAli:=1
DlgX:="", DlgY:="", HtmW:=280, HtmH:=140, Left:=5, TopM:=5
Loop, Parse, _Options, =%_ODL%, %A_Space%
A_Index & 1 ? ( __ := (SubStr(A_LoopField,1,1)="_") ? "_" : SubStr(A_LoopField,1,4))
: ( %__% := A_LoopField )
If ( HtmD )
DllCall( "MoveWindow", UInt,_hHTM, UInt,0, UInt,0, UInt,HtmW, UInt,HtmH, Int,1 )
Else {
DllCall( "MoveWindow", UInt,_hHTM, UInt,Left, UInt,TopM, UInt,HtmW, UInt,HtmH, Int,1 )
Control, Enable,,, ahk_id %_hHTM%
}
Cap := DllCall( "GetSystemMetrics", UInt,4 ) ; SM_CYCAPTION = Window Caption
Frm := DllCall( "GetSystemMetrics", UInt,7 ) ; SM_CXFIXEDFRAME = Window Frame
SBW := DllCall( "GetSystemMetrics", UInt,2 ) ; SM_CXVSCROLL = VScrollbar Width
DlgW := Frm + HtmW + Frm + ( HtmD ? 0-SBW : Left+Left )
DlgH := Cap + Frm + HtmH + BSpV + BHei + BSpV + Frm + ( HtmD ? 0 : TopM )
DlgX := ( DlgX <> "" ) ? DlgX : ( A_ScreenWidth - DlgW ) // 2
DlgY := ( DlgY <> "" ) ? DlgY : ( A_ScreenHeight - DlgH ) // 2
ClAW := DlgW - Frm - Frm ; ClientArea Width
DllCall( "MoveWindow", UInt,_hDLG, UInt,DlgX, UInt,DlgY, UInt,DlgW, UInt,DlgH, Int,1 )
StringReplace, Butt,Butt, /,/, UseErrorLevel
bCount := ErrorLevel+1
If BAli = 0
BX := ( BSpH * 2 ) + ( HtmD ? 0 : Left )
Else If BAli = 1
BX := ( ClAW - (BSpH*(bCount-1)) - (BWid*bCount) ) / 2
Else
BX := ClAW - (BSpH*(bCount+1)) - (BWid*bCount) - ( HtmD ? 0 : Left )
BY := HtmH + BSpV + ( HtmD ? 0 : TopM )
Loop, Parse, Butt, /
{
BHwnd := DllCall( "GetDlgItem", UInt,_hDLG, UInt,100+A_Index )
DllCall( "MoveWindow", UInt,BHwnd, UInt,BX, UInt,BY, UInt,BWid, UInt,BHei, Int,1 )
DllCall( "SetWindowText", UInt,BHwnd, Str,A_LoopField ), BX := BX+BSpH+BWid
DllCall( "ShowWindow", UInt,BHwnd, Int,True )
}
BDef := ( BDef<1 || BDef>bCount ) ? 1 : BDef
DllCall( "SendMessage", UInt,_hDLG, UInt,0x401, UInt,100+BDef, UInt,0 ) ; DM_SETDEFID
ControlFocus,, % "ahk_id " DllCall( "GetDlgItem", UInt,_hDLG, UInt,100+BDef )
DllCall( "SetWindowText", UInt,_hDLG, Str,Titl ? Titl : A_ScriptName )
Sleep, %Slee%
WinShow, ahk_id %_hDLG%
WinWaitClose, ahk_id %_hDLG%,, %Time%
If ( TimedOut := Errorlevel ) {
DllCall( "EndDialog", UInt,_hDLG, UInt,0 )
}
If ( AltR=1 && BDef ) {
StringSplit, B, Butt, /
BDef := B%BDef%
}
DllCall( NumGet(_pwb+4*2), UInt,_ppwb ), DllCall( "SetLastError", UInt,TimedOut ? 1 : 0 )
Return BDEf
}
/*
/- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>- - - - - - - - - - - - - - - - - - - - - - - - - O P T I O N S -
\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Usage: HtmDlg( URL, hwndOwner, Options, OptionsDelimiter )
Parameters :
URL - A valid URL supported by Internet Explorer including Res:// and File://
hWndOwner - Handle to the parent window. If invalid handle or 0 ( zero ) is passed,
the dialog will have a taskbar button. Passing "" as a parameter will
definitely supress the Taskbar Button.
Options - A series of 'variable overrides' delimited with character specified in
Options delimiter. Please refer 'VARIABLE OVERRIDES' below.
OptionsDelimiter - The delimiter used in seperating 'variable overrides'
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; * * * V A R I A B L E O V E R R I D E S * * *
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Important Note: leading 4 characters of a variable will be sufficient.
for eg., Instead of 'AltReturn=1' you may use 'AltR=1'
Title = Captionbar Text
Default is A_ScriptName
DlgXpos = X coordinate in pixels, relative to screen
Dialog is horizontally centered by default
DlgYpos = Y coordinate in pixels, relative to screen
Dialog is vertically centered by default
AltReturn = 1 will return Button-text
0 is default and Button Instance will be returned
TimeOut = Seconds
No Default value
Note: A_LastError will be true when a TimeOut occurs
Sleep = MilliSeconds ( Will be used just before Dialog is shown )
No Sleep by Default
LeftMargin = Spacing in Pixels ( on the left/right sides of Htm Control )
Default value is 5. Ignored if Htm control is disabled. See: HtmDisable
TopMargin = Spacing in Pixels ( above the Htm Control )
Default value is 5. Ignored if Htm control is disabled. See: HtmDisable
HtmDisable = 0 to enable
Htm Control is disabled by default.
HtmWidth = Width of WebControl in Pixels
Default value is 240
HtmHeight = Height of WebControl in pixels
Default value is 140
Buttons = Button labels seperated with "/" ( eg: Buttons=Yes/No/Cancel )
Default is "OK"
BDefault = Instance of Default Button ( eg: To make 3rd Button default, use BDef=3 )
Default forced value is 1
BEscape = Instance of Cancel Button ( Used when dialog is closed or Esc is pressed )
Default is 0
BWidth = Button Width in Pixels
Default Value is 75
BHeight = Button height Pixels
Default value is 23
BSpHorizontal = Pixels ( affects the spacing on the sides of a button )
BSpVertical = Pixels ( affects the spacing above/below a button )
BAlign = 0 or 1 or 2 ( for Left, Center, Right alignment of Buttons )
Default is 1
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
The example script:
| Code: | #SingleInstance, Force
SetWorkingDir %A_ScriptDir%
bgcolor := GetSysColor(15) ; Window Background color for the current desktop theme
FileDelete, demo.htm
FileAppend,
( Join
<html><body bgcolor="#%bgcolor%" leftmargin="10" topmargin="10"><div align="left"><p><font
face="Arial" size="2">This area of this Dialogbox uses HTM which means you can format you
r message using <i>Italics, </i><b>Bold</b>, <font color="#3366CC"><b><font color="#FF0033
">Colors</font></b></font> and all other formatting HTML permits.<br><br>Please note that
this webcontrol mimics a static control using these workarounds:<br><b>1)</b> Your comput
er system's window color is <b>%bgcolor%</b>, and is being used as the bgcolor of HTM so a
s to simulate transparency. <b><br>2)</b> This control has been disabled and so you cannot
select/copy text.<b><br>3)</b> The vertical scrollbar is just outside the client-area of
this dialog.<br><br>Do you like this MessageBox?</font><font face="Arial" size="2"></font
><font color="#3333CC" face="Arial" size="2"> </font></p></div></body></html>
)
, demo.htm
URL=file:///%A_ScriptDir%\demo.htm
Options := "Buttons=Yes/No/50-50, HtmW=360, HtmH=260, BEsc=3"
Sel := HtmDlg( URL, "", Options )
Return ; // end of auto-execute section //
GetSysColor( DisplayElement=1 ) {
VarSetCapacity( HexClr,14,0 ), SClr := DllCall( "GetSysColor", UInt,DisplayElement )
RGB := ( ( ( SClr & 0xFF) << 16 ) | ( SClr & 0xFF00 ) | ( ( SClr & 0xFF0000 ) >> 16 ) )
DllCall( "msvcrt\" (A_IsUnicode ? "swprintf" : "sprintf"), Str,HexClr, Str,"%06X", UInt,RGB )
Return HexClr
}
#Include HtmDlg.ahk ; You may copy/Paste HtmDlg() Instead |
_________________ fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list] |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Thu Jul 15, 2010 11:23 pm Post subject: |
|
|
Thx fincs.
I strongly suggest to all authors to try to make such minimal efforts to make scripts compatible with both branches of AHK.
[Moderator's note: The discussion following this comment was split into its own topic.] _________________
 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Fri Jul 16, 2010 6:53 am Post subject: |
|
|
| fincs wrote: | | This script is awesome. |
Thank you.
| Quote: | | I've given it a little bit of Unicode love (it was pretty easy to make it work with both versions) |
Thank you.. I will incorporate the changes in the next sub-version. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sun Jul 18, 2010 10:00 am Post subject: HTML DialogBox v0.54 |
|
|
Download: HtmDlg() v0.54
New Options:
- DlgDisable - disables the dialog, and will rely on 'TimeOut' to close
- DlgStyle - creates dialog without caption
- DlgTopmost - sets dialog 'AlwaysOnTop'
- DlgNoActivate - shows dialog without activation
- ClickClose - close dialog when 'unoccupied clientarea' is left clicked
- FonSize - increase 'Button-label-text' size for better legibility
- HtmClientEdge - cosmetic requirement when scrollbar is visible
These new options should provide alternatives to Traytip, SplashText/SplashImage.
We need to use some imagination.
Behavior change:
- The function does not try to hide the vertical scrollbar. The same can be achieved at HTML level with CSS snippet provided by codybear
- Webcontrol is not disabled by default.
Pseudo Screensaver ( Shockwave Flash in Kiosk Mode )
| Code: | #SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
IfNotExist,ahkmatrix.swf, UrlDownloadToFile
, http://www.autohotkey.net/~Skan/Scripts/HtmDlg/ahkmatrix.shockwaveflash
, ahkmatrix.swf ; 12022 bytes only
URL = file:///%A_ScriptDir%\ahkmatrix.swf
Options=
(
Buttons = Yes/No
BDefault = 1
BEscape = 2
BHeight = 0
BSpVertical = 0
HtmWidth = %A_ScreenWidth%
HtmHeight = %A_ScreenHeight%
DlgStyle = NoFrame
DlgTopMost = 1
Sleep = 300
)
HtmDlg( URL,"", Options, "`n" ) ; <-- Note: Options Delimiter is different
#Include HtmDlg.ahk ; requires HtmDlg() version 0.54 |
|
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Sun Jul 18, 2010 8:13 pm Post subject: |
|
|
In this line:
| Code: | | hWnd := _URL, uMsg := _Owner, wP := _Options, lP := _ODL |
Where do you use the first and the last variables? I can't seem to find it. _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sun Jul 18, 2010 8:22 pm Post subject: |
|
|
| MasterFocus wrote: | | Where do you use the first and the last variables? I can't seem to find it. |
They are redundant and exist for the sake of readability. |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Sun Jul 18, 2010 8:36 pm Post subject: |
|
|
| SKAN wrote: | | They are redundant and exist for the sake of readability. |
Understood. Thanks  _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
flyingDman
Joined: 27 Feb 2009 Posts: 690 Location: Burbank, California
|
Posted: Mon Jul 19, 2010 11:53 pm Post subject: |
|
|
Again, very cool. Here is to you!
| Code: | #SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
IfNotExist, success.swf, urldownloadtofile http://www.keramigos.com/success.swf, success.swf ;1454 bytes only
settimer, label1, 500
URL = file:///%A_ScriptDir%\success.swf
Options=
(
Buttons = Yes/No
BDefault = 1
BEscape = 2
BHeight = 0
BSpVertical = 0
HtmWidth = %A_ScreenWidth%
HtmHeight = %A_ScreenHeight%
DlgStyle = NoFrame
DlgTopMost = 1
Sleep = 300
)
HtmDlg( URL,"", Options, "`n" ) ; <-- Note: Options Delimiter is different
label1:
IF(A_TimeIdlePhysical < 500)
exitapp
return
;#Include HtmDlg.ahk ; requires HtmDlg() version 0.54 |
Added a timer to check and terminate upon any (incl. mouse) activity. Compile, change the extension to scr and you got a real screensaver (drop the pseudo!). _________________ "Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data... |
|
| Back to top |
|
 |
chrixian
Joined: 08 Apr 2010 Posts: 2
|
Posted: Tue Jul 20, 2010 4:03 am Post subject: |
|
|
| I love you |
|
| Back to top |
|
 |
newus Guest
|
Posted: Tue Jul 20, 2010 12:25 pm Post subject: |
|
|
Crazy Script
I have used below way.
js = window.showModalDialog("http://www.autohotkey.com")
;<or showModelessDialog>
Com_Invoke(pwb, "document.parentWindow.execScript",js)
I`ll try your Script. |
|
| Back to top |
|
 |
majstang
Joined: 29 Aug 2008 Posts: 386
|
Posted: Sat Jul 31, 2010 11:15 pm Post subject: |
|
|
HTML DialogBox is a really cool script!
However I did run into some troubles when changing bgcolors. No problem to change bgcolor on the Dialogbox, but how do I change the bgcolor on the area around the buttons? Bgcolor of this area stays default no matter what I do. I cant find any option to override the default color in this area either. Would be great to have one bgcolor and not two. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 748 Location: Texas, USA
|
Posted: Sun Aug 01, 2010 2:19 am Post subject: |
|
|
I'm still experimenting (read: "having fun") but I'm trying to use this function to replace a small help file. This is what I started with...
I was able to get rid of the buttons by using the following options:
With these options, it looks like this...
So far, so good.
One minor issue... If the Enter or Space keys are used after the dialog is displayed, the dialog is destroyed and the function returns a value of 1. This is the expected action if the first (or only) button is active, but it is a bit confusing when there are no buttons. (Hidden default button??) If the HTM control is made active (assuming HtmDisable=0), using the Space key gives the expected response -- page down.
One possible improvement might be to include a new option (HTMActivate=1 ????) that could be used when the HtmDisable=0 option is used. This option would automatically activate the HTM control when the dialog is displayed so that all standard HTM navigation keys (Up, Down, PageUp, PageDn, Space, etc.) can be used without first clicking on the control to activate it.
Them by my thoughts...
Edit: I discovered the BSpHorizontal and BSpVertical options so that I could remove the space where the buttons are displayed. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sun Aug 01, 2010 3:21 am Post subject: |
|
|
| majstang wrote: | | but how do I change the bgcolor on the area around the buttons? Bgcolor of this area stays default no matter what I do. I cant find any option to override the default color in this area either. |
It was not implemented because:
Changing the GUI ( dialog ) background color alone would not be sufficient.
Theme should be removed for the button or it will show through the background color.
Button has to be colored to match the window BG color.
Please try this snippet:
| Code: | Gui, Color, Black
Gui Add, Button, x200 y200, OK
Gui Add, Button, x+5 , Cancel
Gui, Show,, Test |
| Quote: | | Would be great to have one bgcolor and not two. |
Okay.. I will try and see if it can be implemented with little extra code.
BTW, I recommend you to use the current version: HtmDlg() 0.54
http://www.autohotkey.com/forum/viewtopic.php?p=370245#370245 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sun Aug 01, 2010 3:38 am Post subject: |
|
|
| jballi wrote: | | One possible improvement might be to include a new option (HTMActivate=1 ????) that could be used when the HtmDisable=0 option is used. This option would automatically activate the HTM control when the dialog is displayed so that all standard HTM navigation keys (Up, Down, PageUp, PageDn, Space, etc.) can be used without first clicking on the control to activate it. |
jballi, please try the newer version 0.54 ( posted few posts above ).
- Webcontrol is not disabled by default.
- You can even simulate kiosk mode now.
- You can show the dialog unobtrusive i.e., 'without' activating it... like a TrayTip
Okay, I will introduce a new option that will put WebControl in focus.
| Quote: | | I discovered the BSpHorizontal and BSpVertical options so that I could remove the space where the buttons are displayed. |
Those overrides were intended for such purpose.
Again, please try the new example posted along with v0.54 which simulates kiosk mode.
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|