Code Monkey home page Code Monkey logo

webapp.ahk's Introduction

Webapp.ahk

"AHK-Webkit" / Webapp.ahk - Library for developing web-based apps with AutoHotkey. (Actually uses IE [Trident])
Released under the MIT License

Getting started

Webapp.ahk projects should have one AutoHotkey script (*.ahk) file. See Example.ahk. This file must have the following in the header:

#Include Lib\Webapp.ahk
__Webapp_AppStart:
;<< Header End >>

Note: Do not change the working directory; Webapp.ahk handles it. Aurelain's Exo is planned to be intergrated into Webapp.ahk. Custom functions maybe added easily. See the provided example html and ahk files.
Important!: It is strongly recommended to include the following meta tag in the html files:
<meta http-equiv='X-UA-Compatible' content='IE=edge'>

A Webapp.ahk project must have a webapp.json configuration file.

{
  "name":                   "My App",
  "width":                  640,
  "height":                 480,
  "protocol":               "app",
  "protocol_call":          "app_call",
  "html_url":               "index.html",
  "NavComplete_call":       "app_page",
  "Nav_sounds":             true,
  "fullscreen":             true,
  "DPI_Aware":              true,
  "ZoomLevel":              100,
  "AllowZoomLevelChange":   true
}
  • Width & Height: Webapp.ahk allows window resizing just like any other application. The width and height options here are to set the application's starting size.
  • The name option is the text that will be displayed in the title bar. It can be changed on run-time with setAppName().
  • The html_url option is the starting HTML file for the App to launch with. It defaults to index.html if none is specified.
  • The protocol option is for filtering URL prefixes such as whether to run a function when a link like app://msgbox/hello is clicked.
  • The protocol_call option is the name of the function in your AutoHotkey that will run in these cases. It defaults to app_call() if none is specified.
  • The NavComplete_call option is the name of the function in your AutoHotkey that will run when a page is finished loading. Its first argument is the new page's URL. It defaults to app_page() if none is specified.
  • The Nav_sounds parameter (boolean) is optional. If left unspecified, it defaults to false. The Navigation sounds correspond to the sounds made by IE during navigation such as the infamous "click" sound.
  • The fullscreen parameter (boolean) is optional. If left unspecified, it defaults to false. This sets whether the application should start in fullscreen or as a window of the specified size (Width & Height).
  • The DPI_Aware parameter (boolean) is optional. If left unspecified, it defaults to true. This sets whether the application should do zoom level auto-correction based on the system's DPI.
  • The ZoomLevel option is the percent scaling for the App to launch with (e.g. specify 200 for 200% scaling). It defaults to 100 if none is specified.
  • The AllowZoomLevelChange parameter (boolean) is optional. If left unspecified, it defaults to true. This sets whether the application should allow users to change the zoom level with either Ctrl +/- or Ctrl Wheel Up/Down.

Note: For example, if protocol is set to myapp and a myapp://test/1234 link is clicked, the set protocol_call function will be called and will receive test/1234 as its first argument. If protocol is set to *, the set protocol_call function will run for ANY link clicked and it will receive myapp://test/1234 (the whole URL) as its first argument. This is not recommended for most cases, as links with href="#" will also trigger the function (usually unwanted behaviour).

Special thanks

A special thanks to Coco, VxE, Lexikos, Phatricko, MrBubbles and the AutoHotkey community.

webapp.ahk's People

Contributors

joedf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webapp.ahk's Issues

Which version of IE is used?

I want to know which features (HTML / CSS / JavaScript) are available. For that I need to know the version of IE.

Tried searching, but didn't find anything.

JS page load function not being run when changing pages

Hey there,
I have been playing around with this and love it!
I have encountered an issue where the jquery (or JS for that matter) page on load functions only run when the application is loaded and not each time you change between pages.

Similarly the "app_page" function runs each time but doesnt run JS functions after the initial page load.

example:

$(function() {
		BuildDropDowns();
	});

This runs when page is loaded first time but when I click a link to another page and then come back the function no longer runs

Thoughts?

What is the best practice for JS interaction?

for GUI, it's a necessity it seems. I have some checkboxes that work with materialize, and unless I add some sleeps before and after I run the update function (which updates from certain hotkeys being pressed), otherwise the checkboxes won't update. Now, I would debug js with a console, but it seems there isn't one... lol. I'm not sure if this is just an issue with materialize. Not sure any other way to update

sendJS(js) {
wb := getDOM()
wb.Navigate("javascript:" . js)
}

And, my update code, and yes, please laugh because it looks disgusting as I tried many ways to make if faster, sometimes it wouldn't update at all. I did try to interact with the DOM directly with wb but that didn't seem to make much of a difference, and it didn't trigger the animations that make the radio boxes appear active/inactive

updateToggles(afk,tram,gard){
	wb := getDOM()
	sleep, 50
		if(!afk && !tram &&  !gard)
	{
			sleep, 150
		sendJS("clearStatus();")
		
		OutputDebug Cleared
}else{
	if(afk && wb.Document.getElementById("afk-switch").checked != afk)
	{
			sendJS("updateStatus('a', true)")
		OutputDebug Updated AFK
	}else if(tram && wb.Document.getElementById("trampoline-switch").checked != tram)
	{
			sendJS("updateStatus('t', true)")
			OutputDebug Updated Trampoline
	}else
	if(gard && wb.Document.getElementById("garden-switch").checked !=gard)
	{
		sendJS("updateStatus('g', true)")
	}
}
sleep, 250
}
<ul class="tabs tabs-transparent tabs-fixed-width" style="height:auto;">
			<li class="tab"><a href="#main" class="active">Main Page</a></li>
			<li class="tab" id="atab"><a href="#afk">Anti-AFK</a><input class="with-gap" name="toggles" type="radio" id="afk-switch" /><label for="afk-switch">CTRL+SHIFT+1</label></li>
			<li class="tab" id="ttab"><a href="#trampoline">Trampoline Bot</a><input class="with-gap" name="toggles" type="radio" id="trampoline-switch" /><label for="trampoline-switch">CTRL+SHIFT+2</label></li>
			<li class="tab" id="gtab"><a href="#garden">Gardening Bot</a><input class="with-gap" name="toggles" type="radio" id="garden-switch" /><label for="garden-switch">CTRL+SHIFT+4</label></li>
			<li class="tab"><a href="#fishing">Fishing Hack Guide</a></li>
    </ul>
function updateStatus(control,status){
			if(control == "t"){
				$('#ttab input').prop("checked", true)
			}else if(control == "a"){
				$('#atab input').prop("checked", true)
			}else if(control == "g"){
				$('#gtab input').prop("checked", true)
			}else{
				console.log("$('" + control + "').prop('checked'," + status + ")");
			$(control).prop("checked",status);
			}
		}
		function clearStatus(){
			$('.tabs input:radio').removeAttr('checked')
		}

What about scaling?

KEYDOWN(wParam, lParam) {
	...
	if(GetKeyState("CTRL") && (wParam=187 || wParam=189)) ;CTRL+ CTRL-
		return
	...
}
WM_MOUSEWHEEL(wParam, lParam) {
	if(GET_KEYSTATE_WPARAM(wParam)=8)
		return 1
}




GET_KEYSTATE_WPARAM(wparam) {
	return (wparam & 0xFFFF)
}

Why dont return value from global variable, ON LOAD PAGE?

When I use a gloval variable from AHK for load with the page, does not work

Have any Idea?

Example?

global test := "Simple Test"`

app_page(NewURL) {
	wb := getDOM()
	if InStr(NewURL,"index.html") {
		Sleep, 10
		x := wb.document.getElementById("ahk_info")
		x.innerHTML := GetAHK_EnvInfo()
	}
}
GetAHK_EnvInfo(){
	return "IP: " . A_IPAddress1 . %test%
}

HTML

<p><small id="ahk_info"><small></p>

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.