ScriptUp - Many scripts, One process

Post your working scripts, libraries and tools
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

ScriptUp - Many scripts, One process

04 Sep 2017, 04:07

Finally, it's been completed! :) Everything is in the readme. Enjoy!

Download from Github


Last update:

Added "Edit" to context menu.
Helgef
Posts: 3221
Joined: 17 Jul 2016, 01:02
Contact:

Re: ScriptUp - Many scripts, One process

05 Sep 2017, 13:20

I have tested it. Well done :thumbup:
I made a list:
  • Suggestion, If possible, it would be nice to have the default tray menu options for the running scripts, via ScriptUp. That is, Pause, Suspend etc..
  • Suggestion, maybe collect all relevant files and make a release on github, for easy access. (Most people (me included) are lazy you know)
  • Comment, for others, it is nice to put a copy of autohokey.exe in the script folder, renaming to ScriptUp.exe, then you get the ScriptUp.exe name in the taskmanager.
  • Problem, I needed to restart ScriptUp when I added a new script, it didn't run on add. I tried refresh and refresh all. Only tested with std. My ahk_h version is 1.1.25.02 64bit on win7. AHK_h is not my default AHK.
  • Problem, exiting ScriptUp seems to invoke a TerminateThread or similar forceful exiting for each script, rather than invoking ExitApp. AHK_H V2 documentation suggest you can do thread.ExitApp() I do not know if this is possible in v1. I tried to invoke a.thread.exec(...) (if I understand correctly, it is threadManObject.exec(str)) in fileList.__Delete() but it didn't seem to work.
Cheers, and thanks for sharing.
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

05 Sep 2017, 17:17

Hey Helgef, glad you like it!

First 2, good ideas and I'll act on both of them. But for the tray, do you mean to have a global pause and suspend? If you mean to list all the scripts and have those options for them, that's much too messy for my liking.
Problem 1, I had this issue as well, and I believe I know where it is. Portion of code I had to re-write several times already, bit tricky for me. I'll get to this when I can.
Problem 2, yes, this was on purpose. I didn't see a need for soft-closing threads, but it's pretty important if they're required to run an onExit sub. And exec should probably be in threadMan.quit(), to replace the ahkTerminate.

Good suggestions, thanks! I'll implement them when I get a minute to work on it.

Note: I do not use AHK_H except for multi-threading, and I only use v1.1. The script itself was written in/for AHK v1.1 [Unicode x64], my standard.
Helgef
Posts: 3221
Joined: 17 Jul 2016, 01:02
Contact:

Re: ScriptUp - Many scripts, One process

06 Sep 2017, 02:25

Hello!
For suggestion 1, I meant something like having button controls in the main gui, [Pause] [Supspend] ... Which would do the action for the selected script. Or instead of buttons, maybe a menu item, [Script actions]->[Pause]... In effect, one could clean up the tray notification area by using #NoTrayIcon for scripts running through ScriptUp. (Ofc, for scripts without custom tray menu items)
Problem 2, onExit subs and object __delete and such would be the issue indeed.

Cheers.
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

11 Sep 2017, 10:30

For suggestion 1...
Ah, that makes much more sense! I will certainly add the ability to pause and such (and display the status) soon.
#NoTrayIcon for scripts running through ScriptUp.
Yes, I highly suggest this! And it's exactly what I do, for anything that doesn't have a custom menu, anyway.

I could only muster up enough time to fix the soft-closing. ahkTerminate() is actually a soft-close. The problem was that ScriptUp didn't release the threadMan objects, so it just force terminated everything. It now does so, but it's limited to a set timeout (see the readme on Github). If the timeout is exceeded, ScriptUp will crash. Adding a try-block seems to catch the crash, but it should then fall back to a force-closure. It seems to do so, anyway, which works quite well.

I'll try to get the other stuff put in soon. :thumbup:
guest3456
Posts: 2433
Joined: 09 Oct 2013, 10:31

Re: ScriptUp - Many scripts, One process

11 Sep 2017, 10:47

why not also include the AHK_H.dll in the repository?

User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

11 Sep 2017, 11:12

why not also include the AHK_H.dll in the repository?
To ensure everyone is getting the most up-to-date version. I'm not going to update the DLL's on ScriptUp's repository every time they're updated. I most likely won't even update mine, unless something truly pertinent is added.

I suppose I could put the latest ones up/the version I'm working with now (just updated) for compatibility purposes.
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

15 Sep 2017, 09:38

I have a particular script that crashes ScriptUp every time it tries to close/reload it. It doesn't crash when ran through the AHK or AHK_H executable. I can't post the script, but it's mostly context-sensitive hotkeys, image/pixel searching and key sending. I have several other scripts that use all the same commands and functions, none of which crash ScriptUp. The path is identical to several others in there as well, so it's certainly something to do with the contents, right? It does not have an onExit sub.

If anyone else encounters this, or has an idea as to why, please let me know.
Helgef
Posts: 3221
Joined: 17 Jul 2016, 01:02
Contact:

Re: ScriptUp - Many scripts, One process

17 Sep 2017, 13:11

I cannot reproduce with simple example doing context sensitive hotkey to imagesearch and send keys. Not with std or mini (you didn't specifiy). Can you narrow your script down?
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

17 Sep 2017, 14:09

Unfortunately, not too much. I have it force-install both the mouse and keyboard hooks, it sets the coordmode for tooltip, pixel, and mouse, has setControlDelay -1 and setKeyDelay,25,25, several associative arrays, a simple array, and a single GUI. There are timers and loops, but none are on by default, and the crash occurs regardless of if a hotkey is triggered or not.

I have several identical hotkeys, separated by context.. It's quite a large script, but I'll try to reproduce it in an example.
HotKeyIt
Posts: 1705
Joined: 29 Sep 2013, 18:35
Contact:

Re: ScriptUp - Many scripts, One process

18 Sep 2017, 15:35

Do you get an Exception message on crash, if yes, what is it showing? If not then the error occurs in exe, you can download VC and try to run debug version to see what causes the error!
Dboeeee
Posts: 2
Joined: 30 Oct 2017, 01:53

Re: ScriptUp - Many scripts, One process

30 Oct 2017, 01:57

How can i download it?, i always struggle downloading things on GitHub
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

08 Dec 2017, 06:53

Do you get an Exception message on crash, if yes, what is it showing? If not then the error occurs in exe, you can download VC and try to run debug version to see what causes the error!
I never got any exceptions, it would just say it's stopped responding and my cursor position wouldn't update faster than once a second, so I have to hit "Close unresponsive process" button on the popup with they keyboard. Sorry I didn't respond sooner.

Between being busy and lazy, I've finally bothered to see why this was occurring: #IfWinActive. I've deprecated this in favor of #if winActive() everywhere, including in that script, except for one instance. I replaced it and now there's no more crashing.

So, HotKeyIt, I assume you deprecated this as well in AHK_H? Why is it allowed to run in the first place, though?
burque505
Posts: 627
Joined: 22 Jan 2017, 19:37

Re: ScriptUp - Many scripts, One process

11 Dec 2017, 19:59

:bravo: Thanks, Masonjar13, that's good stuff.

I cloned the GitHub repository, and ran into a couple of errors (not yours) that I thought I'd share in case anyone else does what I did and ran it from the src folder.
1) I already had _Struct in my LIB folder in the program directory, so that threw an error at Line 42 of C:\Program Files\AutoHotkey\LIB\_Struct.ahk. I removed _Struct from the LIB folder in the cloned repository structure and that error went away.
2) You mention readResource and even give the link to it, but it isn't in the LIB folder in the repository for some reason, though all the rest of the requirements are. That of course threw an error, but I just added readResource to the LIB folder in the cloned repo structure and everything fired up.
Cool script indeed!

Regards,
burque505
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

15 Mar 2018, 10:52

Update!

I replaced the face buttons with a context (right-click) menu, which now also allows to invoke ListLines on the selected script. You may only click-and-drag scripts to the window now to add them. More to come in the near future (looks at Helgef) ;)
You mention readResource
True, it's something I forgot to add. However, it doesn't work, so I'll probably just remove it anyway. It did at one point, but for some reason, I can no longer pull resources from a compiled script. :think: If anyone has a fix for that, please let me know!

Note: the mini DLL doesn't have the ListLines command, therefore you may not use it with scripts that use the mini DLL.
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

15 Mar 2018, 15:39

Update! Again ;)

Added readResource to the included lib folder, added pause/suspend function to threads, added new column to show the current state of the script.

New limitation: the only way I know how to suspend a thread is by executing Suspend as code, which won't work if the thread is paused. So to do both via the GUI, you must suspend then pause.
Helgef
Posts: 3221
Joined: 17 Jul 2016, 01:02
Contact:

Re: ScriptUp - Many scripts, One process

21 Mar 2018, 14:23

Great updates :clap:.
For suspending while paused, as per the documentation,

Code: Select all

; fileList.ahk
suspend(scriptName){
	; Not tested on mini
	static WM_COMMAND := 0x111
	static ID_FILE_SUSPEND := 65404
	DetectHiddenWindows, On
	PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, % "ahk_id " this.scripts[scriptName].thread.varGet("a_scripthwnd")
}
Also, very nice with one download including everything :thumbup: .
Cheers.
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

21 Mar 2018, 15:49

For suspending while paused, as per the documentation
Helgef, my hero! I didn't consider to look at the Suspend docs for some reason. It doesn't need to work with mini anyways, since it can't have hotkeys. This works perfectly! Added a check to maintain previous DetectHiddenWindows setting and for the Mini, I'll have it posted to the repository momentarily. :)
User avatar
Masonjar13
Posts: 1403
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: ScriptUp - Many scripts, One process

22 Mar 2018, 01:30

I was considering adding an interface to execute code on a thread directly. Does anyone think this would be useful? Or does anyone have any other feature suggestions for it? As it is, it's very stable (on my end) and contains pretty much everything I could think of needing.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: SAbboushi, swagfag and 40 guests