Search found 616 matches

by afe
25 Nov 2020, 06:04
Forum: Ask For Help
Topic: When to use study option (S) of regular expressions? Topic is solved
Replies: 2
Views: 69

When to use study option (S) of regular expressions? Topic is solved

The study option (S) can sometimes improve the performance of a regular expression that is used many times (such as in a loop).
Does this mean that just using this option in a loop can improve performance?
by afe
25 Nov 2020, 05:45
Forum: Ask For Help
Topic: How to quickly remove the file name in the path? Topic is solved
Replies: 6
Views: 141

Re: How to quickly remove the file name in the path? Topic is solved

Smile_ wrote:
22 Nov 2020, 08:29

Code: Select all

path := "C:/TEST/a.txt"
filename := "a.txt"
Msgbox % RegExReplace(path, "\\?/?" filename,"")
so easy! I didn't expect it. But to avoid files with the same name in the path, add a $ at the end.

Code: Select all

path := RegExReplace(path, "/" . filename . "$")
by afe
25 Nov 2020, 05:33
Forum: Ask For Help
Topic: How to quickly remove the file name in the path? Topic is solved
Replies: 6
Views: 141

Re: How to quickly remove the file name in the path? Topic is solved

mikeyww wrote:
22 Nov 2020, 08:19

Code: Select all

fpath = /TEST/a.txt
fpath := StrReplace(fpath, "/", "\")
SplitPath, fpath,, dir
dir := StrReplace(dir, "\", "/")
MsgBox, #%dir%#
Wonderful, I didn't expect to replace it first. But both are 0ms, so the string should be too simple.
by afe
22 Nov 2020, 03:26
Forum: Ask For Help
Topic: How to quickly remove the file name in the path? Topic is solved
Replies: 6
Views: 141

Re: How to quickly remove the file name in the path? Topic is solved

Thanks, SplitPath is very good, but if making a slight change, like the following

Code: Select all

/TEST/a.txt
The expected result is
/TEST
by afe
22 Nov 2020, 03:12
Forum: Ask For Help
Topic: How to quickly remove the file name in the path? Topic is solved
Replies: 6
Views: 141

How to quickly remove the file name in the path? Topic is solved

Code: Select all

path := "C:\TEST\a.txt"
filename := "a.txt"
; Method 1
RegExReplace(path, "\\[^\\]+$")
; Method 2
SubStr(path, 1, InStr(path, filename, true, -1, 1) - 2)
The expected result is
C:\TEST

One uses RegExReplace and the other uses SubStr and InStr. Will the latter be faster?
by afe
18 Nov 2020, 07:44
Forum: Ask For Help
Topic: How to make the Gui have no focus?
Replies: 4
Views: 69

Re: How to make the Gui have no focus?

What if there is no button? In other words, the focus must exist, but it is moved to other controls.
by afe
17 Nov 2020, 05:20
Forum: Ask For Help
Topic: How to make the Gui have no focus?
Replies: 4
Views: 69

How to make the Gui have no focus?

When opening an AHK Gui, if there is an Eidt control, the focus may be set on it. How to make it not set the focus or set the focus on the menu, such as the file menu. But the menu does not have Text and ClassNN attributes.
by afe
16 Nov 2020, 12:50
Forum: Ask For Help
Topic: The menu command cannot be used in the ? : operator? Topic is solved
Replies: 6
Views: 106

The menu command cannot be used in the ? : operator? Topic is solved

2 >1 ? ( Menu, MenuName, Disable, Value1 ) : ( Menu, MenuName, Disable, Value2 ) Why is this invalid? 1 = 0 ? a() : b() return a() { msgbox 1 return } b() { msgbox 2 return } And why doesn't this call the b function? Why would the b function be called when changed to the following? Really weird? x ...
by afe
16 Nov 2020, 11:15
Forum: Scripts and Functions
Topic: MCode4GCC -- C/C++ to MCode Generator
Replies: 116
Views: 36114

Re: MCode4GCC -- C/C++ to MCode Generator

Is it possible to use it to encrypt ahk source code and how to do it?
by afe
16 Nov 2020, 10:39
Forum: Ask For Help
Topic: How to use mcode to encrypt source code? Are there any ready-made tools?
Replies: 5
Views: 213

Re: How to use mcode to encrypt source code? Are there any ready-made tools?

You can see an example of such by referring to Encryptor by FeiYue. https://www.autohotkey.com/boards/viewtopic.php?f=28&t=42494 Oh, no. Don't mention this. I tested it today. The script has only two lines of code. Msgbox OK return After compiling and running, it looked like a virus. Not only did i...
by afe
04 Nov 2020, 08:49
Forum: Ask For Help
Topic: Does ahk support tail recursion? Topic is solved
Replies: 5
Views: 166

Re: Does ahk support tail recursion? Topic is solved

its the other way around. tail recursion(referring to the optimization tail call elimination ) is not a feature present in ahk the example provided is tail recursive, since no other actions are performed after the recursive call to f() What you mean is that it is possible to recurse in this way, bu...
by afe
04 Nov 2020, 08:46
Forum: Ask For Help
Topic: Does ahk support tail recursion? Topic is solved
Replies: 5
Views: 166

Re: Does ahk support tail recursion? Topic is solved

Does ahk support tail recursion? Yes, tail recursion is explained here And does the following example count as tail recursion? no, the example provided will never reach this line : return, f() Sorry, my example is not complete and it has misunderstood you. I meant that n might be equal to 9.
by afe
02 Nov 2020, 13:10
Forum: Ask For Help
Topic: Does ahk support tail recursion? Topic is solved
Replies: 5
Views: 166

Does ahk support tail recursion? Topic is solved

Does ahk support tail recursion? And does the following example count as tail recursion?

Code: Select all

f() 
{
    Try {
        ; something
        if ( n != 9 )
            return, err
    }
    Catch {
        ; something
        return
    }
   return, f()
}
by afe
02 Nov 2020, 08:14
Forum: Ask For Help
Topic: How to traverse folders using loops instead of recursion?
Replies: 4
Views: 93

Re: How to traverse folders using loops instead of recursion?

However, this is not the same problem. To be more specific, the traversal of folders I mentioned may not really mean traversing the local computer folders. This is just an analogy.
by afe
02 Nov 2020, 07:48
Forum: Ask For Help
Topic: How to traverse folders using loops instead of recursion?
Replies: 4
Views: 93

How to traverse folders using loops instead of recursion?

How to traverse folders using loops instead of recursion? Do I need to prepare an array and save the folders in the current directory to the array. When the current directory is traversed, take out a value from the array and traverse again until the array is empty? The actual problem is more complic...
by afe
22 Oct 2020, 06:35
Forum: Ask For Help
Topic: How to use mcode to encrypt source code? Are there any ready-made tools?
Replies: 5
Views: 213

How to use mcode to encrypt source code? Are there any ready-made tools?

How to use mcode to encrypt source code? Are there any ready-made tools?
I don't understand mcode. Is it possible to encrypt the source code into an EXE and no longer need AutoHotKey.exe when running it?
by afe
09 Oct 2020, 03:16
Forum: Scripts and Functions
Topic: ScriptGuard: Helps Protect Compiled Scripts from Decompilation
Replies: 26
Views: 2170

Re: ScriptGuard: Helps Protect Compiled Scripts from Decompilation

My program has been decoded by others, and the account was used to sell it. I can't do anything about it. I know that this day will come sooner or later, and have been considering changing to another language. Of course, this is not the only reason. AutoHotKey does not support multi-threading, and t...
by afe
07 Oct 2020, 05:59
Forum: Scripts and Functions
Topic: ScriptGuard: Helps Protect Compiled Scripts from Decompilation
Replies: 26
Views: 2170

Re: ScriptGuard: Helps Protect Compiled Scripts from Decompilation

Unfortunately, this method does not allow the source code to be protected too much.
by afe
05 Jul 2020, 03:32
Forum: Ask For Help
Topic: Run cmd has an unexpected result
Replies: 2
Views: 779

Re: Run cmd has an unexpected result

I don't think it has anything to do with the working directory. The working directory impact will be CMD, and CMD is not in the script directory, nor will it affect the subsequent appA. The problem should be what caused the directory displayed after 'Run, cmd' to be 'C:\Windows\Systme32' instead of ...

Go to advanced search