Jump to content

modifier keys getting stuck down by HotKeySet


frew
 Share

Recommended Posts

... Also, I'm not sure why this is, but if I comment out the _SendEx in script_2.au3, then I can change the _SendEx in script_3.au3 to Send (not _SendEx) and "Hello." prints fine, and I can go right into typing normally, ie no Alt key is being pressed down still.

So...what was that Send in script_2.au3 doing (the Send being now commented out in script_2.au3) that the Send in script_3.au3 is not doing? Hmmm...seems like the Send in c would cause a problem too, but it does not. ...

:-) Too many scripts. There is no script_3.au3, but I think that I know the answer to your question. It is just a matter of timing. As long as you have let go of the Alt before the regular Send function happens, then you will be okay. That is what martin's UDF does, it makes the script wait for the human to let go of the Alt key before it uses the regular Send function.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Nice...yes that works! Thanks so much herewasplato! ...

You are welcome.

... but I do wonder if

RunWait(@AutoItExe & " /AutoIt3ExecuteScript script_1.au3")

will find script_1.au3 if script_1.au3 is located way off in some other directory structure? ...

Nope, it won't.

... Also, the Traytip does not show up...may be my AutoIt version and OS? ...

What happens if you intentionally hold down Alt-F1 for several seconds? Do you see it then?

You mentioned your OS...

True, you could have TrayTips turned off in your OS.

What two lines of code could test that for you?

TrayTip("Title", "text", 100)

Sleep(100000)

:-)

... Also, would I have to put that code for each function? I have a big list of HotKeySets in my HotKeySet main script. (I could look into putting the function into a variable and using the variable to call the function?...I'm learning how to do these things) ...

See if this code gives you any ideas:
#include <Misc.au3>

HotKeySet("!{F1}", "_UDF1")
HotKeySet("!{F2}", "_UDF1")
HotKeySet("!{F3}", "_UDF1")
HotKeySet("!{F4}", "_UDF1")

While 1
    Sleep(9)
WEnd

Func _UDF1()
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        Sleep(50)
    WEnd
    Select
        Case @HotKeyPressed = "!{F1}"
            ;code that you want done if Alt-F1 is pressed
            MsgBox(0, "_UDF1", @HotKeyPressed)
        Case @HotKeyPressed = "!{F2}"
            ;code that you want done if Alt-F2 is pressed
            MsgBox(0, "_UDF1", @HotKeyPressed)
        Case @HotKeyPressed = "!{F3}"
            ;code that you want done if Alt-F3 is pressed
            MsgBox(0, "_UDF1", @HotKeyPressed)
        Case @HotKeyPressed = "!{F4}"
            ;code that you want done if Alt-F4 is pressed
            MsgBox(0, "_UDF1", @HotKeyPressed)
    EndSelect
EndFunc   ;==>_UDF1
Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

It is just a matter of timing

Yes, I see what you mean. Thank you for clarifying that further.

Ha, yes...by 3.au3 I meant 2, and by 2 I meant 1 in that last post.

but I do wonder if

RunWait(@AutoItExe & " /AutoIt3ExecuteScript script_1.au3")

will find script_1.au3 if script_1.au3 is located way off in some other directory structure? ...

Nope, it won't.

Hmmm...I wonder how to use this RunWait(@AutoItExe & " /AutoIt3ExecuteScript script_1.au3") when the script_1.au3 is

off somewhere else in some distant folder or subfolder? Just put the path in there like, for example,

RunWait(@AutoItExe & " /AutoIt3ExecuteScript C:\Scripts\Tests\script_1.au3")...would that work?

(The AutoIt main folder will get overcrowded very quickly).

What happens if you intentionally hold down Alt-F1 for several seconds? Do you see it then?

No. And I think my OS does not even support tray tips. Nothing happens with the traytips code you gave.

I'll try your nice HotKeySet code that you gave and let you know how it works here.

Thanks so much. I really appreciate the help and the wonderful code that you present.

frew

Edited by frew
Link to comment
Share on other sites

It should work just fine.

Works fine except when the HotKeys_1.au3 is located somewhere other than the folder in which the script_1.au3 and the script_2.au3 folders re located.

I'm forgetting what the advantages of /AutoIt3ExecuteScript are again.

Is that mainly useful for exe that have been compiled from au3?

I'm having problems with this kind of line not working when I have spaces in the paths to the au3, where the HotKey au3 that I have created (modified from code you gave) is not located anywhere around the folder of the au3 files that it starts up.

RunWait(@AutoItExe & " /AutoIt3ExecuteScript script_2.au3")

Whereas this format seems to work much more consistently for me:

ShellExecute(@AutoItExe, "autocompose_1.au3", "C:\Program Files\AutoIt3\Scripts")

I may be dealing with an older OS that isn't handling the spaces in paths and filenames well (I know, Windows 98SE).

Maybe that's part of the problem...I'm not sure.

Anyways, as it is now, I'm very thankful for so many of the ideas you've presented me with in this thread. It turns out though that I feel like going back to my original

ShellExecute(@AutoItExe, "autocompose_1.au3", "C:\Program Files\AutoIt3\Scripts")

types of ideas because they are working for me, in conjunction with the great HotKeys code you gave.

I'm not 100% sure I have all my facts here described correctly, but the basic idea is that I'm running into problems getting this all to work unless I want to have all my files in one folder, which I do not want to do. and I don't want to have to compile au3 at this point. And the ShellExecute seems to be working here better than the /AutoIt3ExecuteScript ...so I'm not sure exactly the best way to go...ie I don't want to develop coding habits that will have to be changed later...soi want to get used to using the /AutoIt3ExecuteScript if indeed that is a better way to go generally. I'm just learning about these things still.

Thank you very much for any ideas about this.

frew

Link to comment
Share on other sites

You can give this a try:

RunWait(@AutoItExe & " /AutoIt3ExecuteScript 'C:\temp folder\script_2.au3'")

But you can stick with au3 files and ShellExecute since it works on your OS.

I tried every combination of quotes, double quotes, single quotes, etc. but none seem to work with /AutoIt3ExecuteScript

when the path has spaces in it, and the au3 are in various folders.

No problem, Ill just stick with this ShellExecute format for now:

ShellExecute(@AutoItExe, "autocompose_1.au3", "C:\Program Files\AutoIt3\Scripts")

Thanks so much for your Select Case code for me to work with in my Hotkeys au3. It's working out beautifully.

Thanks for all your great help in this thread...I really appreciate it. You have helped me with some coding that is going to make things go very smoothly in these areas now.

frew

Link to comment
Share on other sites

I tried every combination of quotes, double quotes, single quotes, etc. ...

Sorry, I should have tested before posting:

RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "c:\temp\temp folder\script_2.au3"')

The code above and below works for me on XP as an au3 or complied.

$var = '"c:\temp\temp folder\script_2.au3"'

RunWait(@AutoItExe & " /AutoIt3ExecuteScript " & $var)

~Most Senile Poster~

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Interestingly,

RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "c:\temp\temp folder\script_2.au3"')

The code above and below works for me on XP as an au3 or complied.

$var = '"c:\temp\temp folder\script_2.au3"'

RunWait(@AutoItExe & " /AutoIt3ExecuteScript " & $var)

...both do not work on Windows 98SE (I hope my testing was done right).

I do greatly appreciate your help with testing this.

So, for now I stick with ShellExecute()

Just curious, if it's not too much trouble, what is the advantage of trying to get this format to work:

RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "c:\temp\temp folder\script_2.au3"')

...ie the /AutoIt3ExecuteScript part....I never did get a grasp of why it may be a good idea to think about doing it in this

way, rather than just using ShellExecute()

Thanks for any other ideas.

I'm definitely the most 12/9ths nuts poster.

frew

Edited by frew
Link to comment
Share on other sites

A picture might be worth 1000 words, so here is a pic and some words too:-)

Posted Image

In that picture you can see the code for each script as shown in the notepad windows.

You can see the version of the OS and AutoIt.

The file named temp.au3 is running.

(Temp.au3 appears in the list of processes as AUTOIT3A.EXE.)

Temp.au3 launched the script named "script_2.au3".

(script_2.au3 appears in the list of processes as AUTOIT3A.EXE.)

AutoIt must be installed on the computer that is going to run these two scripts.

The file named temp.exe is also running.

(Temp.exe appears in the list of processes as TEMP.EXE.)

Temp.exe launched the script named "script_2.au3".

(script_2.au3 appears in the list of processes as TEMP.EXE.)

AutoIt does NOT need to be installed on the computer that is going to run these two scripts.

The compiled script named temp.exe "uses itself" to run the script named "script_2.au3".

RunWait(@AutoItExe & ' /AutoIt3ExecuteScript .....

versus

ShellExecute()

The info in bold above is one reason - but if you are only writing this code for yourself, then it should not matter because you have AutoIt installed :-)

Another reason is:

Using Run and /AutoIt3ExecuteScript will work for others using the latest version of AutoIt.

(Like most of those attempting to help you in this forum.)

Using ShellExecute() as you did - relaunches the script in AutoIt v3.3.0.0 that called it...

...like I said in this earlier post: http://www.autoitscript.com/forum/index.ph...st&p=668510

Using ShellExecute() as you did - runs the other script in AutoIt v3.2.10.0

Posted Image

Also notice that it does it with only one copy of AUTOIT3A.EXE running.

Maybe you should just stick with your ShellExecute() code.

In the future, please include the W98 OS info and the version of AutoIt that you are using in your first post... not post #14 :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...