How to run Auto Hot Key file from web Page? - autohotkey

Is there any way to call or run .ahk files from web page using any of (HTML - JS - PHP)?
I need to start ahk files from my web pages on link or button clicks

Here is an example of how it can be done by using some evil activeX.
It used to be possible to access a users whole computer using activeX in the Internet Explorer. Nowadays ActiveX is mostly disabled. But we can still create .hta files to render html etc and these files allow the usage of activeX.
Try to save this as something.hta
<!DOCTYPE html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=9'>
<script language="JScript">window.resizeTo(200,100);</script>
<script language="JScript">
function runAhkScript() {
var ahkExePath = "C:/Program Files/AutoHotkey/AutoHotkey.exe";
var scriptToExecute = "C:/aaa/a.ahk";
new ActiveXObject("Shell.Application").ShellExecute(ahkExePath, scriptToExecute)
}
</script>
</head>
<body>
Run the autohotkey script
</body>
Adjust the path to your autohotkey.exe and your script and make sure you use forward slashes in the pathes.

You can not do that while accessing your web pages over a remote server (even localhost). If you access your web page on your local machine (i.e., typing "file:///C:/path/my web page.html" in the browser), and you use Internet Explorer as your browser, you might try:
<button onclick="window.open('file:///C:/path/my ahk script.ahk')">
Launch My AHK Script
</button>
Or, you may have to try it this way:
<button onclick="Process.Start('C:\path\my ahk script.ahk')">
Launch My AHK Script
</button>
(But maybe switch the slashes to "/" or add "file:\\" (trying with two or three slashes, and in each direction).
Hth,

Related

Logs are not shown when the webapp is triggered by doGet

I'm currently trying to write a form in HTML that passes its input to a spreadsheet. I did it as shown in the following video: https://www.youtube.com/watch?v=RRQvySxaCW0&list=PLv9Pf9aNgemt82hBENyneRyHnD-zORB3l.
The problem is that the Logger in addInfo() function isn't working when the button is clicked (In the Logs is no "Hey" when the button got clicked).
My Code.gs (Google Apps Script) file:
function doGet(){
return HtmlService.createHtmlOutputFromFile("index");
}
function addInfo(){
Logger.log("Hey");
}
My index.html file:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<button id="btn">Klick mich</button>
<script>
document.getElementById("btn").addEventListener("click",doStuff);
function doStuff(){
google.script.run.addInfo();
}
</script>
</body>
</html>
Is anyone knowing why it is not working like that?
I appreciate your help.
Best regards,
Max
Issue
The logs of triggers like doGet() cannot be seen from the Apps Script IDE Logger.
Solution
Follow these steps to achieve what you are aiming for:
Instead of Logger.log use console.log.
In your script editor go to Resources -> Cloud Platform Project.
Select the project you want to associate the script with. For that you will need to have previously created a project in the Google Cloud Platform and use its project’s number.
Once you have your script linked with the project, go to View -> Stackdrive Logging and there you will be able to see the console logs of the script including the ones in the trigger functions.
For more information regarding this process, check this post where they explain more extensively the use of the Stackdrive Logger for Apps Script.
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
I ran it as a dialog like this:

How do I open a browser window in a visual studio code extension?

I am writing a visual studio code extension and I'd like to be able to open a browser window with a specific url in response to a command. I know that Electron has a BrowserWindow class but it appears that the Electron API is not accessible from a vscode extension.
I'd prefer the browser window to open within the tool but I'd be ok with opening the web page in my default browser if it is not possible.
How does one open a web page from an extension?
This was added recently (see microsoft/vscode#109276).
Open the pallet (Ctrl + Shift + P)
Select "Simple Browser: Preview"
Enter web address
You can use the Live Preview extension from Microsoft:
[Deprecated] Browser Preview
To open a browser window inside VS Code you can use the WebView API, though you need to supply HTML content rather than a URL:
export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand('catCoding.start', () => {
// Create and show panel
const panel = vscode.window.createWebviewPanel(
'catCoding',
'Cat Coding',
vscode.ViewColumn.One,
{}
);
// And set its HTML content
panel.webview.html = getWebviewContent();
})
);
}
function getWebviewContent() {
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cat Coding</title>
</head>
<body>
<img src="https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif" width="300" />
</body>
</html>`;
}
Depending on your specific use case, there's also the Browser Preview extension which registers a command browser-preview.openPreview that you could use (you'd probably want to list browser-preview as a dependency to ensure it's installed).
And finally, if you just want to open in a normal browser window you can use the env.openExternal API. When running in remote environments this will also take care of exposing ports and mapping to the exposed hostname (if it's a localhost-served service):
vscode.env.openExternal(Uri.parse("https://www.stackoverflow.com/"));
Steps:
Open vscode
Click ctrl + shift + P
Search Simple Browser Show
enter your localhost URL
step1: Open command Palate {shift+ctrl+p}
step2: search for -> Simple Browser: view
step3: Click on it and Enter webLink what you want to view

Kentico 7 create content placeholder in Portal Master to use in ASCX in inherited page

Working in Kentico 7 on an Ad-Hoc page that inherits from Portal Master. I want to insert some literal script or code right before the </body> tag in the rendered ad-hoc page.
I thought I'd have to do this by editing the portal master and adding the following:
<cms:CMSPagePlaceholder ID="plcBodyEnd" runat="server">
<LayoutTemplate>
</LayoutTemplate>
</cms:CMSPagePlaceholder>
and then in the layout of the Ad-Hoc page do this:
<cms:CMSContent runat="server" id="cntLeft" PagePlaceholderID="plcBodyEnd">
<script type="text/javascript">
ProviderConnections.Transparency.initializeWidget({ });
</script>
</cms:CMSContent>
This worked fine until I went to the design tab on the Ad-Hoc page, where I got the following error:
Object reference not set to an instance of an object.
I don't want to register script blocks. I just want to put text in the Ad-Hoc page that goes there before the </body> tag, which is controlled by Portal Master.
What am I doing wrong?
I'm not 100% sure what you are trying to achieve. Giving an example or attaching a screenshot would be very helpful.
Here are the ways of attaching JavaScript in Kentico:
Through portal engine:
Use JavaScript web part - that gives you an option of choosing where the script should be located
Programmatically from code-behind:
Use CMS.Helpers.ScriptHelper API (wrapper around ASP.NET's ClientScriptManager)
ScriptHelper.RegisterStartupScript() to put the script at the end of the page
ScriptHelper.RegisterClientScriptBlock() to put the script before page's elements
The difference between the two is well explained here.
Programmatically from ASPX markup:
Put your <script> block to a desired location in your .aspx / .ascx files
Evaluate a code-behind variable containing script
<asp:Button ID="btnOK" runat="server" Text="OK" />
<script type="text/javascript">
<%= fieldWithActualScript %>
</script>

(ASP.NET 2008) opens the file within browser rather than showing a Open/SaveAs dialog

we have image files in IIS6.0 server, and wanted to open in browser using ASP.NET2008.
My problem is that it always shows the open/saveas dialog, but what I wanted is, it should open the file in the browser directly. we are using ASP.NET2008. It would be great if you provide the sample code.
thanks
You could try to embed those file(s) into a simple HTML page. This will make browsers display it without prompting the user.
Making your code output bare bones like:
<html>
<head><title>YOUR_IMAGE_NAME</title></head>
<body>
<img src = 'YOUR_IMAGE' alt='YOUR IMAGE DESC' />
</body>
</html>
to the browser should be sufficent.
HTH

Iframe Size problem in facebook iframe application

I have an iframe application which works fine but the issue comes when the content of iframe is large the text appears to be cut down.
I registered the application as iframe and set as resizable.
I have applied the following code but nothing seems to work
<div id="FB_HiddenIFrameContainer" style="display:none; position:absolute; left:-100px; top:-100px; width:0px; height: 0px;"></div>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["CanvasUtil"], function(){
FB.XdComm.Server.init(xd_receiver.htm);
FB.CanvasClient.setSizeToContent();
});
</script>
I have xd_receiver.htm file in myapp folder.
Please help me on this
In my iframe app I use
FB.CanvasClient.startTimerToSizeToContent();
instead of setSizeToContent() which seems to work for me.
Edit:
Can your javascript actually see the xd_receiver.htm file? Does it need a path (absolute or relative?) Is Apache serving static files from that directory?
What browsers have you observed the problem in? Try running in firefox with firebug installed to debug javasript problems. I'm not sure if the code you posted is actually what you're using, but it seems to be missing quotes on the "xd_receiver.htm" and also, no api key.
Regarding the xd_receiver.htm--> If the path to your callback url is callback, it should exist at callback/xd_receiver.htm. You have specified a relative path, so if your canvas page lives at /foo/page.htm, then the receiver page should exist at /foo/xd_receiver.htm. You could also specify at absolute path like '/xd_receiver.htm' and just keep your xd_receiver at the root.
Your page should look something like this:
http://gist.github.com/156633