Jump to content
Sign in to follow this  
boat_58

Func Help Please

Recommended Posts

Hello, i am new to this and learning. Can someone help me with the code below? I am trying to get the function to run an autoit file when the function is called but i can't seem to get it right. The file is currently saved on my desktop at this location: I:\External Drive\Backup\AutoIt\AutoIt\Testing

HotKeySet('{ESC}', 'Stop')

Example()

Func Example()
    Run('Test13.au3')

EndFunc   ;==>Example



;Stop Function
Func Stop()
    Exit
    EndFunc ; Stop

 

Edited by boat_58

Share this post


Link to post
Share on other sites

Its not a bot for any game, its a bot that i want to automate some items on my computer. I am trying to figure out how to effectively make button and link them to different files in autoit. But each time i link it, it doesn't open.

Edited by boat_58

Share this post


Link to post
Share on other sites

u cant run script as au3 directly , u have two options :-
option 1:- 

$FilePath="I:\External Drive\Backup\AutoIt\AutoIt\Testing\Test13.au3"
Run(@AutoItExe & " /ErrorStdOut "&$FilePath)

option 2:-

compile au3 to exe and run it normaly
 

Share this post


Link to post
Share on other sites

It needs to be a separate process. When the button is clicked on, then that process will activate. 

I think Network Guy's option 2 is working

Share this post


Link to post
Share on other sites

sry i missed quotes :-

7 hours ago, Network_Guy said:

option 1:- 

$FilePath="I:\External Drive\Backup\AutoIt\AutoIt\Testing\Test13.au3"
Run(@AutoItExe & " /ErrorStdOut "&$FilePath)

 

try this code:-

$FilePath="I:\External Drive\Backup\AutoIt\AutoIt\Testing\Test13.au3"
Run(@AutoItExe & ' /ErrorStdOut "'&$filepath&'"')

 

Share this post


Link to post
Share on other sites

Okay i got it to open the files as exe files. Is there a way that when i start the script, the main script willl keep running until i stop it, but the mini scripts that i open, i have the power to stop them and start another script when i click the button associated with it? How do i make it so that i can start and stop each of those cases without closing out the main script? Each of those cases run another autoscript file to automate.

 

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Virus Scan
            V_Scan()

        Case $Spyware
            S_Scan()

        Case $Misc
            Misc()
        

        Case $Stop
            Exit


    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

why you close the main script at all ?

sry i cant get what you want , can u post your full code and what you try to achieve with it ? 

Share this post


Link to post
Share on other sites

Yes, sorry here is the full code. I want to run this script, i will get a menu with two buttons, V_Scan and S_Scan. When i click V_Scan, it will run V_Scan.exe. When i click S_Scan it will do the same for S_Scan.exe. How do i make it so i can run the main code, then select V_Scan, and then be able to add a stop V_Scan and then be able to start S_Scan also without having to stop the main script that is showing me the S_Scan and V_Scan menu.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


#Region ### START Koda GUI section ### Form=I:\External Drive\Backup\AutoIt\AutoIt\Testing\Auto_Control.kxf
$Auto_Control = GUICreate("Auto_Control", 190, 139, -1, -1)
Global $Stop_Auto = GUICtrlCreateButton("Stop_Auto", 56, 104, 83, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $V_Scan = GUICtrlCreateButton("V_Scan", 8, 8, 83, 25)
Global $S_Scan = GUICtrlCreateButton("S_Scan", 96, 8, 83, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###




While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $V_Scan
            V_Scan()

        Case $S_Scan
            S_Scan()

        Case $Stop_Auto
            Exit


    EndSwitch
WEnd

;Start V_Scan Function
Func V_Scan()
Run("V_Scan.exe")
EndFunc ; Stop

;Start S_Scan Function
Func S_Scan()
Run("S_Scan.exe")
EndFunc ; Stop

 

Edited by boat_58

Share this post


Link to post
Share on other sites
3 hours ago, boat_58 said:

How do i make it so i can run the main code, then select V_Scan, and then be able to add a stop V_Scan and then be able to start S_Scan also without having to stop the main script that is showing me the S_Scan and V_Scan menu.

The same way you can start process, you can close process with ProcessClose() :)


Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

1- you can stop the v_scan by killing its process using ProcessClose ,example :-

Global $V_PID

func V_scan()
$V_PID= Run("V_scan.exe")
endfunc

func Stop_V_Scan()
ProcessClose($V_PID)
endfunc

2-you can check if V_scan.exe is running or not by using ProcessExists , example :-

Global $V_PID

func V_scan()
$V_PID= Run("V_scan.exe")
endfunc


func State_V_Scan()
$state=ProcessExists($V_PID)
if $state = 0 then
; V_scan not running
else
;V_scan is running
endif
endfunc

BTW ,using run will open another process completely separated from main  script that mean :- even if u start V_scan and closed the main script v_scan still working on background
 

Share this post


Link to post
Share on other sites
2 hours ago, Network_Guy said:

1- you can stop the v_scan by killing its process using ProcessClose ,example :-

Global $V_PID

func V_scan()
$V_PID= Run("V_scan.exe")
endfunc

func Stop_V_Scan()
ProcessClose($V_PID)
endfunc

2-you can check if V_scan.exe is running or not by using ProcessExists , example :-

Global $V_PID

func V_scan()
$V_PID= Run("V_scan.exe")
endfunc


func State_V_Scan()
$state=ProcessExists($V_PID)
if $state = 0 then
; V_scan not running
else
;V_scan is running
endif
endfunc

BTW ,using run will open another process completely separated from main  script that mean :- even if u start V_scan and closed the main script v_scan still working on background
 

Thank you so much. This helps alot. I appreciate you

 

BTW, for the first one. how do you stop the process? What button do you press to have the V_Scan stop?

Edited by boat_58

Share this post


Link to post
Share on other sites

i didnt create button i just gave an example how to stop v_scan , u just need to create new button and link it to the Stop_V_scan function ,finally dont forget to create the global variables ($V_PID) and change your run command to 
 

$V_PID= Run("V_scan.exe")

 

 

Share this post


Link to post
Share on other sites

Last question:

How do i make the script window GUI stay frozen and active on my screen. So that it will always remain on top just like the AutoIT Info screen when opened?

Share this post


Link to post
Share on other sites
11 minutes ago, boat_58 said:

How do i make the script window GUI stay frozen and active on my screen. So that it will always remain on top just like the AutoIT Info screen when opened?

In help file, under GUICreate function, there is style and extended style you can set.  Like $WS_EX_TOPMOST....

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...