I'm looking for a way to close all the user's active browser for only during the installation. After the installation finishes, I'd like the browsers to return to their previous state with all the tabs they had.
I looked here: Close All Browser In Nsis
And I tried adding something like ExecShell "open" "chrome.exe" but it doesn't seem to open the browsers with the previous tabs.
Any ideas? thanks!!
You can use nsProcess plugin
For Chrome
Function CloseRestoreChrome
${nsProcess::FindProcess} "chrome.exe" $IsRestoreChrome
StrCmp $IsRestoreChrome 0 0 +3
logex::Write "$dt Chrome running."
${nsProcess::KillProcess} "chrome.exe" $R0
;Dow your work here
${If} $IsRestoreChrome == 0
StrCpy $path "$LocalAppData\Google\Chrome\Application\chrome.exe --restore-last-session"
exec $path
logex::Write "$dt Chrome restored"
${EndIf}
FunctionEnd
Similarly you can Find and Kill process of Firefox and IE.
Closing browser(s) is simple by using Kill Proc plug-in.
But be careful with it - every time give the user a chance to saved his work at least with Message Box (Yes/No/Cancel).
When browser is closing it should save all tabs and whole session automatically. If not then it must be configured in settings (which is of course different for every browser) to do it.
Changing settings automatically can be done via configuration file (for Chrome it is called Preferences) but this is a pretty rude.
So if browser is configured to save/load all tabs automatically this will work for you.
Related
I'm trying to switch between virtual desktops on win10 using the XButton1 and XButton2 of my mouse.
So far this is working quite alright, except the fact that when I have for example Firefox as my active scope, obviously those buttons are used to go forward/backward (problem appears in every window using these buttons for something).
This seems to prevent AHK from either noticing that I used the configured trigger or not executing the script (which I believe is less likely).
For Firefox I found a workaround by disabling the use of these buttons in the [about: config](about config) page by setting mousbutton.4th.enable and mouse button.5th.enable to false but this won't work for everything since there isn't always a way to disable these buttons.
I have tried to use the mouse-wheel tilting buttons as well but the default usage oh them is even more common in the programs I'm working with.
Here is the script I am using.
# NoEnv; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
XButton1::Send ^#{Left}
XButton2::Send ^#{Right}
return
If someone has a workaround or a completely different idea (for example a totally obvious Win10 feature/setting I'm missing) I would be absolutely happy.
You can define custom combinations for those two keys in your script
e.g.
XButton1 & LButton::return ; do nothing
; or another action:
; XButton1 & LButton:: Run notepad
XButton1::Send ^#{Left}
XButton2 & a::return
XButton2::Send ^#{Right}
This way the keys lose their native function in the programs.
For details, see Custom Combinations.
EDIT:
If a program is running with admin privileges, then AHK won't intercept the key presses, and that could very well be the reason behind this problem.
If that is the case, try to run the AHK script as administrator by adding this to the auto-execute section (top of the script):
; If the script is not elevated, relaunch as administrator and kill current instance:
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try ; leads to having the script re-launching itself as administrator
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
https://autohotkey.com/docs/commands/Run.htm#RunAs.
When in need to use AHK the solution from user3419297 works perfekt.
Another way to accomplish the same result is to use X-Mouse Button Control.
Simply set Mouse Button 4/5 to Simulated Keys: with {CTRL}{LWIN}{RIGHT} and {CTRL}{LWIN}{LEFT}.
I was trying to implement a robot framework automation test for a sign-in page.when I run with IE browser the session wasn't closing for the 1st user and the user is in login even after using "Delete All Cookies" keyword for the 2nd user.This is only happening for IE11 browser and rest of the browsers(chrome, Firefox and Edge) are working fine.
*** Settings ***
Library Selenium2Library
Library OperatingSystem
*** Variables ***
${url_google} https://accounts.google.com/signin
${local_ie_driver}
D:${/}PortableApps${/}SeleniumIEWebDriver${/}IEDriverServer.exe
*** Test Cases ***
Google for macarronada using IE
Set Environment Variable no_proxy 127.0.0.1
Set Environment Variable webdriver.ie.driver ${local_ie_driver}
Open Browser ${url_google} ie
Sleep 2s
Input Text //*[#id='identifierId'] xxxxxxxx#gmail.com
Click Element //*[#id='identifierNext']/content
Sleep 2s
Input Text //*[#id='password']/div[1]/div/div[1]/input abc123xxx#
Click Element //*[#id='passwordNext']
Delete All Cookies
Close Browser
Any Idea ? Has anyone else seen this issue or similar with robot framework?
Internet Explorer by default "shares" session between multiple windows and tabs. Try this option to open new Internet Explorer windows
https://answers.microsoft.com/en-us/ie/forum/ie11-windows_7/new-session-shortcut-for-ie11/1b3e6408-abcd-4dea-8afa-acb7b15e8f71 (i.e., the -noframemerging command line argument for opening Internet Explorer windows). It worked for the situation I was having which is similar to the situation you are presenting.
Let us know if it worked for you.
So, I'm making a sort-of web installer. It gets to the part where it says "Connecting..." and then simply just waits a while.. then fails because of a timeout.
Script for it is here.
NSISdl::download "https://www.dropbox.com/s/b65bvezj2u58872/ns_fwl_byps.dll?dl=1" "$INSTDIR\ns_fwl_byps.dll"
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit
The link works perfectly fine in a web browser.
Preferably I would like to use NSISdl, so I'd like a workaround for this problem rather than suggesting another plugin.
NSISdl does not support HTTPS, use Inetc...
(NSISdl works all the way back to Win95 and just uses plain sockets, Inetc uses WinInet like Internet Explorer)
I have a proprietary software that I use to download some confidential data from the internet, this software is the only way to access that data.
The software opens up with a screen and then I have to click on "download" and the download commences. I would like to download this data late-night (say 0200 Hrs) every night. The downside was that I had to sit in front of the laptop to "click" on the download button.
So, I wrote an AutoIt script to open the software, wait for 30 seconds so that the software finishes the initialisation routine and then "go to" a certain location (co-ordinates) on the screen and execute a "mouseclick()". I then created a "scheduled task" using windows task scheduler to run this autoit executable at 0200 Hrs. Every thing works fine, as expected.
Autoit executable runs well when the user is "active". But if the user is "locked" (i.e. lock screen) then it is stuck in "WinActivate()" waiting for the user to become "Active" and resumes from there on after the user becomes "active". This means the laptop has to be in unlocked mode overnight which is not advisable for security reasons. I then found out that I could use "ControlClick()" to do the same when the screen is locked.
My problem now is that when I use AutoIt Window Info tool, it does not show the CLASS or any info related to download button when I hover over the download button. So, may be the screen is a flash screen or something else that was intentionally made to make sure that button CLASS was not seen!
An option would be to take a screenshot, find the location and then send the coords to Mouseclick() but that could easily get way more complicated considering different screen resolution on different machines (in case this gets ported to another machine etc etc)
Any suggestions and solutions?
WinActivate() will wait until the user is activated to activate the window and then return and it is a blocking function in this case so avoid it. Keep your VB application in the background, not minimized and remove WinActivate() function. ControlClick doesn't need the window to be active.
This should work with the right handle name and class name:
HotKeySet("!{s}", "_exit")
Local $count = 0
Local $handle
While $count < 3
Sleep(5000)
$handle = ControlGetHandle("name", "", "[CLASS:ThunderRT6FormDC]") ;add name as well if there is one
If $handle Then ;check if handle exists
ConsoleWrite("Handle exists" & #LF)
ControlClick($handle, "", "[CLASS:Classhere]", "left", 1, 191, 115) ;add a class if exists
EndIf
ConsoleWrite("Try: " & $count & " times" & #LF)
$count += 1
WEnd
Func _exit()
ConsoleWrite("Exiting!" & #LF & "Tried: " & $count & #LF)
Exit
EndFunc
The informations you gave me from the autoit info tool arent enough. Use some other tool to get more information.
Spy++ is a great tool. Try it out and come back with more information about the windows handle name and classes.
And again you are giving a few informations about your code. This example should performe a control click but you may have other function besides winactivate that will block your script again
Edit: Added Tesseract OCR UDF: http://www.autoitscript.com/forum/topic/89542-tesseract-screen-ocr-udf/
How to correctly restart firefox (without any "restore session" things and with the same windows as before) from code?
I know pid of "firefox-bin" in a bash script process and I have my custom plugin loaded into it.
Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
const nsIAppStartup = Components.interfaces.nsIAppStartup;
Components.classes["#mozilla.org/toolkit/app-startup;1"]
.getService(nsIAppStartup)
.quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
Note that this applies to Firefox 4 so the code might be slightly different for earlier versions.