AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New Variable for Selected Content in Foremost Window

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  

Would such a variable be useful to you?
No, I'd rather always use clipboard variables
33%
 33%  [ 1 ]
Yes, it would be more efficient
66%
 66%  [ 2 ]
Total Votes : 3

Author Message
instantrunoff



Joined: 13 Jan 2008
Posts: 63

PostPosted: Mon Apr 21, 2008 12:41 am    Post subject: New Variable for Selected Content in Foremost Window Reply with quote

It would be nice to have a variable such as A_Highlighted that would allow replacing the following:
Code:

>!k:: ; Look selection up in Wikipedia
        gosub backupclip
        Run, http://en.wikipedia.org/wiki/Special:Search?search=%Clipboard%
        gosub restoreclip
        Return
backupclip:
      ClipSaved := ClipboardAll   ; Save the entire clipboard to a variable of your choice.
              clipboard = ; clear clipboard
         Send, ^c
         ClipWait, 1
         IfEqual, ErrorLevel, 0
         return
         else
         {
         gosub restoreclip
         exit
         }
   
   restoreclip:
       Clipboard := ClipSaved   ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
       ClipSaved =   ; Free the memory in case the clipboard was very large.
       return

With something like this:
Code:
>!k::Run http://en.wikipedia.org/wiki/Special:Search?search=%A_Highlighted%


I think for the A_Highlighted variable to be more reliable and refer to the foremost window that might not be active, there might have to be fancier coding that the above AHK workaround.


Last edited by instantrunoff on Mon Apr 21, 2008 1:38 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Spymaster101



Joined: 22 Mar 2008
Posts: 2

PostPosted: Mon Apr 21, 2008 1:28 am    Post subject: Reply with quote

that actually sounds good, this would mean that there would be no need to copy it to the clipboard. Smile
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Mon Apr 21, 2008 1:37 am    Post subject: Reply with quote

I think in the meantime a function wrapping the workaround would work best as this is used fairly regulary.

Something like.
Code:
^r::Run,% "http://www.google.co.uk/search?source=ig&hl=en&rlz=&q=" copyhighlighted()

copyhighlighted(){
Clipsaved:=ClipboardAll
Clipboard:=""
Send,^c
Clipwait,1
temp:=Clipboard
Clipboard:=Clipsaved
Return temp
}
*Untested

This would reduce code length in multiple calls, although I agree a hardcoded solution would probably work much better.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Last edited by Superfraggle on Mon Apr 21, 2008 10:33 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Lexikos



Joined: 17 Oct 2006
Posts: 2359
Location: Australia, Qld

PostPosted: Mon Apr 21, 2008 9:19 am    Post subject: Reply with quote

Spymaster101 wrote:
that actually sounds good, this would mean that there would be no need to copy it to the clipboard. Smile
In that case, how would A_Highlighted work? Copying to the clipboard is the most compatible method available.
Superfraggle wrote:
...although I agree a hardcoded solution would probably work much better.
Other than allowing built-in variable syntax, how could it work better?
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Mon Apr 21, 2008 6:51 pm    Post subject: Reply with quote

Lexicos, I just thought a hard coded version would allow for easier calling. I.e no need to force expression mode.

And I thought it would probably perform slightly faster. I was under the impression that the direct coding of such a feature would perform slightly quicker. Although I bow down to your greatness so correct me if im wrong Very Happy
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Lexikos



Joined: 17 Oct 2006
Posts: 2359
Location: Australia, Qld

PostPosted: Mon Apr 21, 2008 10:13 pm    Post subject: Reply with quote

The inclusion of ClipWait makes it likely that both will perform very similarly. The overhead of six lines of script (and a function call) is negligible.

It would be more convenient and maybe faster, but not any more functional. It would still rely on ^c copying something to the clipboard. (Btw, maybe ClipWait should have a timeout...)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group