| View previous topic :: View next topic |
| Author |
Message |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Tue Aug 07, 2007 8:27 pm Post subject: Check if inputbox input is empty or not ? |
|
|
Hi, I'm trying to find out how I can make the script end without doing anything else, if the variable is left empty OR the ESC-key was pressed during the Inputbox showing.
This is the first line of the script, but I have no idea how to get what I want...
| Code: | | InputBox, searchstring, Search what?, Search Websites for what ? |
|
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Tue Aug 07, 2007 8:51 pm Post subject: |
|
|
| Code: |
InputBox, searchstring, Search what?, Search Websites for what ?
If ErrorLevel = 1
Msgbox cancel was hit or the box was closed
else if searchstring =
Msgbox There was nothing Entered!
Else
Msgbox, you entered %searchstring%
|
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Tue Aug 07, 2007 8:56 pm Post subject: |
|
|
Great! Thanks engunneer !
I had the following to work, but I assume your method will probably be better. The following does what I want though :
| Code: | InputBox, searchstring, Search what?, Search Websites for what ?
If Errorlevel OR !searchstring {
EXIT
}
MsgBox, You entered %searchstring%
|
|
|
| Back to top |
|
 |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Tue Aug 07, 2007 9:39 pm Post subject: |
|
|
Darn, problems again. I want the entered text in inputbox to be 'included' in an url which I then can open as a command-line for the browser.
Here's what I currently have :
| Code: | InputBox, searchstring, Search what?, Search Websites for what ?
If Errorlevel OR !searchstring {
EXIT
}
Stringreplace, searchstring, searchstring, %A_SPACE%, +, All
Website1search := http://www.website1.com/search.php?mode=results?search_keywords=%searchstring%&search_terms=all&search_forum=-1&search_time=0&search_fields=titleonly&sort_by=0&sort_dir=DESC&show_results=topics&return_chars=200
|
But I get "Illegal characters in variable" error.
I think the problem is the = and & chars in the variable assignment, is there some way I can correctly construct a variable which includes those = and & characters ?
TIA ! |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1163 Location: Denmark
|
Posted: Tue Aug 07, 2007 9:42 pm Post subject: |
|
|
Using := you must include strings in " and concatenate with .
Try using just =
| Code: | | Website1search = http://www.... |
_________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Wed Aug 08, 2007 12:04 am Post subject: |
|
|
Thanks, all I need to know is how do i replace a certain string with another one in a text file that isn't opened. I've search the forum but could only find some rather old snippets which probably don't work anymore/could be much more easier to do.
Say I want to open 2 files thisfile1.txt & file2.txt
Replace the occurence of replacethisthing with correctinfo in both files.
...and overwrite the 2 files with the corrected versions. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Wed Aug 08, 2007 12:14 am Post subject: |
|
|
FileRead
StringReplace
FileRecycle
FileAppend _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Wed Aug 08, 2007 12:20 am Post subject: |
|
|
Thanks a lot !  |
|
| Back to top |
|
 |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Wed Aug 08, 2007 1:29 am Post subject: |
|
|
| Just one last Q. How can I use the & symbol as part of prompt in an inputbox ? The helpfile is really clumsy in pointing people to special chars etc... |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Wed Aug 08, 2007 2:34 am Post subject: |
|
|
please give an example of how you want to use it. & should not be special. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Wed Aug 08, 2007 9:57 am Post subject: |
|
|
| engunneer wrote: | | please give an example of how you want to use it. & should not be special. |
Hi engunneer, I have the following line :
| Code: | InputBox, searchstring, Search what?, Search Google(a comma should be here) Betanews (a & should be here) DOpus sites for what ?
|
|
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1163 Location: Denmark
|
Posted: Wed Aug 08, 2007 10:19 am Post subject: |
|
|
| Quote: | AutoHotkey's default escape character is accent/backtick (`), which is at the upper left corner of most English keyboards. Using this character rather than backslash avoids the need for double blackslashes in file paths.
Since commas and percent signs have special meaning in the AutoHotkey language, use `, to specify a literal comma and `% to specify a literal percent sign. One of the exceptions to this is MsgBox, which does not require commas to be escaped. Another exception is commas in the last parameter of any command: they do not need to be escaped. See #EscapeChar for a complete list of escape sequences.
Certain special characters are also produced by means of an escape sequence. The most common ones are `t (tab), `n (linefeed), and `r (carriage return). |
_________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
Smikkel
Joined: 10 Jul 2007 Posts: 23
|
Posted: Wed Aug 08, 2007 10:25 am Post subject: |
|
|
| tonne, the comma `, works, the `& doesn't. |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1163 Location: Denmark
|
Posted: Wed Aug 08, 2007 10:31 am Post subject: |
|
|
Maybe a bug!?
This works however:
| Code: | | InputBox, searchstring, % "Search what?, Search Google`,Betanews & DOpus sites for what ?" |
_________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
|