Jump to content

Recommended Posts

Posted

Hello all, this is my first post to this forum. I am relatively new to AutoIt, but the more I've been learning, the more I love it! I have already created about 15 or so little programs that make my job a breeze!

I am having an intermittent issue with my scripts that require a hotkey to start. Most of the time, they work without an issue. However, once in a while, the scripts crash the moment I press the hotkey instead of completing the function. I can't seem to figure out what the issue is. I could write an additional script that continually checks the status of the existing scripts and relaunches them if they crash. However, I am wondering if I am simply missing something. I would appreciate any advice or feedback if anyone has any to offer. Below is an example of one of my s1cripts (although this error seems to occur on any script in which I am using a hotkey):

#include "misc.au3" ;Necessary for SendEx to function

HotKeySet("^!q", "Exit_Script") ; Exits Script
HotKeySet("^!7", "Picture_Insert_2")

While 1 ;Waits for hotkey to be pressed
    Sleep(1000)
WEnd

Func _SendEx($keys) ;Prevents ctrl, shift, and alt keys from sticking
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
      sleep(50)
    WEnd
    Send($keys)
EndFunc;==>_SendEx


Func Picture_Insert_2()
   _SendEx("!06")
   WinWaitActive("Insert Picture")
   Local $Edit_Txt = ControlGetText("Insert Picture", "", "ToolbarWindow324")

   If StringInStr($Edit_Txt, "Z:\Vince J\Pictures") = False Then
      ControlSetText("Insert Picture", "", "Edit1", "Z:\Vince J\Pictures\")
      Send("{ENTER}")
   EndIf
EndFunc

Func Exit_Script()
   Exit
EndFunc

Thanks!

Posted

 

10 minutes ago, Danp2 said:

Are you able to duplicate the crash when running the script in Scite? If so, post the contents of the output panel.

Danp2, thank you for the response. I admittedly have not gotten too deep into the debug features of AutoIt. Concerning this crash, I can't seem to replicate it in Scite. It seems to only occur when I'm running the compiled (x64) versions of my script. If I run the au3, the scripts don't crash. However, it is my goal to use exe's because once I am done debugging these tools, I would like to be able to share them with my non-programming co-workers without having to install AutoIt on everyone's machine. 

Posted

Are you running multiple scripts (more than 1 in fact) with hotkeys set in each one ?

Cause that might be the problem.  You should avoid (as much as possible) having multiple scripts running with Hotkeys at the same time.

If you can use GUI Accelerator Keys instead (you need to have a GUI running ofc)

Posted
1 minute ago, Nine said:

Are you running multiple scripts (more than 1 in fact) with hotkeys set in each one ?

Cause that might be the problem.  You should avoid (as much as possible) having multiple scripts running with Hotkeys at the same time.

If you can use GUI Accelerator Keys instead (you need to have a GUI running ofc)

I am running multiple scripts with hotkeys set to each one. I have created some GUIs with accelerator keys. However, for these simple functions, I would like the user to simply be able to press a Hotkey and have it automatically complete the function without the wasted time of them having to interact with a GUI every time. Some of these operations are things that we have to complete 100 times a day or more. I am curious as to why running multiple scripts with Hotkeys causes them to crash?

Posted

If the issue lies in the fact that there are multiple scripts running simultaneously, perhaps I could try creating 1 consolidated script that contains every hotkey and have it run the other scripts. I will give this a try and report my results. Thank you for the feedback. You definitely have me thinking now! 

Posted
2 minutes ago, RiffRiffington said:

I am curious as to why running multiple scripts with Hotkeys causes them to crash?

I am not the developer of autoit, so I will speak from experience.  I had some difficulties once using multiple scripts with Hotkeys.  My scripts didn't crash but they froze from time to time.  I resolved that issue by combining the scripts and since then, I had no issue. 

Posted
27 minutes ago, Nine said:

I am not the developer of autoit, so I will speak from experience.  I had some difficulties once using multiple scripts with Hotkeys.  My scripts didn't crash but they froze from time to time.  I resolved that issue by combining the scripts and since then, I had no issue. 

I just created a master launch script that contains all of the Hotkey commands and runs the other scripts using the "Run" function. In retrospect, this is actually a much cleaner way of handling this anyway. Should have done it from the start. Thank you for your input!

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
×
×
  • Create New...