Re: [GUI] Use HTML and CSS for your GUIs!
Posted: 11 Apr 2018, 17:44
Awesome
Let's help each other out
https://www.autohotkey.com/boards/
joedf wrote:Awesome
https://support.microsoft.com/en-us/hel ... orer-to-ruStavencross wrote:joedf wrote:Awesome
Some of the functions I use pop up a message box that pauses the script while a user works in PowerPoint.
However, it seems that webapp.ahk will be looping in the background, once it gets to 5 million loops, internet explorer pops a message box complaining about an unresponsive script and asking if I want to close it.
Is there anything I can do about this?
I'm trying to refractor my code to do away with these message boxes, but I wanted to see if you had any insight as a temp fix
kczx3 wrote:https://support.microsoft.com/en-us/hel ... orer-to-ruStavencross wrote:joedf wrote:Awesome
Some of the functions I use pop up a message box that pauses the script while a user works in PowerPoint.
However, it seems that webapp.ahk will be looping in the background, once it gets to 5 million loops, internet explorer pops a message box complaining about an unresponsive script and asking if I want to close it.
Is there anything I can do about this?
I'm trying to refractor my code to do away with these message boxes, but I wanted to see if you had any insight as a temp fix
Code: Select all
ShellRun("C:\Users\<user>\Desktop\index.html", "", "", "print", 1)
Code: Select all
Run, % "rundll32.exe " . A_WinDir . "\system32\mshtml.dll,PrintHTML "C:\Users\<user>\Desktop\index.html"""
wow thank you! I'll read through this tonight. Thats great news!!kczx3 wrote: ↑02 Nov 2018, 07:41I think you have two options DRocks. You can try using ShellRun by Lexikos and calling it like so:I do believe that this requires that the default program for html files is Internet Explorer though.Code: Select all
ShellRun("C:\Users\<user>\Desktop\index.html", "", "", "print", 1)
Another option, though it seems that this is undocumented behavior, is to call the PrintHTML function from mshtml.dll. I wasn't able to figure it out using DllCall but I could get it to run via to following:See here for more info - https://stackoverflow.com/a/768/8820049 and https://stackoverflow.com/questions/199 ... mshtml-dllCode: Select all
Run, % "rundll32.exe " . A_WinDir . "\system32\mshtml.dll,PrintHTML "C:\Users\<user>\Desktop\index.html"""
EDIT:
And here's a sample of a HTML file with styles for printing - https://gist.github.com/crowcoder/c4ac49ba30048262db8c
This seems to have good info for CSS print stuff - https://print-css.rocks/
Code: Select all
Run, % "rundll32.exe " . A_WinDir . "\system32\mshtml.dll,PrintHTML ""C:\Users\Alex\Desktop\index.html"
Might want to use %A_UserName% as opposed to Alex or <user>... Just saying...DRocks wrote: ↑02 Nov 2018, 17:35Code: Select all
Run, % "rundll32.exe " . A_WinDir . "\system32\mshtml.dll,PrintHTML ""C:\Users\Alex\Desktop\index.html"
Right.SOTE wrote: ↑06 Nov 2018, 01:02Might want to use %A_UserName% as opposed to Alex or <user>... Just saying...DRocks wrote: ↑02 Nov 2018, 17:35Code: Select all
Run, % "rundll32.exe " . A_WinDir . "\system32\mshtml.dll,PrintHTML ""C:\Users\Alex\Desktop\index.html"
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Not required for the script but it makes moving the window around with the mouse possible.
OnMessage(0x0201, "WM_LBUTTONDOWN")
WM_LBUTTONDOWN()
{
If (A_Gui){
PostMessage, 0xA1, 2
}
}
gui Changeimagecolor:default
gui, add, edit, h0 w0
gui, font, s10
gui +Border -Caption +lastfound
gui, color, EBAE02
WinSet, TransColor, EBAE02
;set gui background and make that color invisible so just the elements are shown.
winsettitle, Changeimagecolor
guiwidth := A_screenwidth / 1.5
guiheight := A_screenheight / 1.5
;specify width and heights for guis
leftmenuwidth := guiwidth * 0.1
leftmenuheight := guiheight
middlemenuwidth := guiwidth * 0.8
middlemenuheight := guiheight
Gui, Add, ActiveX, x0 y0 w%leftmenuwidth% h%leftmenuheight% vleftmenu, Shell.Browser
Gui, Add, ActiveX, x%leftmenuX% y0 w%middlemenuwidth% h%middlemenuheight% vmiddlemenu, Shell.Browser
lefthtml := "<!DOCTYPE html><html><head><meta http-equiv='X-UA-Compatible' content='ie=edge'>"
lefthtml .= "<style type=text/css> html {overflow:hidden; height: 100%;} body {background:#777777; height: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [greyed=true]{background: #666666 !important;}"
lefthtml .= "button{width:100%; height:5%; background:#555555; color:#000000; border: 2px solid #440044;}"
lefthtml .= ".altercolor{filter: hue-rotate(90deg); background:#FFFFFF;}"
lefthtml .= "</style></head><body>"
lefthtml .= "<button class='button' id='changecolor'>Change image color</button>"
lefthtml .= "<button class='exitbutton' id='exitbutton'>Exit</button>"
lefthtml .= "</body></html>"
middlehtml := "<!DOCTYPE html><html><head><meta http-equiv='X-UA-Compatible' content='ie=edge'>"
middlehtml .= "<style type=text/css> html {overflow:hidden; height: 100%;} body {background:#666666; height: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [greyed=true]{background: #666666 !important;}"
middlehtml .= ".altercolor{filter: hue-rotate(90deg); background:#FFFFFF;}"
middlehtml .= "</style></head><body>"
middlehtml .= "<img class='image' id='image' src='" . A_WorkingDir . "\>\* Put image here*\<'>"
middlehtml .= "</body></html>"
;navigate to a blank html slate
leftmenu.navigate("about:blank")
middlemenu.navigate("about:blank")
rightmenu.navigate("about:blank")
;write html in the guis
leftmenu.document.open()
leftmenu.document.write(lefthtml)
leftmenu.document.close()
middlemenu.document.open()
middlemenu.document.write(middlehtml)
middlemenu.document.close()
;connect the button to the changecolor function
ComButton := Leftmenu.document.getElementById("changecolor")
ExitButton := Leftmenu.document.getElementById("exitbutton")
ComObjConnect(ComButton, "changeColor_")
ComObjConnect(ExitButton, "exit_")
gui, show
return
F11::
reload
return
changeColor_onclick(){
global
;get the ID of the image and button and set their class to 'altercolor'
imagecheck := middlemenu.document.getElementById("image")
imagecheck.setAttribute("className", "altercolor")
;.altercolor{filter: hue-rotate(90deg); background:#FFFFFF;} < this should change the color and background of both the button and image but just the background changes.
buttoncheck := leftmenu.document.getElementById("changecolor")
buttoncheck.setAttribute("className", "altercolor")
}
exit_OnClick(){
ExitApp
}