Jump to content

Having difficulties trying to run a function


98700
 Share

Recommended Posts

In my script you hit a key and it runs another .au3 script, and i am trying to get it so after that script is finished it will run another function in the main script. I have looked through the help file and i couldn't see any way i could do this. Any ideas?

Link to comment
Share on other sites

Oh and Welcome to the forums! :)

HotKeySet() may also be useful. Here is a small demo.

HotKeySet("{F1}", "_Launch")

Func _Launch()
    HotKeySet("{F1}")
    RunWait(@AutoItExe & " /AutoIt3ExecuteScript MyScript2.au3")
    _OnCompleteFunction()
    HotKeySet("{F1}", "_Launch")
EndFunc   ;==>_Launch

Func _OnCompleteFunction()
    MsgBox(64, Default, "Script has been run.")
EndFunc   ;==>_OnCompleteFunction

While 1
    Sleep(250)
WEnd

Hope this helps :mellow:

-smartee

Link to comment
Share on other sites

Thanks for the quick reply and the welcoming lol. Well i tried that code in mine, changed it around alittle, but all it does is i hit enter, and it doesnt run the exe (my other code). I didnt get any errors or anything.

Link to comment
Share on other sites

This is my main script...

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


$file_loc = @ScriptDir & "\LastChaos Find Position.au3"


Opt("TrayMenuMode", 1)
Opt("TrayMenuMode", 1)
#Region ### START Koda GUI section ###
$MultiBot = GUICreate("", 501, 501, 191, 124)
$File = GUICtrlCreateMenu("&File")
$Menu_Save = GUICtrlCreateMenuItem("Save"&@TAB&"Ctrl+S", $File)
$Spacer1 = GUICtrlCreateMenuItem("", $File)
$Menu_Exit = GUICtrlCreateMenuItem("Exit"&@TAB&"Esc", $File)
$Settings = GUICtrlCreateMenu("&Settings")
$Menu_Settings = GUICtrlCreateMenuItem("Settings", $Settings)
$Help = GUICtrlCreateMenu("&Help")
$Menu_About = GUICtrlCreateMenuItem("About", $Help)
$Spacer2 = GUICtrlCreateMenuItem("", $Help)
$Menu_Help = GUICtrlCreateMenuItem("Help"&@TAB&"F1", $Help)
$StatusBar = _GUICtrlStatusBar_Create($MultiBot)
Dim $StatusBar_PartsWidth[2] = [75, -1]
_GUICtrlStatusBar_SetParts($StatusBar, $StatusBar_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar, "$Test1", 0)
_GUICtrlStatusBar_SetText($StatusBar, @TAB & "$Test2", 1)
$Group1 = GUICtrlCreateGroup("Sign-in Bot", 8, 40, 489, 73)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$SignInBot = GUICtrlCreateCheckbox("", 24, 72, 17, 17)
$Username = GUICtrlCreateInput("Username", 56, 56, 121, 21)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Password = GUICtrlCreateInput("Password", 56, 80, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Radio1 = GUICtrlCreateRadio("Character 1", 224, 56, 100, 17)
$Radio2 = GUICtrlCreateRadio("Character 3", 224, 80, 100, 17)
$Radio3 = GUICtrlCreateRadio("Character 2", 328, 56, 100, 17)
$Radio4 = GUICtrlCreateRadio("Character 4", 328, 80, 100, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "Sign in Bot ( Click the check-box to activate )")
$Group2 = GUICtrlCreateGroup("Group1", 8, 128, 489, 97)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Group1", 8, 240, 489, 97)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Group1", 8, 352, 489, 97)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
TraySetIcon("", -1)
TraySetClick("22")
$Tray_About = TrayCreateItem("About")
$HelpTray = TrayCreateItem("Help")
$SpacerTray = TrayCreateItem("")
$ExitTray = TrayCreateItem("Exit")
Dim $MultiBot_AccelTable[3][2] = [["^s", $Menu_Save],["{ESC}", $Menu_Exit],["{F1}", $Menu_Help]]
GUISetAccelerators($MultiBot_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{ENTER}","LaunchScript")


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

Func LaunchScript ()
    HotKeySet("{Enter}")
    RunWait(@AutoItExe & "C:\Users\Jacob\Desktop\LastChaosFindPosition.exe")
    ShowPosition()
    HotKeySet("{Enter}", "_Launch")
EndFunc

Func ShowPosition()
    $LCposX = IniRead("C:\Users\Jacob\Desktop\LCPosition.ini", "Position", "X", "Null")
    $LCposY = IniRead("C:\Users\Jacob\Desktop\LCPosition.ini", "Position", "Y", "Null")
    $LCposition = GUICtrlCreateLabel("LC is at " & $LCposX & "' " & $LCposY & ".", 224, 25, 100, 17)
EndFunc

And this is the script i am trying to execute and wait til its finished to do something else..

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


Global $LastChaosX = 0
Global $LastChaosY = 0


HotKeySet( "{Tab}" ,"FoundLC")

WinMinimizeAll()

MsgBox(0,"Find Last Chaos", "Move mouse ontop of the Last Chaos Icon and push Tab")

Func FoundLC()
    $LCIcon = MouseGetPos()
    IniWrite("C:\Users\Jacob\Desktop\LCPosition.ini", "Position", "X", $LCIcon[0])
    IniWrite("C:\Users\Jacob\Desktop\LCPosition.ini", "Position", "Y", $LCIcon[1])
    MsgBox(0,"","Saved")
    $FoundLC = True
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by 98700
Link to comment
Share on other sites

Try

RunWait(@AutoItExe & " C:\Users\Jacob\Desktop\LastChaosFindPosition.au3")

Or

RunWait("C:\Users\Jacob\Desktop\LastChaosFindPosition.exe")

Pick one

And what gui do you suppose this is getting a Msg from

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

Because it dosent have a gui.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...