 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
deleyd
Joined: 08 Mar 2008 Posts: 64 Location: Santa Barbara
|
Posted: Sun Mar 01, 2009 4:11 am Post subject: AutoHotKey Expression Examples: "" %% () and all t |
|
|
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 |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Sun Mar 01, 2009 4:53 am Post subject: |
|
|
Helpful!
Thanks for this.
You should consider doing some kind of clickable index version.
Perhaps if I have some time I will try . _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
deleyd
Joined: 08 Mar 2008 Posts: 64 Location: Santa Barbara
|
Posted: Sun Mar 08, 2009 12:00 pm Post subject: |
|
|
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 |
|
 |
closed
Joined: 07 Feb 2008 Posts: 509
|
Posted: Sun Mar 08, 2009 12:02 pm Post subject: |
|
|
| wooow thanks |
|
| Back to top |
|
 |
webber
Joined: 25 Aug 2005 Posts: 129
|
Posted: Thu Mar 12, 2009 5:16 pm Post subject: good candidate for scriptlet library |
|
|
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 |
|
 |
fincs
Joined: 05 May 2007 Posts: 1162 Location: Seville, Spain
|
|
| Back to top |
|
 |
deleyd
Joined: 08 Mar 2008 Posts: 64 Location: Santa Barbara
|
Posted: Sat May 16, 2009 12:29 am Post subject: |
|
|
Added sections H2: & I2:
COMPARING NUMERIC VALUES VS. COMPARING STRINGS
It's also available as a web page now. |
|
| Back to top |
|
 |
deleyd
Joined: 08 Mar 2008 Posts: 64 Location: Santa Barbara
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|