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 

Cursor-highlighted variable

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
mAdDoG



Joined: 29 Dec 2004
Posts: 62

PostPosted: Mon Mar 14, 2005 12:23 am    Post subject: Cursor-highlighted variable Reply with quote

Hi guys, me again-

How can I turn "cursor-highlighted text" into a variable?
_________________
-buttons, buttons,...
I like to push all the buttons!!!
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Mon Mar 14, 2005 12:26 am    Post subject: Reply with quote

Here's a part of my script.

Code:
  ;Save and clear clipboard
  ClipSaved := ClipboardAll
  Clipboard =

  ;Cut highlight to clipboard
  Send, ^x

  ;If nothing is highlighted, select all and cut
  If Clipboard is Space
    {
      ;Select all and cut to clipboard
      Send, ^a^x
    }

  ;get rid of all carriage returns (`r).
  StringReplace, ClipboardString, Clipboard, `r`n, `n, All

  ;restore the original clipboard and free memory
  Clipboard := ClipSaved
  ClipSaved =

_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Mon Mar 14, 2005 7:11 pm    Post subject: Reply with quote

Is this what you meant?
Code:
!z::                       ; Alt-z hotkey
ClipSaved := ClipboardAll  ; Save original clipboard
Send ^c                    ; highlighted text to clipboard

VarName := ClipBoard       ; Name of the new variable
%VarName%= your_value      ; Since you didn't know the variable name
                           ; at writing the script, you have to use %...%
Clipboard := ClipSaved     ; Restore original clipboard
ClipSaved =                ; Free memory
return
Select some text, press Alt-z and you have a new variable with the selection as its name. Your script can only access it with indirection (%VarName%), because you did not know the name of the variable at the time of writing the script.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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