Sign in to follow this  
Followers 0
chandler8

GUI flashes on screen and then disappears

12 posts in this topic

Hey Everyone.. I have been working on this project for a few days and now have added the code to a GUI. The problem I have is when the script is run, the GUI flashes really fast on the screen and you can't do anything with it. I have tried to add a Sleep(10) in the code and this helps to keep the GUI visable, but when you hit the start button nothing happens. The GUI is designed with three buttons that run the same script, but to different Control ID's on an external program. If I comment out the functions and then run the script it works fine, however when am calling the function this is where all the problems start. Any ideas??? In addition, is there anyway that you can stop the script when it's running and then start it again and begin where you left off?


#include <Array.au3>
#include <GUIConstants.au3>

Func _FileReadToArray($sFilePath, ByRef $aArray)
Local $hFile
$hFile = FileOpen($sFilePath, 0)
If $hFile = -1 Then
SetError(1)
Return 0
EndIf
$aArray = StringSplit(StringStripCR( FileRead($hFile, FileGetSize($sFilePath))), @LF)
FileClose($hFile)
Return 1
EndFunc;==>_FileReadToArray

Local $filePath = @DesktopDir &'\Stocks.txt'
Local $aArray = ''
_FileReadToArray($filePath, $aArray)
Local $sArray = _SeperateEachWord($aArray); should have each 'word' now in an array

Func _SeperateEachWord(ByRef $aArray, $dDelimeter = ' ')
For $i = 1 To Ubound($aArray) - 1
If $aArray[$i] <> '' Then 
$SplitSpace = StringSplit($aArray[$i], $dDelimeter)
For $x = 1 To UBound($SplitSpace) - 1
$sArray = $sArray & $SplitSpace[$x] & Chr(01)

Next
EndIf
Next
Return StringSplit(StringTrimRight($sArray, 1), Chr(01))
EndFunc


GUICreate("Millenium Script")
$buttonstart1 = GUICtrlCreateButton ("Start Script 1",50,100,100,25)
GUICtrlSetOnEvent(-1, "buttonstart1")
$buttonstart2 = GUICtrlCreateButton("Start Script 2",50,150,100,25)
GUICtrlSetOnEvent(-1, "buttonstart2")
$buttonstart3 = GUICtrlCreateButton("Start Script 3",50,200,100,25)
GUICtrlSetOnEvent(-1, "buttonstart3")
$buttonstop = GUICtrlCreateButton("Stop", 150,150,70,22)
GUISetState()


Func buttonstart1()
While 1
$msg = GUIGetMsg()
If $msg = $buttonstart1 Then
$count = 1 ; Set the counter
Do ; Execute the loop "until" the counter is greater than 20
For $x = 1 To UBound($sArray) - 1 ;go through the array and execute with focus on the control ID
ControlSend("Form1","", 1836126, $sArray[$x])
;Sleep(1000)
ControlSend("Form1", "", 1836126, "{Enter}")
Sleep(1000)
ControlSend("Form1","", 1836126, "{BackSpace 20}")
Next
$count = $count + 1 ; Increase the count by one
Until $count > 5
MsgBox(0, "Click start to Continue ", "Search finished!") ; Finished
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
EndFunc

Func buttonstart2()
While 1
$msg = GUIGetMsg()
If $msg = $buttonstart2 Then
$count = 1 ; Set the counter
Do ; Execute the loop "until" the counter is greater than 20
For $x = 1 To UBound($sArray) - 1 ;go through the array and execute with focus on the control ID
ControlSend("Form1","", 1049864, $sArray[$x])
Sleep(1000)
ControlSend("Form1", "", 1049864, "{Enter}")
Sleep(1000)
ControlSend("Form1","", 1049864, "{BackSpace 20}")
Next
$count = $count + 1 ; Increase the count by one
Until $count > 5
MsgBox(0, "Click start to Continue ", "Search finished!") ; Finished
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
EndFunc

Func buttonstart3()
While 1
$msg = GUIGetMsg()
If $msg = $buttonstart1 Then
$count = 1 ; Set the counter
Do ; Execute the loop "until" the counter is greater than 20
For $x = 1 To UBound($sArray) - 1 ;go through the array and execute with focus on the control ID
ControlSend("Form1","", 1312058, $sArray[$x])
Sleep(1000)
ControlSend("Form1", "", 1312058, "{Enter}")
Sleep(1000)
ControlSend("Form1","", 1312058, "{BackSpace 20}")
Next
$count = $count + 1 ; Increase the count by one
Until $count > 5
MsgBox(0, "Click start to Continue ", "Search finished!") ; Finished
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
EndFunc

[\Code]


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                        





(adsbygoogle = window.adsbygoogle || []).push({});




                    
                
                    
                    
                    






    
    
        
greenmachine   

    
        
    
             4
    
        
    

        
            
                Universalist
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             4
    
        
    

                1,246 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #2 · 
            Posted 
            
            
            
        
    

    


            
        
            This is an exact copy of the post in the GUI support forum.  Don't double post.  I already answered the question there.


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
chandler8   

    
        
    
             0
    
        
    

        
            
                Seeker
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                25 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #3 · 
            Posted 
            
            
            
        
    

    


            
        
            This is an exact copy of the post in the GUI support forum.  Don't double post.  I already answered the question there.
Hey Sorry about that....I was going to post the change I made from your suggestion and one of the examples I've seen....This change adding a While...Wend does allow access to the GUI, but now the program doesn't function.

#include <Array.au3>
#include <GUIConstants.au3>

Func _FileReadToArray($sFilePath, ByRef $aArray)
    Local $hFile
    $hFile = FileOpen($sFilePath, 0)
    If $hFile = -1 Then
        SetError(1)
        Return 0
    EndIf
    $aArray = StringSplit(StringStripCR( FileRead($hFile, FileGetSize($sFilePath))), @LF)
    FileClose($hFile)
    Return 1
EndFunc;==>_FileReadToArray

Local $filePath = @DesktopDir &'\Stocks.txt'
Local $aArray = ''
_FileReadToArray($filePath, $aArray)
Local $sArray = _SeperateEachWord($aArray); should have each 'word' now in an array

Func _SeperateEachWord(ByRef $aArray, $dDelimeter = ' ')
    For $i = 1 To Ubound($aArray) - 1
        If $aArray[$i] <> '' Then 
            $SplitSpace = StringSplit($aArray[$i], $dDelimeter)
            For $x = 1 To UBound($SplitSpace) - 1
                $sArray = $sArray & $SplitSpace[$x] & Chr(01)
    
          Next
        EndIf
    Next
    Return StringSplit(StringTrimRight($sArray, 1), Chr(01))
EndFunc


GUICreate("Millenium Script")
$buttonstart1 = GUICtrlCreateButton ("Start Script 1",50,100,100,25)
GUICtrlSetOnEvent(-1, "buttonstart1")
$buttonstart2 = GUICtrlCreateButton("Start Script 2",50,150,100,25)
GUICtrlSetOnEvent(-1, "buttonstart2")
$buttonstart3 = GUICtrlCreateButton("Start Script 3",50,200,100,25)
GUICtrlSetOnEvent(-1, "buttonstart3")
$buttonstop = GUICtrlCreateButton("Stop", 150,150,70,22)
GUISetState()

While 1
    Sleep(10)
Wend


Func buttonstart1()
    While 1
        $msg = GUIGetMsg()
        If $msg = $buttonstart1 Then
            $count = 1              ; Set the counter
            Do                      ; Execute the loop "until" the counter is greater than 20
                For $x = 1 To UBound($sArray) - 1  ;go through the array and execute with focus on the control ID
                    ControlSend("Form1","", 1836126, $sArray[$x])
                ;Sleep(1000)
                    ControlSend("Form1", "", 1836126, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1","", 1836126, "{BackSpace 20}")
                Next
                    $count = $count + 1  ; Increase the count by one
            Until $count > 5
                    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
        EndIf
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend
EndFunc


Func buttonstart2()
    While 1
        $msg = GUIGetMsg()
        If $msg = $buttonstart2 Then
            $count = 1              ; Set the counter
            Do                      ; Execute the loop "until" the counter is greater than 20
                For $x = 1 To UBound($sArray) - 1  ;go through the array and execute with focus on the control ID
                    ControlSend("Form1","", 1049864, $sArray[$x])
                    Sleep(1000)
                    ControlSend("Form1", "", 1049864, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1","", 1049864, "{BackSpace 20}")
                Next
                    $count = $count + 1  ; Increase the count by one
            Until $count > 5
                    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
        EndIf
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend
EndFunc


Func buttonstart3()
    While 1
        $msg = GUIGetMsg()
        If $msg = $buttonstart1 Then
            $count = 1              ; Set the counter
            Do                      ; Execute the loop "until" the counter is greater than 20
                For $x = 1 To UBound($sArray) - 1  ;go through the array and execute with focus on the control ID
                    ControlSend("Form1","", 1312058, $sArray[$x])
                    Sleep(1000)
                    ControlSend("Form1", "", 1312058, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1","", 1312058, "{BackSpace 20}")
                Next
                    $count = $count + 1  ; Increase the count by one
            Until $count > 5
                    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
        EndIf
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend
EndFunc

Share this post


Link to post
Share on other sites

Right, the while loop just makes stuff show up. I believe I mentioned adding GUI-listening functions (as in the rest of your while loops)... otherwise, yes the GUI will do absolutely nothing.

Share this post


Link to post
Share on other sites

maybe

#include <Array.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)       ;0=disabled, 1=OnEvent mode enabled

Local $filePath = @DesktopDir & '\Stocks.txt'
Local $aArray = ''

_FileReadToArray($filePath, $aArray)
Local $sArray = _SeperateEachWord($aArray); should have each 'word' now in an array

GUICreate("Millenium Script")
$buttonstart1 = GUICtrlCreateButton("Start Script 1", 50, 100, 100, 25)
GUICtrlSetOnEvent(-1, "buttonstart1")
$buttonstart2 = GUICtrlCreateButton("Start Script 2", 50, 150, 100, 25)
GUICtrlSetOnEvent(-1, "buttonstart2")
$buttonstart3 = GUICtrlCreateButton("Start Script 3", 50, 200, 100, 25)
GUICtrlSetOnEvent(-1, "buttonstart3")
$buttonstop = GUICtrlCreateButton("Exit", 150, 150, 70, 22)
GUICtrlSetOnEvent(-1, "My_Exit")
GUISetOnEvent($GUI_EVENT_CLOSE, "My_Exit")

GUISetState()

While 1
    Sleep(10)
WEnd

; ------------ Functions ---------------------

Func buttonstart1()
    
    $count = 1             ; Set the counter
    Do                     ; Execute the loop "until" the counter is greater than 20
        For $x = 1 To UBound($sArray) - 1 ;go through the array and execute with focus on the control ID
            ControlSend("Form1", "", 1836126, $sArray[$x])
        ;Sleep(1000)
            ControlSend("Form1", "", 1836126, "{Enter}")
            Sleep(1000)
            ControlSend("Form1", "", 1836126, "{BackSpace 20}")
        Next
        $count = $count + 1 ; Increase the count by one
    Until $count > 5
    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
    
EndFunc  ;==>buttonstart1


Func buttonstart2()
    
    $count = 1             ; Set the counter
    Do                     ; Execute the loop "until" the counter is greater than 20
        For $x = 1 To UBound($sArray) - 1 ;go through the array and execute with focus on the control ID
            ControlSend("Form1", "", 1049864, $sArray[$x])
            Sleep(1000)
            ControlSend("Form1", "", 1049864, "{Enter}")
            Sleep(1000)
            ControlSend("Form1", "", 1049864, "{BackSpace 20}")
        Next
        $count = $count + 1 ; Increase the count by one
    Until $count > 5
    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
    
EndFunc  ;==>buttonstart2


Func buttonstart3()
    
    $count = 1             ; Set the counter
    Do                     ; Execute the loop "until" the counter is greater than 20
        For $x = 1 To UBound($sArray) - 1 ;go through the array and execute with focus on the control ID
            ControlSend("Form1", "", 1312058, $sArray[$x])
            Sleep(1000)
            ControlSend("Form1", "", 1312058, "{Enter}")
            Sleep(1000)
            ControlSend("Form1", "", 1312058, "{BackSpace 20}")
        Next
        $count = $count + 1 ; Increase the count by one
    Until $count > 5
    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
    
EndFunc  ;==>buttonstart3

Func My_Exit()
    Exit
EndFunc  ;==>My_Exit

; --------------- Utility Functions ----------------

Func _FileReadToArray($sFilePath, ByRef $aArray)
    Local $hFile
    $hFile = FileOpen($sFilePath, 0)
    If $hFile = -1 Then
        SetError(1)
        Return 0
    EndIf
    $aArray = StringSplit(StringStripCR( FileRead($hFile, FileGetSize($sFilePath))), @LF)
    FileClose($hFile)
    Return 1
EndFunc  ;==>_FileReadToArray

Func _SeperateEachWord(ByRef $aArray, $dDelimeter = ' ')
    For $i = 1 To UBound($aArray) - 1
        If $aArray[$i] <> '' Then
            $SplitSpace = StringSplit($aArray[$i], $dDelimeter)
            For $x = 1 To UBound($SplitSpace) - 1
                $sArray = $sArray & $SplitSpace[$x] & Chr(01)
                
            Next
        EndIf
    Next
    Return StringSplit(StringTrimRight($sArray, 1), Chr(01))
EndFunc  ;==>_SeperateEachWord

you obviously did not look at "Welcome to Autoit 1-2-3"

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

maybe

#include <Array.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)     ;0=disabled, 1=OnEvent mode enabled

Local $filePath = @DesktopDir & '\Stocks.txt'
Local $aArray = ''

_FileReadToArray($filePath, $aArray)
Local $sArray = _SeperateEachWord($aArray); should have each 'word' now in an array

GUICreate("Millenium Script")
$buttonstart1 = GUICtrlCreateButton("Start Script 1", 50, 100, 100, 25)
GUICtrlSetOnEvent(-1, "buttonstart1")
$buttonstart2 = GUICtrlCreateButton("Start Script 2", 50, 150, 100, 25)
GUICtrlSetOnEvent(-1, "buttonstart2")
$buttonstart3 = GUICtrlCreateButton("Start Script 3", 50, 200, 100, 25)
GUICtrlSetOnEvent(-1, "buttonstart3")
$buttonstop = GUICtrlCreateButton("Exit", 150, 150, 70, 22)
GUICtrlSetOnEvent(-1, "My_Exit")
GUISetOnEvent($GUI_EVENT_CLOSE, "My_Exit")

GUISetState()

While 1
    Sleep(10)
WEnd

; ------------ Functions ---------------------

Func buttonstart1()
    
    $count = 1           ; Set the counter
    Do                   ; Execute the loop "until" the counter is greater than 20
        For $x = 1 To UBound($sArray) - 1;go through the array and execute with focus on the control ID
            ControlSend("Form1", "", 1836126, $sArray[$x])
;Sleep(1000)
            ControlSend("Form1", "", 1836126, "{Enter}")
            Sleep(1000)
            ControlSend("Form1", "", 1836126, "{BackSpace 20}")
        Next
        $count = $count + 1; Increase the count by one
    Until $count > 5
    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
    
EndFunc;==>buttonstart1
Func buttonstart2()
    
    $count = 1           ; Set the counter
    Do                   ; Execute the loop "until" the counter is greater than 20
        For $x = 1 To UBound($sArray) - 1;go through the array and execute with focus on the control ID
            ControlSend("Form1", "", 1049864, $sArray[$x])
            Sleep(1000)
            ControlSend("Form1", "", 1049864, "{Enter}")
            Sleep(1000)
            ControlSend("Form1", "", 1049864, "{BackSpace 20}")
        Next
        $count = $count + 1; Increase the count by one
    Until $count > 5
    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
    
EndFunc;==>buttonstart2
Func buttonstart3()
    
    $count = 1           ; Set the counter
    Do                   ; Execute the loop "until" the counter is greater than 20
        For $x = 1 To UBound($sArray) - 1;go through the array and execute with focus on the control ID
            ControlSend("Form1", "", 1312058, $sArray[$x])
            Sleep(1000)
            ControlSend("Form1", "", 1312058, "{Enter}")
            Sleep(1000)
            ControlSend("Form1", "", 1312058, "{BackSpace 20}")
        Next
        $count = $count + 1; Increase the count by one
    Until $count > 5
    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
    
EndFunc;==>buttonstart3

Func My_Exit()
    Exit
EndFunc;==>My_Exit

; --------------- Utility Functions ----------------

Func _FileReadToArray($sFilePath, ByRef $aArray)
    Local $hFile
    $hFile = FileOpen($sFilePath, 0)
    If $hFile = -1 Then
        SetError(1)
        Return 0
    EndIf
    $aArray = StringSplit(StringStripCR( FileRead($hFile, FileGetSize($sFilePath))), @LF)
    FileClose($hFile)
    Return 1
EndFunc;==>_FileReadToArray

Func _SeperateEachWord(ByRef $aArray, $dDelimeter = ' ')
    For $i = 1 To UBound($aArray) - 1
        If $aArray[$i] <> '' Then
            $SplitSpace = StringSplit($aArray[$i], $dDelimeter)
            For $x = 1 To UBound($SplitSpace) - 1
                $sArray = $sArray & $SplitSpace[$x] & Chr(01)
                
            Next
        EndIf
    Next
    Return StringSplit(StringTrimRight($sArray, 1), Chr(01))
EndFunc;==>_SeperateEachWord

you obviously did not look at "Welcome to Autoit 1-2-3"

8)

Guilty as charged :o However, I will make it the first place for info for now on. Thanks so much. Really like how you organize and document things. Question for you: I will look first in "Welcome to Autoit", but is there a way you can run multiple scripts from the same GUI at the same time to different ControlID's to an external program. Here is my code so far and added some hotkeys to the program. - Thanks for that one GreenMachine. And thanks again Valuater.

#include <Array.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)    ;0=disabled, 1=OnEvent mode enabled



Global $Paused                      ;Press Esc to terminate script, Pause/Break to "pause"
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage");Shift-Alt-d

Local $filePath = @DesktopDir &'\Stocks.txt'
Local $aArray = ''

_FileReadToArray($filePath, $aArray)
Local $sArray = _SeperateEachWord($aArray); should have each 'word' now in an array



GUICreate("Millenium Script")
$buttonstart1 = GUICtrlCreateButton ("Start Script 1",50,100,100,25)
GUICtrlSetOnEvent($buttonstart1, "buttonstart1")
$buttonstart2 = GUICtrlCreateButton("Start Script 2",50,150,100,25)
GUICtrlSetOnEvent($buttonstart2, "buttonstart2")
$buttonstart3 = GUICtrlCreateButton("Start Script 3",50,200,100,25)
GUICtrlSetOnEvent($buttonstart3, "buttonstart3")
$buttonExit = GUICtrlCreateButton("Exit", 150,150,70,22)
GuiCtrlSetOnEvent($buttonExit, "buttonExit")
GUISetOnEvent($GUI_EVENT_CLOSE, "buttonExit")
GUISetState()

While 1
    Sleep(10)
Wend

    
;-------------------------------------Main Functions -------------------------------------- 
    
Func buttonstart1()

            $count = 1              ; Set the counter
            Do                      ; Execute the loop "until" the counter is greater than 20
                For $x = 1 To UBound($sArray) - 1  ;go through the array and execute with focus on the control ID
                    ControlSend("Form1","", 2098474, $sArray[$x])
                ;Sleep(1000)
                    ControlSend("Form1", "", 2098474, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1","", 2098474, "{BackSpace 20}")
                Next
                    $count = $count + 1  ; Increase the count by one
            Until $count > 5
                    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
EndFunc;===buttonstart1

Func buttonstart2()
            $count = 1              ; Set the counter
            Do                      ; Execute the loop "until" the counter is greater than 20
                For $x = 1 To UBound($sArray) - 1  ;go through the array and execute with focus on the control ID
                    ControlSend("Form1","", 3278074, $sArray[$x])
                ;Sleep(1000)
                    ControlSend("Form1", "", 3278074, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1","", 3278074, "{BackSpace 20}")
                Next
                    $count = $count + 1  ; Increase the count by one
            Until $count > 5
                    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
EndFunc;===buttonstart2



Func buttonstart3()
            $count = 1              ; Set the counter
            Do                      ; Execute the loop "until" the counter is greater than 20
                For $x = 1 To UBound($sArray) - 1  ;go through the array and execute with focus on the control ID
                    ControlSend("Form1","", 984376, $sArray[$x])
                ;Sleep(1000)
                    ControlSend("Form1", "", 984376, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1","", 984376, "{BackSpace 20}")
                Next
                    $count = $count + 1  ; Increase the count by one
            Until $count > 5
                    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
EndFunc;===buttonstart2


Func buttonExit()
    Exit
EndFunc ;==>buttonExit

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc ;======>Pause Script

Func Terminate()
    Exit 0
EndFunc;======>Esc closes the program

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc;=======Displays a message



;--------------------------------------Utility Functions-------------------------------------------



Func _FileReadToArray($sFilePath, ByRef $aArray)
    Local $hFile
    $hFile = FileOpen($sFilePath, 0)
    If $hFile = -1 Then
        SetError(1)
        Return 0
    EndIf
    $aArray = StringSplit(StringStripCR( FileRead($hFile, FileGetSize($sFilePath))), @LF)
    FileClose($hFile)
    Return 1
EndFunc;==>_FileReadToArray



Func _SeperateEachWord(ByRef $aArray, $dDelimeter = ' ')
    For $i = 1 To Ubound($aArray) - 1
        If $aArray[$i] <> '' Then 
            $SplitSpace = StringSplit($aArray[$i], $dDelimeter)
            For $x = 1 To UBound($SplitSpace) - 1
                $sArray = $sArray & $SplitSpace[$x] & Chr(01)
    
          Next
        EndIf
    Next
    Return StringSplit(StringTrimRight($sArray, 1), Chr(01))
EndFunc;====>_Separate Each Word
Edited by chandler8

Share this post


Link to post
Share on other sites

yes!...

but there are many approaches to doing this

1

i prefer to make a Script(s) compile it...

then use FileInstall() to run it/them from my main Script (then compile that )

2

you can FileInstall() Autoit3.exe and run many scripts ( au3 only )

3

you can compile a main program and "Drag & Drop" links or programs/au3 onto the exe and they will run

Truely depends on which way you want to go

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

yes!...

...

2

you can FileInstall() Autoit3.exe and run many scripts ( au3 only )

...

You don't need to FileInstall Autoit3.exe - the compiled script becomes the AutoIt3.exe for all script-running purposes. Proof - compile this script (name is whatever you want, but not autoit3.au3):

MsgBox (0, "", @AutoItExe)

You'll get the path the the current script.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

You don't need to FileInstall Autoit3.exe - the compiled script becomes the AutoIt3.exe for all script-running purposes. Proof - compile this script (name is whatever you want, but not autoit3.au3):

MsgBox (0, "", @AutoItExe)

You'll get the path the the current script.

Thanks greenmachine that worked adding that piece into my code.

run(@AutoItExe)

When I click the button it gives you the option of selecting your desired script. I would also like the option of clicking a button to run another script automatically. This is what I've tried adding, but when I click on my desired button I get =======> Unable to execute the external program

FileInstall("C:\test.au3", "D:\test.au3\")
run("D:\test.au3")
;also have tried run("D:\test.exe")

I've tried looking for an example in AutoIt 123 with no luck. If there is an example to run the script after FileInstall() has done it's thing, Valuater, what example #.

Edited by chandler8

Share this post


Link to post
Share on other sites

If you want to run an au3 file, you need to run it like this:

FileInstall("C:\test.au3", "D:\test.au3"); no ending \ by the way
run(@AutoItExe & " /AutoIt3ExecuteScript D:\test.au3")

This way, you're running the au3 file through the currently running exe.

Share this post


Link to post
Share on other sites

If you want to run an au3 file, you need to run it like this:

FileInstall("C:\test.au3", "D:\test.au3"); no ending \ by the way
run(@AutoItExe & " /AutoIt3ExecuteScript D:\test.au3")

This way, you're running the au3 file through the currently running exe.

Thanks greenmachine. Works great. I did try this earlier today

run(@AutoItExe & "D:\test.au3")

and now have it like you suggested. If I don't have a space between the first quote mark and the D, I get ==> Unable to execute the external program. Just was wondering why a single space would cause this.

really appreciate your expertise.

(@AutoItExe & " D:\test.au3")

Share this post


Link to post
Share on other sites

The reason is this:

The @AutoItExe macro holds a specific value, which is the path of either the compiled script that is running, or the installed AutoIt3.exe file. When you leave out the space, you are trying to run (for example) "C:\Program Files\AutoIt3\Autoit3.exeD:\test.au3", which won't work (for obvious reasons). The space comes in handy to separate the file from the parameter.

Share this post


Link to post
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
Sign in to follow this  
Followers 0