Run Down
Hello, this is a very specific and situation question. Basically, I'm running Applescript in Automator on Safari, and the result is Null.
What I Have
I currently have a script that can do these things:
Before I even run the Automator program, I have Safari open
Next I run the Automator, which starts with this code:
on run {input, parameters}
tell application "Safari" to activate
tell application "System Events"
keystroke "t" using command down
end tell
return input
end run
This script will activate Safari, and open a new tab.
Next I have an Automator pause. This will give the page time to load
After the Safari page has opened, I run this code:
on run
clickID("75610556")
end run
on clickID(theId)
tell application "Safari"
do JavaScript "document.getElementById(‘” & theId & “‘).click();" in document 1
end tell
end clickID
This script should of selected the button with the ID "75610556", but it did not. This is the key problem with my program.
Next I run the following code:
on run {input, parameters}
tell application "Safari" to activate
tell application "System Events"
keystroke "w" using command down
end tell
return input
end run
This closes the current tab.
Next, I loop through with an Automator loop.
What I Would Like Help With
I will address my questions for the program step by step.
For step one, is this a good way to set things up? Is Automator even a proper way to go?
Is this code efficient? Any errors yet?
I really hope there is an alternative to this. I have not found one.
Why won't this work in Safari? I feel like I have done this right.
Same as number 2, just curious if this is the best way to handle this
I think this is a good way to do things.
Why I Need This + Every Single Detail (Optional Section)
These are extra details if you want them. It will give you nearly every detail, and explain why I need this.
So there is a business contest at my college. I'm a freshman programmer, and have programmed a very simple mobile networking game. The issue is there is a cash prize foe $3,000 on a poll website. This website is Poll Everywhere. The judges did not realize that this website is not secure in the slightest. We reported it, and the judges thought it was not good enough of a reason to cancel the poll and maybe search for a new alternative. We reported that Poll Everywhere can be manipulated to work to any teams advantage who was smart enough to:
A. Turn off cookies for their browser
B. Use a private browser
But of course, the judges did not listen. They thought that if somebody stayed up all night, it might change it, but during a 2-3 hour period, it will have little effect. To deter their ruling, I would like to make an example program for them on my Mac that will blow their minds: A voting program. This program will open safari. Safari has already been configured to open the voting page in private browser mode. All my program has to do is open a new tab, find the button ID, and click on it. The faster it does this the better.
Final note: Was the back story too much? I know Stack overflow has a "spare the details" policy. I thought the elaborate version might help, but if it is a bad thing I will remove it.
Unfortunately I don't have a lot of time to answer all your questions as it's late and I need to get to bed, but here is an example of all you need to do. No need for automator, that just seems to complicate your process to me.
You may want to tweak some of the sleep settings a little if you need more "wait" time, I tried this on my local web server and it worked, but it's local so the site loads very fast.
on run
set i to 1
repeat until i > 5
do shell script "sleep 2"
tell application "Safari"
activate
tell window 1
set properties of current tab to {URL:"http://yoururl.com"}
end tell
end tell
do shell script "sleep 3"
tell application "Safari"
tell document 1
do JavaScript "document.getElementById(\"75610556\").click();"
end tell
quit
end tell
set i to i + 1
end repeat
end run
Also note, you'll need to change the url to your url where it says "http://yoururl.com" and you'll probably want to change the 5 in repeat until i > 5 to a larger number to let it repeat more.
Related
In my database (Access 2013, .accdw), I am checking the user's current version in the Form_Open event. If it is not up to date it triggers an external command to download a fresh copy and then is supposed to close itself to allow for the update. The problem is that after Application.Quit is triggered, access closes but instantly reopens, blocking the download. I've stripped out all the code I can to isolate the problem.
If 1 = 1 Then
Application.Quit
End If
Simplified pretty far, right? It should always just close as soon as the form is opened. With this as the only code in my Form_Open event which is the only code in the form, it still closes, reopens, and then closes again. Docmd.Quit has the same effect. I've tried too many variations to enumerate. In a button this code works fine, but I need it to run the check before it loads any data (the linked tables may be being altered while we change versions).
Any ideas how to make it stay closed the first time it closes?
I think it reopens because your external code (.bat file ?) reopens it. It's not an Access problem. Have you checked the numerous tools you can find for Access automated client deployment ? Here are the first 2 I found:
http://www.databasejournal.com/features/msaccess/article.php/3286111/Automatically-Deploy-a-New-Access-Client.htm
http://www.devhut.net/2015/06/30/ms-access-deploying-your-database-front-end-to-your-users/
Your code works for me in a Form_Open(), but then this is Access 2010 and no Sharepoint.
You may have better luck by Creating an AutoExec macro that calls an initialization function that does the version check, instead of having a form open automatically.
If the version check is ok, then open your start form from the function.
The easy work-around is to always fetch the current version and then launch it.
This way there's no fuzz and the user always run the latest version.
I have an MS Access form, and on a button click it runs VBA code to run the Shell Command.
private sub cmdOpen_click()
dim vValue as String
vValue = Listbox.column(1) 'Retrieving a path name from a list
shell "C:\Adobe's Path\Arco.exe " & vValue
end sub
When I first run this script the first time I open this database, it stops running, opens the script editor, and highlights the shell line. There is no error code, in fact if I just hit the Run button it finishes just fine. If run it a second time there is no issue. Only when I close it down and reopen it.
No there is no Breakpoints/stops in the code. Would anyone have any idea why this is happening? I can't seem to fine anyone else with a similar issue.
I have had issues with this in Access 2010. I found that there was a breakpoint on that line, and for some reason Access seemed to remember it even after closing the application. For me, it usually happened when I fixed code and someone else ran it.
The only thing I found that seemed to fix it was to set a breakpoint on that line, save the project, then clear it and save it again. Sometimes I had to open and close the project once or twice to get it to completely forget the breakpoint was there.
It seems to me that it's a random, esoteric bug in the Access IDE. It would be fantastic if they would actually make this a feature, but it's not even a bug that can be relied on.
I've had similar experiences with Access and what always helped for me is to copy the text into a Notepad .txt file (or other basic text processing program). Then select it all in the .txt and copy it back.
Decompiling the Access application will solve this too.
Previous SO question: How does one decompile and recompile a database application?
I'm relatively new to batch commands and have been learning steadily. My problem is like this:
I've understood how to kill processes using batch commands using many different methods. However, I've been unable to figure out how to close a single tab in, preferably, chrome.
Any thoughts would be greatly appreciated!
Thanks!
So, I suppose I should state my exact problem.
I'm using notepad++ as my LaTeX compiler and sending the final pdf to chrome. The reason: I usually have ~20 tabs open related to the project I'm working on and it just makes my work much easier to split my screen between notepad++ and chrome.
My current batch file compiles the LaTeX code and sends the compiled document to chrome as a new tab. For obvious reasons, i don't want to close a tab each time I compile, so I thought that closing the current tab at the same time during compiling would solve my problem. But, I just can't find a way to get my batch file to only close the tab with my compiled pdf.
Thanks in advance!
check all running chrome instances/tabs with :
wmic process where "caption='chrome.exe'" get
and see processes properties.Probably the best indicator that you can rely on in this case is CreationDate (other properties are basically the same for all chrome instances) - it always comes in format YYYYMMDDHHmmss.ms and is easy for string comparison.But you'll have to know the time when it was started.
It seems like lately I have been having been getting hung up on the auto-completion drop down when using the console in Chrome DevTools. It seems like it has suddenly gotten more aggressive. I have never had a problem with the feature until the other day when I was trying to enter commands into the console quickly in order to test things. I wasn't sure why it wasn't working right. when I'd hit Enter auto-completion kept popping up and not executing what I typed. At first it seems as if auto-completion was activating whenever I would hit Enter to execute my code. However, it began to look like it was only popping up when I would end a statement with ;.
For example, typing the following statement into the console and pressing Enter would not cause the autocomplete drop down to activate:
console.log('did it')
However, if I add a semicolon then as soon as I press ; a number of milliseconds later the autocompletion feature immediately pops up:
console.log('did it');
At this point if I press Enter it will simply select the first entry, $, and add it as the next statement so we get:
console.log('did it');$
I know this is not really a big deal, after all, the only reason you would need the semicolon is for entering in multiple statements. However, I feel like in the past I've always added a semicolon ; to the end of simple single test statements such as the console.log shown above not activated the auto-completion, being able to execute it by just hitting Enter.
I definitely feel like my console's auto-completion is being activated more aggressive than it used to.
Has anyone else felt like the auto-completion in the console is activating too often all of the sudden? I am wondering whether or not this could have actually been changed in Chrome or if somehow I have made my console start acting this way with a setting or something?
While writing this I noticed that it seems not to only be after ; that auto-completion seems to pop up when it hadn't before. If you refer to Chrome DevTools - Using the Console you'll see that auto-completion is only referred to once:
The Console attempts to evaluate any JavaScript expression you enter at the shell prompt, upon pressing the Return or Enter key. The Console provides auto-completion and tab-completion. As you type expressions, property names are automatically suggested. If there are multiple properties with the same prefix, pressing the Tab key cycles through them. Pressing the right arrow key accepts the current suggestion. The current suggestion is also accepted by pressing the Tab key if there is only one matched property.
After this it goes on to say that we can use Shift+Enter in order to enter a multi-line expression and it gives the following example:
(source: google.com)
This is something I know for sure I have done plenty of times in the past with no problems from auto-completion. When I try to type the code in the above image I get as far as:
var add = function (val1, val2) {
Then when I press Shift+Enter instead of going to a new line like I am positive it did before (for me at least). Apparently anytime a new statement is started it will pop up. Has anyone else started getting highly annoyed at this feature as of very recently? Does anyone know if there's a way I could have caused this behavior?
Whoever answered my question before deleted their answer. I would like to close the question as it has been answered. This is indeed a bug as stated in the comments above and on the deleted answer. Anyone else that is here because they are experiencing problems as well will have to wait for the release to make it down to their version of Chrome, with Canary getting it first of course. You could presumably install an earlier version of Chrome to get around this as well. I know this is not directly about coding, but I see no reason to close it now when others may find the information useful.
Link to the Chrome Issue referencing this problem: https://code.google.com/p/chromium/issues/detail?id=263925
I don't know if this will help, but i enabled logging to a text file called test.txt on my C Drive.
Public Sub Main()
Dim rowsProcessed As Integer = 100
Dim emptyBytes(0) As Byte
Dts.Log("Testing, Test 1,2,3", rowsProcessed.ToString, emptyBytes)
Dts.TaskResult = ScriptResults.Success
End Sub
You have to go into the SSIS->Logging menu and tick checkboxes like a crazy checkbox-ticking-ninja to get this to work.
There are various checkboxes that have to be checked, and some of them only appear when you click on the script tasks, so it took me a while to figure this out:
First, enable your logging provider (that you have set up, right?) by ticking it on the Providers and Logs tab.
Then switch to the Details tab (which shows various events that you might want to log)
For the DTS.Log() method you need the ScriptTaskLogEntry event, but they only show up when you click on Script Tasks in the tree on the left.
So, click each of your Script Tasks in the tree on the left, enable it for logging, and then tick the Script Tasks event on the details tab.
Also make sure your logging provider is ticked for each script task
See also: http://msdn.microsoft.com/en-us/library/ms136131.aspx
This is an old question and #codeulike has answered it well but I would like to add a note about the logging behavior in debug mode, specially for someone new to SSIS or SSIS logging (like me) - Assuming you have all the configuration in place required for logging, if execute a selected task that you expect to log, it still will not log. Only if you execute (or debug) the entire package, then the logging will work.
If you are sure you have done configured everything correctly and still cant see your dbo.sysssislog in the database you selected, then check in the following
YourDatabase > tables > system tables
you can find your loggings there.
its my first time doing package loggings and configured everything correctly and could not see that dbo.sysssislog in the database it was supposed to do loggings and banging my head for half an hour when i realised it was in system tables of that particular database.
I realize that this question is rather old, but maybe it helps someone.
I ran into the same problem - while debugging in Visual Studio my textfile logging provider just did not write into the configured logfile.
My logfile was in the directory "project-directory/bin/development".
After changing the path to "project-directory-name"-root (eg. "/project-directory-name/test.txt" it worked.
I cannot explain this - it is just what I have observed.