AutoHotkey Community

It is currently May 26th, 2012, 1:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 55 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: March 5th, 2005, 2:21 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2005, 10:50 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2005, 7:35 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Thanks Rajat,
I'll incorporate that in the script.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 12:52 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 1:33 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
thanx for pointing that out! ...it needed a StringLen. i'll check the new script as soon as i get back to my pc.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2005, 8:27 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
i checked it out... it really kicks ass!
i think all it needs is remembering settings b/w sessions (ini functions). great work! Image

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2005, 10:10 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2005, 10:40 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
What a great Script. Case-correction would make it perfect and it should be distributed with AutoHotkey.

Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2005, 12:28 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2005, 2:46 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi,

it does not work, even with F2 or dragging a file. "winwait" should get "WinWait", right?

Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2005, 3:05 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Could you post an example?
It should work.

Have you tried it with other commands? Does it work then?

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2005, 5:06 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2005, 6:09 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
If you could post an example, I can try to reproduce it.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2005, 12:27 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2005, 2:21 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 55 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group