 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Sat Mar 05, 2005 1:21 pm Post subject: |
|
|
Hi Rajat,
I already had some problem when comparing the first command in my code due to case sensitivity. I just got around that by making all lower char in the code. I know that "=" should be case-insensitive, but somehow it wasn't, I never tracked it down.
Currently I only see a chance to do the case correction for the first command. All following parameters will be difficult, because where can you get them from? The keywords.txt file is not structured enough to get them out of it. And you have to make sure that you only capture the right keyword for that first command. Might be a tricky loop. Have a try, I'm open.
The case correction for variable names should be easy, you can get them from the syntax file and they are nearly unique. So a loop over all of them and replace them with the right case is easy.
For the Keys I think a limit as you proposed should be set because some of them are not unique enough (might be on a normal text), otherwise it is same as variable names. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1687
|
Posted: Sun Mar 06, 2005 9:50 am Post subject: |
|
|
| Code: | SetWorkingDir, %A_ScriptDir%
RegRead, ahk_dir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir
if ErrorLevel <> 0 ; Use a best guess location instead.
ahk_dir = %ProgramFiles%\AutoHotkey
IfNotExist %ahk_dir%
{
MsgBox Could not find the AutoHotkey folder.
ExitApp
}
FileDelete, %A_ScriptDir%\Out.ahk
FileRead, AHKCommands, *t %ahk_dir%\Extras\Editors\Syntax\CommandNames.txt
FileRead, AHKVars, *t %ahk_dir%\Extras\Editors\Syntax\Variables.txt
AutoTrim, Off ;to save indentation
;reading the dropped script line by line
Loop, Read, %1%, %A_ScriptDir%\Out.ahk
{
CurrLine = %A_LoopReadLine%
;Change Command Name Cases
Loop, Parse, AHKCommands, `n
{
;a limit check
IfLess, A_LoopField, 5, Continue
IfInString, CurrLine, %A_LoopField%
StringReplace, CurrLine, CurrLine, %A_LoopField%, %A_LoopField%, A
}
;Change Variable Cases
Loop, Parse, AHKVars, `n
{
;a limit check, but this one takes into care vars like A_DD
IfNotInString, A_LoopField, a_
IfLess, A_LoopField, 5, Continue
IfInString, CurrLine, %A_LoopField%
StringReplace, CurrLine, CurrLine, %A_LoopField%, %A_LoopField%, A
}
FileAppend, %CurrLine%`n
} |
this is a standalone script. u can drop a script with incorrect cases on it. if u feel fine then it can be adapted for your script.
i've only put in commands and vars for now... it can be extended.
and by the way, as your script already detects commented lines, we can maybe exclude those from this function. _________________
 |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Sun Mar 06, 2005 6:35 pm Post subject: |
|
|
Thanks Rajat,
I'll incorporate that in the script. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Mon Mar 07, 2005 11:52 am Post subject: |
|
|
Hi Rajat,
Did you ever tested your code?
It seams to me that it wouldn't work correctly, since | Code: | | IfLess, A_LoopField, 5, Continue | would do an alphabetic comparison, right?
I have changed the first post:
- Added new functionality to script: a)Case Correction, b) Gui remembers Position on screen
- Script name and Post title have changed to reflect these changes _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1687
|
Posted: Mon Mar 07, 2005 12:33 pm Post subject: |
|
|
thanx for pointing that out! ...it needed a StringLen. i'll check the new script as soon as i get back to my pc. _________________
 |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1687
|
Posted: Mon Mar 07, 2005 7:27 pm Post subject: |
|
|
i checked it out... it really kicks ass!
i think all it needs is remembering settings b/w sessions (ini functions). great work!  _________________
 |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Wed Mar 09, 2005 9:10 am Post subject: |
|
|
Please see first post for changed script.
Edit: 2005-03-09:
- Added new functionality: Gui remembers settings between sessions
- Hotkey has changed to F2
- Fixed: Indentation within a editor was damaged, due to `r`n at end of line (thanks AGU)
- Fixed: Indentation within a editor added additional ´n each time
- Improved speed (setbatchline) _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 814 Location: Germany
|
Posted: Wed Mar 09, 2005 9:40 am Post subject: |
|
|
What a great Script. Case-correction would make it perfect and it should be distributed with AutoHotkey.
Tekl |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Wed Mar 09, 2005 11:28 am Post subject: |
|
|
Dear Tekl,
Case-correction is already in the script. Check it out.
Or do you have something different in mind by | Quote: | | Case-correction would make it perfect |
_________________ Ciao
toralf  |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 814 Location: Germany
|
Posted: Wed Mar 09, 2005 1:46 pm Post subject: |
|
|
Hi,
it does not work, even with F2 or dragging a file. "winwait" should get "WinWait", right?
Tekl |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Wed Mar 09, 2005 2:05 pm Post subject: |
|
|
Could you post an example?
It should work.
Have you tried it with other commands? Does it work then? _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 814 Location: Germany
|
Posted: Wed Mar 09, 2005 4:06 pm Post subject: |
|
|
Hi,
the Loop-Command works for example, but I thought all will get the case as used in the documentation like stringtrimright -> StringTrimRight. Well I've seen, that the syntax-files will be used and they're correct. Also the paths are correct.
Tekl |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Wed Mar 09, 2005 5:09 pm Post subject: |
|
|
If you could post an example, I can try to reproduce it. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 814 Location: Germany
|
Posted: Wed Mar 09, 2005 11:27 pm Post subject: |
|
|
Hi,
I tried this an a different computer:
| Code: | regread, ahk_dir, hkey_local_machine, software\autohotkey, installdir
if errorlevel <> 0 ; use a best guess location instead.
;ahk_dir = %programfiles%\autohotkey
ahk_dir = c:\programme\autohotkey
ifnotexist %ahk_dir%
{
msgbox could not find the autohotkey folder.`nplease edit script.
exitapp
}
gosub, readsyntaxfiles
|
and I'll get this
| Code: | regread, ahk_dir, hkey_local_machine, software\autohotkey, installdir
If ErrorLevel <> 0 ; use a best guess location instead.
;ahk_dir = %programfiles%\autohotkey
ahk_dir = c:\programme\autohotkey
Ifnotexist %ahk_dir%
{
msgbox could not find the autohotkey folder.`nplease edit script.
exitapp
}
gosub, readsyntaxfiles
|
Tekl |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Thu Mar 10, 2005 1:21 pm Post subject: |
|
|
Thanks Tekl,
I found the problem: During copy and paste a "x" happend to be right in front of the "String" variable, so that the Name of the variable was changed and the case correction had no strings to work with.
It is now fixed in the script.
Thanks also to AGU for pointing out a spelling mistake in the GUI. Also Fixed.
And Thanks to all for the feedback. _________________ Ciao
toralf  |
|
| 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
|