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 

AutoHotKey Expression Examples: "" %% () and all t

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



Joined: 08 Mar 2008
Posts: 64
Location: Santa Barbara

PostPosted: Sun Mar 01, 2009 4:11 am    Post subject: AutoHotKey Expression Examples: "" %% () and all t Reply with quote

AutoHotkey Expression Examples: "" %% () and all that.

because I can never get them right, so I made this.
Originally this was just going to be about IF statements (see sections H: , I: ), then it just started growing...

CONTENTS:

A: RETRIEVING COMMAND LINE PARAMETERS
B: COMMON THINGS AT THE BEGINNING OF AUTOHOTKEY SCRIPTS
C: WHEN TO USE %% AROUND VARIABLES x,%x%,(%x%)
D: ERASE A VARIABLE
E: SET A VARIABLE (:=) [store numbers, quoted strings]
F: SET A VARIABLE (=) [assign unquoted literal strings]
G: COPY A VARIABLE
H: IF STATEMENTS with ()
I: IF STATEMENTS without () [Translate the 1st, take the 2nd literally]
J: CHECK FOR A BLANK VARIABLE
K: STRING MANIPULATION
L: NUMBERS
M: FILE NAMES
N: REGULAR EXPRESSIONS
O: MISC AUTOHOTKEY NOTES, DEBUGGING TIPS
P: MISC AUTOHOTKEY SCRIPTS
Q: NAVIGATING WEB SITES
R: NEWBIE RECOMMENDED LEARNING SEQUENCE
S: Press ESC to cancel this scipt
T: THE AUTOHOTKEY RUN COMMAND
U: PASSING PARAMETERS TO AUTOHOTKEY SCRIPTS
V: PASSING PARAMETERS TO ANY PROGRAM


NOTE: ALL VARIABLES ARE STORED AS CHARACTER STRINGS !!!
Strings containing numbers are converted to numbers when needed, and the result is converted back to a string.

NOTE: Closing */ must be first thing on line. Otherwise you'll be asking yourself, "Why does my script stop running at this point, as if the whole rest of the script was commented out?"


Version 1.21 (08/24/2009)
Web page:
http://www.autohotkey.net/~deleyd/xprxmp/autohotkey_expression_examples.htm
or download the older obsolete .ahk version from:
http://www.autohotkey.net/~deleyd/xprxmp/autohotkey_expression_examples.ahk
Example of Navigating a Website:
http://www.autohotkey.net/~deleyd/xprxmp/WebsiteNav.ahk


(It's now too long to post all of it here.)

My title: "" %% (), And All That, is taken from the wonderful book, Div, Grad, Curl, And All That: An Informal Text on Vector Calculus by H. M. Schey (1973)

History:
Version 1.00 02/28/2009
Version 1.04 03/08/2009
Version 1.05 03/09/2009
Version 1.09 03/26/2009
Version 1.10 04/30/2009
Version 1.12 05/15/2009
Version 1.14 05/24/2009
Version 1.19 06/01/2009
Version 1.21 08/24/2009


Last edited by deleyd on Tue Aug 25, 2009 5:27 am; edited 16 times in total
Back to top
View user's profile Send private message Visit poster's website
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Sun Mar 01, 2009 4:53 am    Post subject: Reply with quote

Helpful!

Thanks for this.

You should consider doing some kind of clickable index version.

Perhaps if I have some time I will try Wink.
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Back to top
View user's profile Send private message
deleyd



Joined: 08 Mar 2008
Posts: 64
Location: Santa Barbara

PostPosted: Sun Mar 08, 2009 12:00 pm    Post subject: Reply with quote

Version 1.04 03/08/2008
Added part A: WHEN TO USE %% AROUND VARIABLES
Code:
/*
WHEN TO USE %% AROUND VARIABLES
LESSON #1 on %%:
The only place to use %x% is where a literal string NOT enclosed in
double-quotes is expected. Otherwise, don't use %% around a variable name.
*/
;Notice in the following examples that unquoted literal strings are expected.
; = assigns unquoted literal strings
n = Ishmael
x = Call me %n%
MsgBox Call me %n%

;Example
x = 500
y = 500
z = 10
MouseMove, 500, 500, 10           ;works
MouseMove, 500 - 1, 500 + 1, 10   ;works
MouseMove,  x, y, z               ;works
MouseMove,  x - 1, y + 1, z + 2   ;works

;However, this doesn't work, because MouseMove
;doesn't expect an unquoted literal string
MouseMove, %x% - 1, %y% + 1, 10   ;doesn't work


;CONFUSION IS CAUSED BECAUSE THE FOLLOWING HAPPENS TO ALSO WORK
MouseMove, %x%, %y%, %c%          ;works

;The above works because "for backward compatibility, command parameters
;    that are documented as "can be an expression" treat an isolated name
;    in percent signs (e.g. %Var%, but not Array%i%) as though the percent
;    signs are absent."
;        --AutoHotkey Documentation: Variables and Expressions


/*
LESSON #2 on %%:
Use (%x%) when x contains the name of a 2nd variable which in
turn contains the contents you want.
*/
a = 500    ;a = "500"
b = 200    ;b = "200"
x := "a"
y := "b"
MouseMove, (%x%), (%y%)            ;x = a, a = 500.  y = b, b = 200
MouseGetPos, xpos, ypos
MsgBox xpos=%xpos%  ypos=%ypos%    ;xpos=500  ypos=200
Back to top
View user's profile Send private message Visit poster's website
closed



Joined: 07 Feb 2008
Posts: 509

PostPosted: Sun Mar 08, 2009 12:02 pm    Post subject: Reply with quote

wooow thanks
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Thu Mar 12, 2009 5:16 pm    Post subject: good candidate for scriptlet library Reply with quote

A handy interface for this might be the Scriptlet library tool

Scriptlet Library v4
http://www.autohotkey.com/forum/viewtopic.php?t=2510

should also move this thread to "scripts & functions" forum
________
IMPREZA WRX


Last edited by webber on Thu Mar 10, 2011 11:30 pm; edited 2 times in total
Back to top
View user's profile Send private message
fincs



Joined: 05 May 2007
Posts: 1162
Location: Seville, Spain

PostPosted: Thu Mar 12, 2009 6:40 pm    Post subject: Reply with quote

It's AutoHotkey, (that 'k' is lowercase) Smile
Anyway, nice tutorial for newbies Very Happy
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
deleyd



Joined: 08 Mar 2008
Posts: 64
Location: Santa Barbara

PostPosted: Sat May 16, 2009 12:29 am    Post subject: Reply with quote

Added sections H2: & I2:
COMPARING NUMERIC VALUES VS. COMPARING STRINGS

It's also available as a web page now.
Back to top
View user's profile Send private message Visit poster's website
deleyd



Joined: 08 Mar 2008
Posts: 64
Location: Santa Barbara

PostPosted: Thu Aug 27, 2009 2:00 am    Post subject: Reply with quote

added these new sections:

T: THE AUTOHOTKEY RUN COMMAND
U: PASSING PARAMETERS TO AUTOHOTKEY SCRIPTS
V: PASSING PARAMETERS TO ANY PROGRAM

also added a new essay,

How Command Line Parameters Are Parsed
How to escape the special characters in your parameters
with numerous examples.

_________________
http://www.autohotkey.net/~deleyd/xprxmp/autohotkey_expression_examples.htm
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
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