Please help complete this script(confining mouse to a window)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Please help complete this script(confining mouse to a window)

01 Oct 2020, 11:58

tatagi wrote:
01 Oct 2020, 11:43
@A_AhkUser
Disabling warnings does not solve anything actually. it just stops showing error code, while the script malfunctions or not function at all as far as errors are not revised. I removed all return for single line hotkey to see what happens, doesn't do a thing. and I can't remove setstorecapslockmode line because it's essential.
I already advised you to first remove:

Code: Select all

!x::ExitApp
So I guess it is no more present in your script. Well, please also remove also the part I wrote or simply run your script, stand alone - but adding beforehand:

Code: Select all

#Warn
anywhere on your script (and the very top for example) - and:

Code: Select all

MsgBox, This is a msg box
before the following line:

Code: Select all

setbatchlines, -1
does the msgbox shows up? I'm sure not: this is because you have unreachable code in your script. (I cannot test it, since this feature has been added in ahk 1.1.33 and I'm currently running the 1.1.32 one).

A_AhkUser
my scripts
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Re: Please help complete this script(confining mouse to a window)

01 Oct 2020, 19:25

@A_AhkUser

Oh, I tested my original script with #warn on top, and it really shows error dialog..never realized because all my hotkey worked well. So does having unreachable code in the script, although fully working, cause problem that I am not aware of?
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Please help complete this script(confining mouse to a window)

02 Oct 2020, 13:42

tatagi wrote:
01 Oct 2020, 19:25
Oh, I tested my original script with #warn on top, and it really shows error dialog..never realized because all my hotkey worked well. So does having unreachable code in the script, although fully working, cause problem that I am not aware of?
Bear in mind that it is question of preventive warnings: #Warn is first and foremost designed to prevent bad coding habits. Furthermore, the seriousness of the situation depends on the specific conditions which triggered the warning. For instance, a return after a single-line hotkey is simply redundant but cannot be considered as an error, strictly speaking, as I see it. In your script, there's unreacable code. In that case also, it is not question (a priori) of an error: despite some unreachable code, your script can work as intended; that means the given code is simply superflous; you might simply remove this unreachable code since, anyway, it is not executed (just as the msgbox that never shows up above). But if the given code perform key procedures, your script is likely to not work as expected.

It's just my opinion but if your script displays one or more warnings when adding #Warn, and even it it not question of errors strictly speaking, you should rewrite your script so that warnings are suppressed (first of all because if someonelse use your code and use for its part #Warn it will get annoying warnings: this was exactly what happened here except that you were by turns the one that don't use it and the one that use it).

In reviewing my script, I wonder if I haven't spoken too hastily: Critical might sometimes lead to problems.
It is quite unlikely that Critical may prevent your script from working but you can remove this word from the script (there's only one occurrence of this command in the clipcursor script I provided) since it is optional in this case.
Otherwise, if despite a rewrite matching the prerequisites of #Warn your script still malfunctions after merging it with mine, I must admit that I'll can't explain it; I'll be out of ideas.

Hope this helps

A_AhkUser
my scripts
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Re: Please help complete this script(confining mouse to a window)

02 Oct 2020, 19:47

@A_AhkUser

I appreciate your detailed explanation. I removed all returns after single line hotkey and it improved the readability to a degree which is a plus.
Been testing removing critical which apparently did nothing so far, might refer to some articles about auto execute section.

but I would keep your mousetrap script in my collection, it is very useful itself as standalone which deserves to be in the script showcase archive. :superhappy:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], whoops and 201 guests