Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHKCommandURL() - for volunteers in Ask for Help forum


  • Please log in to reply
6 replies to this topic
Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
WARNING: This is old thread. It is continued here.

This might be a little utility for those who are helping in Ask for Help forum. wink.png
 
; Examples - Select text (command name), and press a hotkey. Preserves clipboard.
F1::AHKCommandURL()
F2::AHKCommandURL("autohotkey.com", 1)


AHKCommandURL(Domain = "ahkscript.org", bold=0) {      ; by Learning one. http://www.autohotkey.com/board/topic/55484-ahkcommandurl-for-volunteers-in-ask-for-help-forum/
	/* What does it do examples:
	Input             Output
	StringReplace		[url=http://ahkscript.org/docs/commands/StringReplace.htm]StringReplace[/url]
	#SingleInstance		[url=http://ahkscript.org/docs/commands/_SingleInstance.htm]#SingleInstance[/url]
	*/
	
	if (Domain = "ahkscript.org")
		Prefix := "[url=http://ahkscript.org/docs/commands/"
	else if (Domain = "autohotkey.com")
		Prefix := "[url=http://www.autohotkey.com/docs/commands/"
	
	IsClipEmpty := (Clipboard = "") ? 1 : 0
	if (IsClipEmpty != 1) {	; not empty
		ClipboardBackup := ClipboardAll	; backup
		While (Clipboard != "") {	; empty
			Clipboard := ""
			Sleep, 20
		}
	}
	Send, ^c
	ClipWait, 0.1	; waits specifically for text or files to appear for 0.1 seconds
	SelectedText := Clipboard
	if SelectedText is space	; nothing to work with
	{
		Clipboard := ClipboardBackup
		if (IsClipEmpty != 1)	; was not empty
			ClipWait, 0.5, 1	; waits for data of any kind to appear on the clipboard for 0.5 seconds
		return
	}
	
	; here should be a check does command exist + some exceptions...
	TextInLink := SelectedText
	StringReplace, TextInLink, TextInLink,#,_,all	; exa: #SingleInstance, #If
	ToSend := Prefix TextInLink ".htm]" SelectedText "[/url]"
	if (bold = 1)
		ToSend := "[b]" ToSend "[/b]"
	Clipboard := ToSend
	Sleep, 50
	Send, ^v
	Sleep, 200
	Clipboard := ClipboardBackup
	if (IsClipEmpty != 1)	; was not empty
		ClipWait, 0.5, 1	; waits for data of any kind to appear on the clipboard for 0.5 seconds
}


MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Thanks! :D

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
There are one or two similar functions on the forum (didn't look but I think by sinkfaze and VxE - but could be wrong). Lexikos also quotes the help iin a 'fixed' format so he might have something as well.

I'm working on something that will allow you to post it like so

Sends a mouse button or mouse wheel event to a control.
Source: <!-- m -->http://www.autohotke...k.htm<!-- m -->



codybear
  • Members
  • 600 posts
  • Last active: Feb 09 2015 12:41 PM
  • Joined: 15 Sep 2009
This is awesome.
Thanks for this...
Can't wait for Hungov's version aswell.

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Thanks. :)

@hugov: Is this your script in action? :p

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
yes, and here as well <!-- m -->http://www.autohotke... ... ht=#367164<!-- m -->
It is part of a general purpose text tool with (interactive) searchable texts, but it is a secret project so don't tell anyone :wink:

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009

Added possibility to chose between ahkscript.org (default) and autohotkey.com domains


My Website • Recommended: AutoHotkey Unicode 32-bit • Join DropBox, Copy