Jump to content

Restart UDF


Yashied
 Share

Recommended Posts

Nice and easy @Nine, thanks. But I had to replace this ...

ShellExecute(@ScriptFullPath)

... by this ...

ShellExecute(@AutoItExe, '/AutoIt3ExecuteScript ' & @ScriptFullPath)

... to get it working.

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

Link to comment
Share on other sites


Okay, interesting. I have to say that I use VSCode instead of SciTE or ISN Studio. Maybe there is a orphaned relation which is default in SciTE, but not in the VSCode settings - I don't know. Anyways, I guess it's good to have two variants, only in case the user also struggles as I did ( for few seconds 😅 ).

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

That's even better, yes. Because of the compiled variant 👍 .
Works fine.

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

If SciTe is set to open the script by default it needs to specify the appropriate verb.

17 minutes ago, SOLVE-SMART said:
ShellExecute(@AutoItExe, '/AutoIt3ExecuteScript ' & @ScriptFullPath)

This also might not work under specific circumstances, so better use some quotes around the script path.

 

When the words fail... music speaks.

Link to comment
Share on other sites

Made an enhanced version that informs the script of the restart, keeps track of the number of restarts and transmits actual command line parameters to the restarted script.  Works compiled and uncompiled (DOS cmd console and Scite).

#include <GUIConstants.au3>
#include <Constants.au3>

HotKeySet("{F1}", Restart)

Global $iRestart = 0
Global $sCmdLine = StringStripWS(@Compiled ? $CmdLineRaw : StringRegExpReplace($CmdLineRaw, '.*?\Q' & @ScriptName & '\E"?\h*(.*)', "$1"), $STR_STRIPTRAILING)

If StringInStr($sCmdLine, "/Restart=", $STR_CASESENSE) Then
  $iRestart = Int(StringRegExpReplace($sCmdLine, ".*\/Restart=(\d+)", "$1"))
  $sCmdLine = StringRegExpReplace($sCmdLine, "(.*?)\h*\/Restart=\d+", "$1")
EndIf

GUICreate("[" & $sCmdLine & "]", 300, 70)
GUICtrlCreateLabel($iRestart, 40, 30, 50, 20)
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func Restart()
  ShellExecute(@ScriptName, $sCmdLine & " /Restart=" & $iRestart + 1, @ScriptDir, @Compiled ? "" : "run")
  Exit
EndFunc   ;==>Restart

 

Edited by Nine
more robust cmd line extractor
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...