1

Тема: AHK: Gui+html+css

Добрый всем день!

Собственно, вопрос обозначен в теме. Можно ли как-то заставить работать в Gui эту html+css кнопку-анимашку:

<!doctype html>
<html>

<head>
<style>
*,
*:before,
*:after {
  box-sizing: border-box;
}
body {
  background-color: #1c1d1f;
}
.button {
  display: block;
  width: 400px;
  height: 120px;
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  background-color: #000000;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.2) inset;
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.button span {
  display: block;
  position: absolute;
  top: 6px;
  width: 194px;
  height: 108px;
  background-color: #1c1d1f;
  -webkit-transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease, -webkit-transform 300ms ease;
}
.button span:before {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  font-family: "Open Sans";
  font-weight: 800;
  font-size: 48px;
  -webkit-transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
  transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
}
.button span:after {
  content: "";
  width: 4px;
  height: 108px;
  position: absolute;
  top: 0;
  background: -webkit-radial-gradient(center ellipse, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  -webkit-transition: opacity 300ms ease;
  transition: opacity 300ms ease;
}
.button span:first-of-type {
  left: 6px;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  -webkit-transform-style: preserve3d;
          transform-style: preserve3d;
  -webkit-transform-origin: right center;
          transform-origin: right center;
  -webkit-transform: perspective(2000px) rotateY(40deg);
          transform: perspective(2000px) rotateY(40deg);
  box-shadow: -1px 0 1px rgba(255, 255, 255, 0.1) inset, 4px 0 8px rgba(255, 255, 255, 0.1) inset, 1px 0 0 rgba(255, 255, 255, 0.1) inset, -10px 0 8px rgba(40, 42, 44, 0.9), -20px 0 8px rgba(28, 29, 31, 0.7), -30px 0 8px rgba(28, 29, 31, 0.4);
}
.button span:first-of-type:before {
  content: "ON";
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 black, 1px 4px 6px #1c1d1f;
}
.button span:first-of-type:after {
  left: -1px;
}
.button span:last-of-type {
  right: 6px;
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  -webkit-transform-origin: left center;
          transform-origin: left center;
  box-shadow: -1px 1px 1px rgba(255, 255, 255, 0.1) inset, 2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button span:last-of-type:before {
  content: "OFF";
  color: #ff4847;
  text-shadow: 0 0 24px rgba(255, 72, 71, 0.6);
}
.button span:last-of-type:after {
  right: -1px;
  opacity: 0;
}
.button input[type="checkbox"] {
  display: none;
}
.button input[type="checkbox"]:checked ~ span:first-of-type {
  -webkit-transform: none;
          transform: none;
  box-shadow: 1px 1px 1px rgba(255, 255, 255, 0.1) inset, -2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button input[type="checkbox"]:checked ~ span:first-of-type:before {
  color: #93c913;
  text-shadow: 0 0 24px rgba(147, 201, 19, 0.6);
}
.button input[type="checkbox"]:checked ~ span:first-of-type:after {
  opacity: 0;
}
.button input[type="checkbox"]:checked ~ span:last-of-type {
  -webkit-transform: perspective(2000px) rotateY(-40deg);
          transform: perspective(2000px) rotateY(-40deg);
  box-shadow: 1px 0 1px rgba(255, 255, 255, 0.1) inset, -4px 0 8px rgba(255, 255, 255, 0.1) inset, -1px 0 0 rgba(255, 255, 255, 0.1) inset, 10px 0 8px rgba(40, 42, 44, 0.9), 20px 0 8px rgba(28, 29, 31, 0.7), 30px 0 8px rgba(28, 29, 31, 0.4);
}
.button input[type="checkbox"]:checked ~ span:last-of-type:before {
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 #000000, 1px 4px 6px #1c1d1f;
}
.button input[type="checkbox"]:checked ~ span:last-of-type:after {
  opacity: 1;
}
</style>
</head>

<body>

<label class="button">
  <input type="checkbox">
  <span></span>
  <span></span>
</label>

</body>

</html>

Как вписать все это дело в Gui я разобрался:
Gui Add, ActiveX ....

а вот КАК заставить выполнять полезную работу - ???

Буду признателен за любую помощь!

Лучше день потерять, потом за пять минут долететь!

2

Re: AHK: Gui+html+css

stealzy, нет смысла выкладывать весь скрипт, куда я хочу все это запихнуть - слишком длинный код, да и не принципиально это. В теории - это обычный Gui, например такой:

	Gui About: +LastFound -Caption +ToolWindow +AlwaysOnTop
	
	Gui About: Add, Picture, x500 y10 w20 h20 BackgroundTrans gCloseAbout vCloseAbout, % CloseExit
	Gui About: Add, ActiveX, x0 y0 w530 h320, % A_ScriptDir "\Switcher.html"
	
	Gui About: Show, Center w530 h320, About
	WinSet Region, w530 h320 0-0 R20-20
	Return

где файл Switcher.html - это и есть html+css код, указанный выше.

Нужно, чтобы при включении/отключении этой html кнопки-анимашки выполнялось что-то, напр. MsgBox .... 1 и MsgBox .... 2

Лучше день потерять, потом за пять минут долететь!

3 (изменено: stealzy, 2015-12-29 23:02:31)

Re: AHK: Gui+html+css

Не работает, кнопка отображается странно и не реагирует на нажатие.
Дайте рабочий код.
В браузере все ок. Я про сам скрипт.
----------------------------------------------------------------------------
Я могу дать вам кнопку в ActiveX, но не такую красивую, скажем так.
Если вкратце, и не рабочим кодом, как вам нравится постить, то так:

ComObjConnect(html_folder := ActiveX.getElementById("button"), "button_")
button_onclick()

4 (изменено: Dr.Jekyll, 2015-12-29 23:06:19)

Re: AHK: Gui+html+css

... странно, у меня все работает. Браузер Comodo Dragon. Пробовал в Ишаке - все работает.
Еще раз html код:


<!doctype html>
<html>

<head>
<style>
*,
*:before,
*:after {
  box-sizing: border-box;
}
body {
  background-color: #1c1d1f;
}
.button {
  display: block;
  width: 400px;
  height: 120px;
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  background-color: #000000;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.2) inset;
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.button span {
  display: block;
  position: absolute;
  top: 6px;
  width: 194px;
  height: 108px;
  background-color: #1c1d1f;
  -webkit-transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease, -webkit-transform 300ms ease;
}
.button span:before {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  font-family: "Open Sans";
  font-weight: 800;
  font-size: 48px;
  -webkit-transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
  transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
}
.button span:after {
  content: "";
  width: 4px;
  height: 108px;
  position: absolute;
  top: 0;
  background: -webkit-radial-gradient(center ellipse, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  -webkit-transition: opacity 300ms ease;
  transition: opacity 300ms ease;
}
.button span:first-of-type {
  left: 6px;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  -webkit-transform-style: preserve3d;
          transform-style: preserve3d;
  -webkit-transform-origin: right center;
          transform-origin: right center;
  -webkit-transform: perspective(2000px) rotateY(40deg);
          transform: perspective(2000px) rotateY(40deg);
  box-shadow: -1px 0 1px rgba(255, 255, 255, 0.1) inset, 4px 0 8px rgba(255, 255, 255, 0.1) inset, 1px 0 0 rgba(255, 255, 255, 0.1) inset, -10px 0 8px rgba(40, 42, 44, 0.9), -20px 0 8px rgba(28, 29, 31, 0.7), -30px 0 8px rgba(28, 29, 31, 0.4);
}
.button span:first-of-type:before {
  content: "ON";
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 black, 1px 4px 6px #1c1d1f;
}
.button span:first-of-type:after {
  left: -1px;
}
.button span:last-of-type {
  right: 6px;
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  -webkit-transform-origin: left center;
          transform-origin: left center;
  box-shadow: -1px 1px 1px rgba(255, 255, 255, 0.1) inset, 2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button span:last-of-type:before {
  content: "OFF";
  color: #ff4847;
  text-shadow: 0 0 24px rgba(255, 72, 71, 0.6);
}
.button span:last-of-type:after {
  right: -1px;
  opacity: 0;
}
.button input[type="checkbox"] {
  display: none;
}
.button input[type="checkbox"]:checked ~ span:first-of-type {
  -webkit-transform: none;
          transform: none;
  box-shadow: 1px 1px 1px rgba(255, 255, 255, 0.1) inset, -2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button input[type="checkbox"]:checked ~ span:first-of-type:before {
  color: #93c913;
  text-shadow: 0 0 24px rgba(147, 201, 19, 0.6);
}
.button input[type="checkbox"]:checked ~ span:first-of-type:after {
  opacity: 0;
}
.button input[type="checkbox"]:checked ~ span:last-of-type {
  -webkit-transform: perspective(2000px) rotateY(-40deg);
          transform: perspective(2000px) rotateY(-40deg);
  box-shadow: 1px 0 1px rgba(255, 255, 255, 0.1) inset, -4px 0 8px rgba(255, 255, 255, 0.1) inset, -1px 0 0 rgba(255, 255, 255, 0.1) inset, 10px 0 8px rgba(40, 42, 44, 0.9), 20px 0 8px rgba(28, 29, 31, 0.7), 30px 0 8px rgba(28, 29, 31, 0.4);
}
.button input[type="checkbox"]:checked ~ span:last-of-type:before {
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 #000000, 1px 4px 6px #1c1d1f;
}
.button input[type="checkbox"]:checked ~ span:last-of-type:after {
  opacity: 1;
}
</style>
</head>

<body>

<label class="button">
  <input type="checkbox">
  <span></span>
  <span></span>
</label>

</body>
</html>

Скопировал сейчас из этого отправленного кода и запустил - все работает.

В этом примере Gui у меня тоже работает .....

Лучше день потерять, потом за пять минут долететь!

5 (изменено: stealzy, 2015-12-29 23:28:14)

Re: AHK: Gui+html+css

:facepalm
Вы из браузера хотите запускать скрипт?
Я то - думал вы хотите использовать нативный элемент ActiveX внутри GUI скрипта.
В браузере у меня тоже все ок.
Я про то ваш html не отображается в ActiveX, как в браузере.

Я запускаю ваш код отсюда:

Dr.Jekyll пишет:
	Gui About: +LastFound -Caption +ToolWindow +AlwaysOnTop
	
	Gui About: Add, Picture, x500 y10 w20 h20 BackgroundTrans gCloseAbout vCloseAbout, % CloseExit
	Gui About: Add, ActiveX, x0 y0 w530 h320, % A_ScriptDir "\Switcher.html"
	
	Gui About: Show, Center w530 h320, About
	WinSet Region, w530 h320 0-0 R20-20
	Return

Убираем строку с несущ. label CloseAbout.
Вот что я вижу:http://s8.hostingkartinok.com/uploads/thumbs/2015/12/4f413832a312f214707a458d5ace455b.png

6 (изменено: Dr.Jekyll, 2015-12-29 23:09:58)

Re: AHK: Gui+html+css

Я только проверял сейчас в браузерах.
В Gui тоже все работает. Мне для скрипта нужно .... ну и для общего развития тоже.

Обычный скрипт с Gui без всякой связи с браузерами.

Лучше день потерять, потом за пять минут долететь!

7

Re: AHK: Gui+html+css

stealzy, у меня в этом Gui все работает. Только сейчас проверил все. .... Не пойму в чем причина .....

Лучше день потерять, потом за пять минут долететь!

8

Re: AHK: Gui+html+css

... видимо, это большие заморочки с html. Сделаю пару скриншотов кнопки в положении On и Off и добавлю в Gui как Picture ... будет нечно похожее на анимашку.

Лучше день потерять, потом за пять минут долететь!

9 (изменено: Dr.Jekyll, 2015-12-29 23:35:40)

Re: AHK: Gui+html+css

у меня 10 винда х64. Ишак 11 версии.

AutoHotkey L 1.1.22.07

... может битность AHK имеет значение???

У меня х64 unicode

Лучше день потерять, потом за пять минут долететь!

10 (изменено: serzh82saratov, 2016-05-25 17:52:39)

Re: AHK: Gui+html+css

Если совсем наобум, у меня так работает:


html = 
( %
<!doctype html>
<html>
 
<body> 
<label class="button" onselectstart='return false' oncontextmenu='return false'>
  <input type="checkbox" id="checkbox">
  <span></span>
  <span></span>
</label>

</body>
<head>
<style>
body {
  background-color: #1c1d1f;
  overflow: hidden; 
}
*,
*:before,
*:after {
  box-sizing: border-box;
} 
.button {
  display: block; 
  width: 400px;
  height: 120px;
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  background-color: #000000;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.2) inset;
  border-radius: 20px; 
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.button span {
  display: block;
  position: absolute;
  top: 6px;
  width: 194px;
  height: 108px;
  background-color: #1c1d1f;
  -webkit-transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease, -webkit-transform 300ms ease;
}
.button span:before {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  font-family: "Open Sans";
  font-weight: 800;
  font-size: 48px;
  -webkit-transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
  transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
}
.button span:after {
  content: "";
  width: 4px;
  height: 108px;
  position: absolute;
  top: 0;
  background: -webkit-radial-gradient(center ellipse, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  -webkit-transition: opacity 300ms ease;
  transition: opacity 300ms ease;
}
.button span:first-of-type {
  left: 6px;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  -webkit-transform-style: preserve3d;
          transform-style: preserve3d;
  -webkit-transform-origin: right center;
          transform-origin: right center;
  -webkit-transform: perspective(2000px) rotateY(40deg);
          transform: perspective(2000px) rotateY(40deg);
  box-shadow: -1px 0 1px rgba(255, 255, 255, 0.1) inset, 4px 0 8px rgba(255, 255, 255, 0.1) inset, 1px 0 0 rgba(255, 255, 255, 0.1) inset, -10px 0 8px rgba(40, 42, 44, 0.9), -20px 0 8px rgba(28, 29, 31, 0.7), -30px 0 8px rgba(28, 29, 31, 0.4);
}
.button span:first-of-type:before {
  content: "ON";
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 black, 1px 4px 6px #1c1d1f;
}
.button span:first-of-type:after {
  left: -1px;
}
.button span:last-of-type {
  right: 6px;
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  -webkit-transform-origin: left center;
          transform-origin: left center;
  box-shadow: -1px 1px 1px rgba(255, 255, 255, 0.1) inset, 2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button span:last-of-type:before {
  content: "OFF";
  color: #ff4847;
  text-shadow: 0 0 24px rgba(255, 72, 71, 0.6);
}
.button span:last-of-type:after {
  right: -1px;
  opacity: 0;
}
.button input[type="checkbox"] {
  display: none;
}
.button input[type="checkbox"]:checked ~ span:first-of-type {
  -webkit-transform: none;
          transform: none;
  box-shadow: 1px 1px 1px rgba(255, 255, 255, 0.1) inset, -2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button input[type="checkbox"]:checked ~ span:first-of-type:before {
  color: #93c913;
  text-shadow: 0 0 24px rgba(147, 201, 19, 0.6);
}
.button input[type="checkbox"]:checked ~ span:first-of-type:after {
  opacity: 0;
}
.button input[type="checkbox"]:checked ~ span:last-of-type {
  -webkit-transform: perspective(2000px) rotateY(-40deg);
          transform: perspective(2000px) rotateY(-40deg);
  box-shadow: 1px 0 1px rgba(255, 255, 255, 0.1) inset, -4px 0 8px rgba(255, 255, 255, 0.1) inset, -1px 0 0 rgba(255, 255, 255, 0.1) inset, 10px 0 8px rgba(40, 42, 44, 0.9), 20px 0 8px rgba(28, 29, 31, 0.7), 30px 0 8px rgba(28, 29, 31, 0.4);
}
.button input[type="checkbox"]:checked ~ span:last-of-type:before {
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 #000000, 1px 4px 6px #1c1d1f;
}
.button input[type="checkbox"]:checked ~ span:last-of-type:after {
  opacity: 1;
}
</style>
</head>
</html>
) 
Global oDoc 
Gui, margin, 0, 0 
FixIE(1)
Gui, Add, ActiveX, w444 h444 voDoc, HTMLFile  
oDoc.body.innerHTML := html
ComObjError(false)
ComObjConnect(oDoc, Events) 
oDoc.querySelector(".button").click()
Gui, Show
return   

Class Events  {
	onclick()  { 
		oevent := oDoc.parentWindow.event.srcElement
		tagname := oevent.tagname
		If tagname = input 
			ToolTip % !(oevent.checked + 1) ? "ON" : "OFF" 
	}
}

FixIE(Fix)  {
	Static Key := "Software\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
	If A_IsCompiled
		ExeName := A_ScriptName
	Else
		SplitPath, A_AhkPath, ExeName
	If Fix
		RegWrite, REG_DWORD, HKCU, %Key%, %ExeName%, 0
	Else
		RegDelete, HKCU, %Key%, %ExeName%
}
По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

11 (изменено: Dr.Jekyll, 2015-12-30 03:16:07)

Re: AHK: Gui+html+css

Добрый вечер, serzh82saratov! Большое спасибо! У меня тоже работает ... но при первом клике по кнопке идет небольшое смещение картинки вниз относительно Gui.
А почему Вы поставили <head> после <body> ?
И еще вопрос. Можно ли сделать так, чтобы позиция кнопки запоминалась на выходе ExitApp и была восстановлена при старте скрипта (по умолчанию это позиция "Off") ... или это из области unreal?

... в принципе, тег <head> тогда можно вообще удалить ....

Лучше день потерять, потом за пять минут долететь!

12

Re: AHK: Gui+html+css

или это из области unreal?

Думаю это просто, но нужен тот кто разбирается в html.

По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

13

Re: AHK: Gui+html+css

html здесь маловероятен. Скорее всего надо искать в css где там выставляется положение по-молчанию, загонять ее в переменную и писать все это в ini или реестр. ... К сожалению, css я вообще не знаю.
В общем, это большие заморочки. Думаю остановиться на варианте двух Picture, которые будут изменяться под GuiControl - будет нечто вроде анимашки. Уже написал тестовый вариант, вроде неплохо ... просто быстрее переключается, но эффект похож.

Всех благодарю за помощь! Задача слишком сложная.

Лучше день потерять, потом за пять минут долететь!

14

Re: AHK: Gui+html+css

Тема очень интересная. Жаль у меня на Win 7 х64 что то пошло не так. Скрипт Сержа создает окно с черным ничто. А твой хтмл весьма достоин (открыл его оперой, IE что то не открыл его). И как он это у вас там работает и почему не работает у меня - очень даже не понятно и прискорбно.

15

Re: AHK: Gui+html+css

yarrroslav, у меня на w7x64sp1, скрипт serzh82saratovа работает ок.

Dr.Jekyll пишет:

У меня тоже работает ... но при первом клике по кнопке идет небольшое смещение картинки вниз относительно Gui.

Всё дело в ошибке в CSS-стиле: для body там надо применять overflow: hidden и hidden не должно быть в кавычках.

16 (изменено: serzh82saratov, 2016-05-25 17:54:13)

Re: AHK: Gui+html+css

Drugoy пишет:

hidden не должно быть в кавычках.

Ага, поправил.

Dr.Jekyll пишет:

И еще вопрос. Можно ли сделать так, чтобы позиция кнопки запоминалась на выходе ExitApp и была восстановлена при старте скрипта (по умолчанию это позиция "Off") ... или это из области unreal?

Добавил:

oDoc.querySelector(".button").click()
По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

17 (изменено: yarrroslav, 2016-05-26 00:16:30)

Re: AHK: Gui+html+css

AHK v1.1.23.01, Win 7 x64

+ открыть спойлер

html = 
( %
<!doctype html>
<html>
 
<body> 
<label class="button" onselectstart='return false' oncontextmenu='return false'>
  <input type="checkbox" id="checkbox">
  <span></span>
  <span></span>
</label>

</body>
<head>
<style>
body {
  background-color: #1c1d1f;
  overflow: hidden; 
}
*,
*:before,
*:after {
  box-sizing: border-box;
} 
.button {
  display: block; 
  width: 400px;
  height: 120px;
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  background-color: #000000;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.2) inset;
  border-radius: 20px; 
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.button span {
  display: block;
  position: absolute;
  top: 6px;
  width: 194px;
  height: 108px;
  background-color: #1c1d1f;
  -webkit-transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: box-shadow 300ms ease, -webkit-transform 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease;
  transition: transform 300ms ease, box-shadow 300ms ease, -webkit-transform 300ms ease;
}
.button span:before {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  font-family: "Open Sans";
  font-weight: 800;
  font-size: 48px;
  -webkit-transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
  transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms;
}
.button span:after {
  content: "";
  width: 4px;
  height: 108px;
  position: absolute;
  top: 0;
  background: -webkit-radial-gradient(center ellipse, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.5) 0%, transparent 50%);
  -webkit-transition: opacity 300ms ease;
  transition: opacity 300ms ease;
}
.button span:first-of-type {
  left: 6px;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  -webkit-transform-style: preserve3d;
          transform-style: preserve3d;
  -webkit-transform-origin: right center;
          transform-origin: right center;
  -webkit-transform: perspective(2000px) rotateY(40deg);
          transform: perspective(2000px) rotateY(40deg);
  box-shadow: -1px 0 1px rgba(255, 255, 255, 0.1) inset, 4px 0 8px rgba(255, 255, 255, 0.1) inset, 1px 0 0 rgba(255, 255, 255, 0.1) inset, -10px 0 8px rgba(40, 42, 44, 0.9), -20px 0 8px rgba(28, 29, 31, 0.7), -30px 0 8px rgba(28, 29, 31, 0.4);
}
.button span:first-of-type:before {
  content: "ON";
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 black, 1px 4px 6px #1c1d1f;
}
.button span:first-of-type:after {
  left: -1px;
}
.button span:last-of-type {
  right: 6px;
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  -webkit-transform-origin: left center;
          transform-origin: left center;
  box-shadow: -1px 1px 1px rgba(255, 255, 255, 0.1) inset, 2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button span:last-of-type:before {
  content: "OFF";
  color: #ff4847;
  text-shadow: 0 0 24px rgba(255, 72, 71, 0.6);
}
.button span:last-of-type:after {
  right: -1px;
  opacity: 0;
}
.button input[type="checkbox"] {
  display: none;
}
.button input[type="checkbox"]:checked ~ span:first-of-type {
  -webkit-transform: none;
          transform: none;
  box-shadow: 1px 1px 1px rgba(255, 255, 255, 0.1) inset, -2px 0 2px rgba(255, 255, 255, 0.05) inset;
}
.button input[type="checkbox"]:checked ~ span:first-of-type:before {
  color: #93c913;
  text-shadow: 0 0 24px rgba(147, 201, 19, 0.6);
}
.button input[type="checkbox"]:checked ~ span:first-of-type:after {
  opacity: 0;
}
.button input[type="checkbox"]:checked ~ span:last-of-type {
  -webkit-transform: perspective(2000px) rotateY(-40deg);
          transform: perspective(2000px) rotateY(-40deg);
  box-shadow: 1px 0 1px rgba(255, 255, 255, 0.1) inset, -4px 0 8px rgba(255, 255, 255, 0.1) inset, -1px 0 0 rgba(255, 255, 255, 0.1) inset, 10px 0 8px rgba(40, 42, 44, 0.9), 20px 0 8px rgba(28, 29, 31, 0.7), 30px 0 8px rgba(28, 29, 31, 0.4);
}
.button input[type="checkbox"]:checked ~ span:last-of-type:before {
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 #000000, 1px 4px 6px #1c1d1f;
}
.button input[type="checkbox"]:checked ~ span:last-of-type:after {
  opacity: 1;
}
</style>
</head>
</html>
) 
Global oDoc 
Gui, margin, 0, 0 
FixIE(1)
Gui, Add, ActiveX, w444 h444 voDoc, HTMLFile  
oDoc.body.innerHTML := html
ComObjError(false)
ComObjConnect(oDoc, Events) 
oDoc.querySelector(".button").click()
Gui, Show
return   

Class Events  {
	onclick()  { 
		oevent := oDoc.parentWindow.event.srcElement
		tagname := oevent.tagname
		If tagname = input 
			ToolTip % !(oevent.checked + 1) ? "ON" : "OFF" 
	}
}

FixIE(Fix)  {
	Static Key := "Software\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
	If A_IsCompiled
		ExeName := A_ScriptName
	Else
		SplitPath, A_AhkPath, ExeName
	If Fix
		RegWrite, REG_DWORD, HKCU, %Key%, %ExeName%, 0
	Else
		RegDelete, HKCU, %Key%, %ExeName%
}

вот так выглядит скрипт уважаемого serzh82saratov.
Если поубирать все и открыть как хтмл - то таки да - виднеется очень красивый и плавный переключатель.
serzh82saratov - а может ли быть так, что у меня браузер по умолчанию Опера и от того у меня скрипт не работает как у всех нормальных?

18

Re: AHK: Gui+html+css

Надо чтобы IE был не ниже 9.

По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

19 (изменено: yarrroslav, 2016-05-26 00:16:04)

Re: AHK: Gui+html+css

serzh82saratov, Вы правы. Только что заглянул - у меня IE 8...