I was using a relatively simple applescript to automate clicking on two buttons in Google Chrome. It was working for weeks but has now stopped randomly without me changing anything. Here is the code I was using:
...
set loc1 to {1200, 400}
set loc2 to {1000, 600}
repeat 30 times
tell application "System Events"
tell process "Google Chrome"
set newest to true
delay 0.2
click at loc1
delay 0.1
click at loc1
delay 0.1
click at loc2
end tell
end tell
end repeat
...
After some experimenting I can still click on the tabs at the top of the chrome browser, but I can no longer click on any buttons/elements on the webpage. Any thoughts on things I can try?
Thanks!
#mrstuckguy, I see your question has no answer yet. I think you'd probably be better off just using Greasemonkey-style user scripts (JavaScript) to interact with HTML elements. Check Tampermonkey for example. You have a lot of examples on the web of how to interact with HTML buttons such as those pesky Cookie Banners. If you need help with an annoying popup just ask.
You'd add in a user scripts manager something like this:
setTimeout(() => {
var elements = document.querySelectorAll('a-moving-target-button')
elements.forEach((element) => {
if (element.textContent == 'I Agree') { element.click() }
})
},1000)
You should be aware, however, that the layout of these button-elements keeps changing and redact them respectively.
Related
hi im using laravel 8 and my software is pos ..
everything working so good but i have big problem ..
thats sometimes the cashier can refresh the page when the customer is gone without save the invoice
..
so what i did is this ..
document.addEventListener('keydown', (e) => {
e = e || window.event;
if(e.keyCode == 116)
{
var is_admin = $("#is_admin").val();
if(is_admin != 1)
{
e.preventDefault();
// this code here will not allow f5 to work
}
}
});
but the cashiers goes to the address bar and hit enter and like that he refresh the page
also sometimes they hit the refresh button beside url bar
so i start chrome in kisok mode in full screen
but the problem thats he can move the mouse to the top of the browser and the url bar will show again and he can do refresh page ..
so the solution for my problem is there any way to set password in chrome when refresh the page or close the chrome or is there any way to start chrome without close bar and url bar in kisok mode
thanks ..
Based on my research I didn't find anything related to setting a password in chrome for closing, instead, I have other solutions that may help you by considering this closing/refreshing issue happens accidentally.
#1st Solution - Closure Extension
https://chrome.google.com/webstore/detail/closure/jjagagcgljmlnihcilbpbfcglnopepjb
a very simple extension that works by locking the current browser tab. Click the toolbar icon or right-click on a page and select “Confirm Closure”. The favicon for the website in the current tab will turn into a padlock.
if the cashier clicked on the refresh button or the closing button a confirmation popup will show up.
#2nd Solution - Disable Close Button
checkout these 5 software that claims to prevent accidental closing of software by disabling the close button
https://www.raymond.cc/blog/prevent-program-closing-disabling-close-button/
#3rd Solution - Saving Draft.
The last solution I have is a workaround you can make by using
window.addEventListener('beforeunload', function (e) {
// saving current invoice in localstorage to be retrieved later
});
// check this answer
// https://stackoverflow.com/questions/13443503/run-javascript-code-on-window-close-or-page-refresh
beforeunload event, so you can save a draft of the current invoice in locale storage before closing the window, but you are should be very aware of how to manage these drafts, when to retrieve them, and when to clean them.
Also, you can use service workers if you choose this kind of solution.
Again, this all about if the cashier accidentally makes this behavior, which I think he must be aware of what he is doing, so you are making your validations as you can to prevent such behavior and make your system as robust as possible, I encourage you to think of this problem in a technical way then you should take the 3rd solution, and for the client just offer him the other 2 solutions which I see they will work well, otherwise, if the client wants to make something wrong in purpose then it will be his responsibility.
I have spent the better part of a day researching this, but still have no freaking clue where to even begin!
Basically all I want to do is add a button to the DevTools toolbar that injects the entire DevTools window into an arbitrary page as a div or iframe, so that I can manipuate that with hover/click event handlers to show/hide it more easily.
Working on a 13" laptop with no option to buy a second monitor (I am dirt poor, hence the need to do this and get my web dev business up and running), makes this an absolute necessity. It is so frustrating to have to constantly expand/collapse the window or undock it and move it around to be able to inspect and change arbitrary parts of a page simultaneously.
As mentioned before, I have spent ~2 hours scouring the DevTools Protocol docs, ~3 hours trying to build my own Chromium from source before my hard drive ran out of space, and countless hours researching this topic on other sites. But Chrome is such a massive and complicated beast that I am utterly baffled by the overly-simplistic DevTools extension API docs and other incomplete resources that I've found.
Could anyone shed some light on this for me? I've gotten so far as creating a DevTools extension with the following devtools.js:
chrome.devtools.panels.create('\u25b2\u25bc', '', 'panel.html', function(panel) {
panel.onShown.addListener(function() {
chrome.extension.sendMessage({
tabId: chrome.devtools.inspectedWindow.tabId,
action: "code",
content: "var newItem = document.createElement('div'); // Create a new div node\n" +
"newItem.innerHTML = '<p>Boo!</p>';" +
"var body = document.getElementsByTagName('body')[0]; // Get the body element to insert the header into\n" +
"body.insertBefore(newItem, body.childNodes[0]); // Insert header before the first child of the body"
});
});
});
That adds a panel, which when switched to inserts the div correctly, but even that tiny amount of progress took ~4 hours to make!! Am I just the world's worst web developer, or is this API the most complicated and poorly-documented one ever created?! Some help to make the button actually do what I want would be very much appreciated!
I'd also like to know whether the extension route is the best one for me to follow, or should I be using the DevTools protocol? That seems to be much more powerful, but all the talk of "remote debugging" and "external clients" on the aforementioned docs page just confuses me even more (can't i just mimic the DevTools locally in my own browser since I'm already running Apache locally?).
MTIA and apologies for the long-winded question!
open a new tab in Chrome (opens http://google.com for example)
open a testpage.htm containing history.pushState({},"test","#lightbox");
which changes the url to testpage.htm#lightbox
if you hit the back button of your chrome the url is changed to http://google.com, which is two states back, not one
firefox and msie10 work both good, so it's a chrome issue
how can i fix this? is there a workaround?
thank you in advance
(feel free to give my question a better title and feel free to correct my english)
notes:
on step 2 you can also use window.location.hash = "#lightbox" but does the same issue
on step 3 you can simulate the back button from within your code, using history.back() and in this very case the url is switched to the correct one testpage.htm, so this is related only to the back button of Chrome's gui
I also tried
window.addEventListener("popstate", function(ev){ ev.preventDefault(); });
window.addEventListener("hashchange", function(ev){ ev.preventDefault(); });
without success :(
Update 2: does the same using History.js
I want to have a sound repeat periodically when there is a new message in the Google Voice Inbox. So far what I've come up with is to have the GV Inbox always open in chrome, and have the following script running:
100:
IfWinExist, Google Voice - Inbox (
SoundPlay, C:\Users\Terry's\Desktop\chimes.wav, wait
Sleep, 1000
Goto 100
If there is a new message, the title of the GV tab is "Google Voice - Inbox (1) - Google Chrome" and if there are no new messages, the "(1)" is missing, so that's why the search string for IfWinExist includes one a "(".
This only works, however, when the GV tab has the attention within chrome (it will work when chrome is minimized or another window is active, as long as GV is the selected tab within chrome). But if another tab within chrome has the attention, then it won't work, and I can't figure out how to make it work. I've tried Adjusting SetTitleMatchMode, but that's all I could come up with to mess with. Any ideas would be greatly appreciated.
Have you tried the AutoHotKey Windows Spy to see how the GV is identified? This is what you will need (and it will most probably be the string you already have) Then set SetTitleMatchMode to 2 (find string anywhere in title). You could try to experiment with "escaping" the "open bracket".
Please don't use Sleep but launch a timer. I temporarily changed the sound back to something I know works. Once this works, you can make a change back to SoundPlay and remove the MsgBox.
Pseudo Code
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2
SetTimer, CheckWin, 10000 ; Run CheckWin every 10 seconds.
CheckWin:
IfWinExist, Google Voice - Inbox (
{
MsgBox, Alert
SoundBeep, 700, 700
}
Return
I am starting my internship on a Home Server able to control mutliple domotics equipments from a web page. The global idea is that based on a click on a button, a certain script is spawned on the server and controls a microcontroller.
My tutor built a simple website he gave me, using AJAX to always stay on 1 page, and brings the menus according to user actions (they are hidden if not used, brought back to front if used).
I have set up an apache server which I configured to execute CGI scripts, and it works.
To always stay on one page, I used the '204 No Content' return trick, so that the server's answer to the page is 'I don't have anything to say, just stay on this page'.
But the one problem I have is that the CGI is launched only once. If I click the button for the first time it works, afterwards nothing happens.
I tried using the SSI (shtml) to use the in a button code instead of using a FORM with GET method but the script still won't execute twice.
I might be using the wrong tools. Should I keep going with CGIs ? Or is there something else (like AJAX, jquery) that actually is designed to do what I want ?
Thanks for having read.
EDIT : I have found a way around it (it's always when I'm desperate after looking for days for an answer that I go to forums and then find myself a nice solution in the next hour .... )
I used a basic link, and for some reason it has a different behaviour than using a button. Whatever. My interrogations on the technologies used still stand though :)
EDIT2 : My solution is crappy, for some reason the script is also called at page refresh (or when the page loads for the first time). It's strange, because since it's in the it should only be spawned when I click on it ...
Familiarize yourself with jQuery and its AJAX API. You can't make it not load a new page unless you use AJAX. Here is an example of what an AJAX call looks like:
$.ajax({
url: 'http://server.domain.com/cgi-bin/myfile.cgi',
data: {
x: 1,
today: '20110504',
user: 'Joe'
}
}).success(function(data, status, xhr) {
if (data)
alert(data);
});
That is for jQuery 1.5 or higher. You can run that whenever a certain button is clicked like this:
HTML for the button:
<input type="button" id="doThis"/>
JavaScript:
$(function() {
$('#doThis').click(function() {
//put AJAX sample shown above, here
});
});