Jump to content


Photo

IE AutoOpen


  • Please log in to reply
2 replies to this topic

#1 silveredge78

silveredge78
  • Members
  • 499 posts

Posted 08 September 2007 - 05:01 PM

I found a couple variations on this in my reading of this forum, but I have tweaked it a bit for my own use, and then for a user's particular uses.

I have all comments in the and changes in the code.

; AutoHotkey script
; Script Name:	IE AutoOpen
; Version:	1.0.2
; Author:	silveredge78
;
; The purpose of this script is to allow for easy opening of IE URL's
; with or without an additional string on the end.  This allows some sites
; to be easily called with a search string (ie: Google, Yahoo, etc).
;
; Changelog:
; Version 1.0.2, 09/18/07
; - Fixed a bug that if someone cancels out of the InputBox, it did not 
;   reset the clipboard back to its original contents.
;   - Moved the ErrorLevel check to after the Clipboard restore
;
; Version 1.0.1, 09/18/07
; - Added in conversion of clipboard to text if possible to fix an issue 
;   of not being able to use the original clipboard if it was text-like
;   in the InputBox.
;   - Added variable TextClip to store this converted text.
;   - Removed AcquireIEClip and RestoreClip subroutines to give more 
;     specific control of the Clipboard, and moving all appropriate 
;     commands to inside the function itself.
;
; Version 1.0.0, 09/12/07
; - Per user request, added functionality by allowing for a Ctrl+Enter in
;   the InputBox which then prepends "www." and appends ".com" before
;   calling IE.
;   - Used lexikos's suggestion of using GetKeyState in relation to the 
;     InputBox and watching for 'Control' being depressed
;   - Adjusted the If clause to only work with a blank URL variable to 
;     prevent appending.
;
; Version 0.9.0, 09/06/07
; - Per user request, moved the RestoreClip routine to before the InputBox
;   in order to allow for pasting into the text field if needed.
; - Per user request, changed the InputBox title to be the %Desc%.
; - Removed the Canceled MsgBox entirely, cleaned up code accordingly.
;
; Version 0.8.0, 09/02/07
; - Per user request, adding specific funcationality to calls for allowing
;   an InputBox to prompt for any possible changes to the URL/search string 
;   to be opened.
; - Added second variable to IEAutoOpen() of Desc to allow for a more 
;   descriptive InputBox prompt. This allows it to be hotkey called specific
;   as the URL passed is already.
; - Used same AcquireClip subroutine, but commented out the error on the 
;   ClipWait, using it instead to allow for empty pastes, which results in 
;   a blank %Default% in the InputBox on generation.

#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines, -1
SendMode, Input

; IE AutoOpen Hotkeys==============================================
#w::IEAutoOpen("URL","")  					;;AutoOpen Link
#g::IEAutoOpen("Google search","www.google.com/search?q=")  	;;AutoOpen Google and Search
#p::IEAutoOpen("Yahoo","profiles.yahoo.com/")  			;;AutoOpen Yahoo Profiles Link

; Functions========================================================
IEAutoOpen(Desc,URL)		; v1.0.2, 09/18/07
{
  ClipSaved := ClipboardAll	; Save the entire clipboard to a variable of your choice.
  Clipboard = %Clipboard%
  TextClip = %Clipboard%  
  Clipboard = 
  Send, ^c
  ClipWait, 1
  IEClip = %Clipboard%
  Clipboard = %TextClip%
  InputBox, URLString, %Desc%, Please enter the %Desc% string to be opened in IE:, , , , , , , , %IEClip%
  If (GetKeyState("Control")) And (URL = "")	; Suggested by Lexikos
    URLString = www.%URLString%.com		; Suggested by Lexikos
  Clipboard := ClipSaved	; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
  ClipSaved =			; Free the memory in case the clipboard was very large.
  If ErrorLevel <> 0
    Return
  Run, iexplore.exe %URL%%URLString%
}


#2 silveredge78

silveredge78
  • Members
  • 499 posts

Posted 12 September 2007 - 06:56 PM

Updated to version 1.0.0.

Changelog:
Version 1.0.0, 09/12/07
- Per user request, added functionality by allowing for a Ctrl+Enter in the InputBox which then prepends "www." and appends ".com" before calling IE.
- - Used lexikos's suggestion of using GetKeyState in relation to the InputBox and watching for 'Control' being depressed
- - Adjusted the If clause to only work with a blank URL variable to prevent appending

Script updated in original post.

#3 silveredge78

silveredge78
  • Members
  • 499 posts

Posted 19 September 2007 - 11:56 PM

Updated to version 1.0.2

Changelog:
Version 1.0.2, 09/18/07
- Fixed a bug that if someone cancels out of the InputBox, it did not
reset the clipboard back to its original contents.
- - Moved the ErrorLevel check to after the Clipboard restore

Version 1.0.1, 09/18/07
- Added in conversion of clipboard to text if possible to fix an issue
of not being able to use the original clipboard if it was text-like
in the InputBox.
- - Added variable TextClip to store this converted text.
- - Removed AcquireIEClip and RestoreClip subroutines to give more
specific control of the Clipboard, and moving all appropriate
commands to inside the function itself.

Script updated in original post.