Jump to content

Problem


 Share

Recommended Posts

#RequireAdmin
#Region
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=HEX
#AutoIt3Wrapper_Res_Description=HEX
#AutoIt3Wrapper_Res_Fileversion=0.2
#AutoIt3Wrapper_Res_LegalCopyright=Copyright ©2017, Farming Inc.
#EndRegion

#Region Declare
$inipath = @ScriptDir & "\Settings.ini"
$scriptpath = _FileListToArray(@ScriptDir & "\Scripts", "*.au3", 1, False)
$Nope = "Nope"
$scriptrunning = False
Global $scriptid[0]
Global $items
#EndRegion Declare

HotKeySet("{F11}", "Script_Run")

#Region Form
$gui = GUICreate($Nope, 367, 338)
$guitab = GUICtrlCreateTab(8, 8, 353, 321)
$tabmain = GUICtrlCreateTabItem("Main")
$mainstatus = GUICtrlCreateEdit("", 16, 40, 335, 280, BitOR(2048, 2097152))
GUICtrlSetColor(-1, 12632256)
GUICtrlSetBkColor(-1, 65793)
$tabscript = GUICtrlCreateTabItem("Scripts")
$scriptlistlabel = GUICtrlCreateLabel("Featured Scripts", 16, 40, 100, 16)
$scriptlist = GUICtrlCreateList("", 16, 60, 165, 240, -1, 0)
For $i = 1 To $scriptpath[0] Step 1
    GUICtrlSetData($scriptlist, $scriptpath[$i] & "|")
Next
status("Scripts Loaded")
$scriptselectedlabel = GUICtrlCreateLabel("Selected Scripts", 185, 40, 80, 16)
$scriptselected = GUICtrlCreateList("", 185, 60, 165, 240, -1, 0)
$scriptinfo = GUICtrlCreateButton("Info ^", 15, 300, 82, 20)
$scriptadd = GUICtrlCreateButton("Select ->", 100, 300, 82, 20)
$scriptdel = GUICtrlCreateButton("<- Remove Script", 184, 300, 167, 20)
$tabhelp = GUICtrlCreateTabItem("Help")
$helptopic = GUICtrlCreateCombo("", 16, 40, 335, 25, BitOR(3, 64))
GUICtrlSetData(-1, "About|How to use?|Scripting|Credits", "")
$helptext = GUICtrlCreateEdit("Select a topic.", 16, 64, 335, 256, BitOR(2048, 2097152))
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
status("GUI Loaded")
#EndRegion Form
status("Nope started")

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $helptopic
            help()
        Case $scriptinfo
            script_info(GUICtrlRead($scriptlist))
        Case $scriptadd
            script_add(GUICtrlRead($scriptlist))
        Case $scriptdel
            script_del(GUICtrlRead($scriptselected))
    EndSwitch
WEnd

#Region Main
Func status($textline)
    Local $text = GUICtrlRead($mainstatus)
    $text = $text & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & $textline & @CRLF
    GUICtrlSetData($mainstatus, $text)
EndFunc   ;==>status
Func terminate()
    If $scriptrunning = True Then
        script_stop()
    EndIf
    Exit
EndFunc   ;==>terminate
#EndRegion Main
#Region Script
Func script_add($path)
    If $path And _GUICtrlListBox_FindString($scriptselected, $path, True) = -1 Then
        GUICtrlSetData($scriptselected, $path & "|")
        status("Script_Add() -> Success")
    Else
        status("Script_Add() -> Fail")
    EndIf
EndFunc   ;==>script_add
Func script_del($path)
    If $path Then
        $index = _GUICtrlListBox_FindString($scriptselected, $path, True)
        _GUICtrlListBox_DeleteString($scriptselected, $index)
        status("Script_Del() -> Success")
    Else
        status("Script_Del() -> Fail")
    EndIf
EndFunc   ;==>script_del
Func script_info($path)
    If $path Then
        $path = @ScriptDir & "\Scripts" & "\" & $path
        $name = _StringBetween(FileReadLine($path, 1), ";<Name>", "</Name>")
        $category = _StringBetween(FileReadLine($path, 2), ";<Category>", "</Category>")
        $author = _StringBetween(FileReadLine($path, 3), ";<Author>", "</Author>")
        $text = "Name: " & $name[0] & @CRLF & "Category: " & $category[0] & @CRLF & "Author: " & $author[0]
        MsgBox(64, $Nope, $text)
        status("Script_Info() -> Success")
    Else
        status("Script_Info() -> Fail")
    EndIf
EndFunc   ;==>script_info
Func script_run()
    $items = _guictrllistbox_getitems($scriptselected)
    If UBound($items) <> 0 Then
        ReDim $scriptid[UBound($items)]
        For $i = 0 To UBound($items) - 1 Step 1
            $path = @ScriptDir & "\Scripts" & "\" & $items[$i]
            $scriptid[$i] = _runau3($path)
            HotKeySet("{F11}")
            HotKeySet("{F11}", "Script_Stop")
        Next
        $scriptrunning = True
        status("Script_Run() -> Success")
    Else
        status("Script_Run() -> Fail")
    EndIf
EndFunc   ;==>script_run
Func script_start()
    For $i = 0 To UBound($scriptid) - 1 Step 1
        ProcessClose($scriptid[$i])
    Next
    HotKeySet("{F11}")
    HotKeySet("{F11}", "Script_Run")
    $scriptrunning = False
EndFunc   ;==>script_stop
#EndRegion Script
#Region Help
Func help()
    Local $text = ""
    Switch GUICtrlRead($helptopic)
        Case
        $text
    EndSwitch
    GUICtrlSetData($helptext, $text)
    status("Help() -> Success")
EndFunc   ;==>help
#EndRegion Help
#Region Includes
Func _FileListToArray($sfilepath, $sfilter = "*", $iflag = 0, $breturnpath = False)
    Local $sdelimiter = "|", $sfilelist = "", $sfilename = "", $sfullpath = ""
    $sfilepath = StringRegExpReplace($sfilepath, "[\\/]+$", "") & "\"
    If $iflag = Default Then $iflag = 0
    If $breturnpath Then $sfullpath = $sfilepath
    If $sfilter = Default Then $sfilter = "*"
    If Not FileExists($sfilepath) Then Return SetError(1, 0, 0)
    If StringRegExp($sfilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0)
    If Not ($iflag = 0 Or $iflag = 1 Or $iflag = 2) Then Return SetError(3, 0, 0)
    Local $hsearch = FileFindFirstFile($sfilepath & $sfilter)
    If @error Then Return SetError(4, 0, 0)
    While 1
        $sfilename = FileFindNextFile($hsearch)
        If @error Then ExitLoop
        If ($iflag + @extended = 2) Then ContinueLoop
        $sfilelist &= $sdelimiter & $sfullpath & $sfilename
    WEnd
    FileClose($hsearch)
    If $sfilelist = "" Then Return SetError(4, 0, 0)
    Return StringSplit(StringTrimLeft($sfilelist, 1), $sdelimiter)
EndFunc   ;==>_filelisttoarray

Func _StringBetween($sstring, $sstart, $send, $imode = 0, $bcase = False)
    $sstart = $sstart ? "\Q" & $sstart & "\E" : "\A"
    If $imode <> 1 Then $imode = 0
    If $imode = 0 Then
        $send = $send ? "(?=\Q" & $send & "\E)" : "\z"
    Else
        $send = $send ? "\Q" & $send & "\E" : "\z"
    EndIf
    If $bcase = Default Then
        $bcase = False
    EndIf
    Local $areturn = StringRegExp($sstring, "(?s" & (Not $bcase ? "i" : "") & ")" & $sstart & "(.*?)" & $send, 3)
    If @error Then Return SetError(1, 0, 0)
    Return $areturn
EndFunc   ;==>_stringbetween

Func _guictrllistbox_getitems($ctrlid)
    Local $items[_GUICtrlListBox_GetCount($ctrlid)]
    For $i = 0 To UBound($items) - 1 Step 1
        $items[$i] = _GUICtrlListBox_GetText($ctrlid, $i)
    Next
    Return $items
EndFunc   ;==>_guictrllistbox_getitems

Func _runau3($sfilepath, $sworkingdir = "", $ishowflag = @SW_SHOW, $ioptflag = 0)
    Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sfilepath & '"', $sworkingdir, $ishowflag, $ioptflag)
EndFunc   ;==>_runau3

Func _GUICtrlListBox_FindString($hwnd, $stext, $bexact = False)
    If Not IsString($stext) Then $stext = String($stext)
    If IsHWnd($hwnd) Then
        If ($bexact) Then
            Return _SendMessage($hwnd, 418, -1, $stext, 0, "wparam", "wstr")
        Else
            Return _SendMessage($hwnd, 399, -1, $stext, 0, "wparam", "wstr")
        EndIf
    Else
        If ($bexact) Then
            Return GUICtrlSendMsg($hwnd, 418, -1, $stext)
        Else
            Return GUICtrlSendMsg($hwnd, 399, -1, $stext)
        EndIf
    EndIf
EndFunc   ;==>_guictrllistbox_findstring

Func _GUICtrlListBox_DeleteString($hwnd, $iindex)
    If IsHWnd($hwnd) Then
        Return _SendMessage($hwnd, 386, $iindex)
    Else
        Return GUICtrlSendMsg($hwnd, 386, $iindex, 0)
    EndIf
EndFunc   ;==>_guictrllistbox_deletestring

Func _GUICtrlListBox_GetCount($hwnd)
    If IsHWnd($hwnd) Then
        Return _SendMessage($hwnd, 395)
    Else
        Return GUICtrlSendMsg($hwnd, 395, 0, 0)
    EndIf
EndFunc   ;==>_guictrllistbox_getcount

Func _GUICtrlListBox_GetText($hwnd, $iindex)
    Local $ttext = DllStructCreate("wchar Text[" & _GUICtrlListBox_GetTextLen($hwnd, $iindex) + 1 & "]")
    If Not IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
    _SendMessage($hwnd, 393, $iindex, $ttext, 0, "wparam", "struct*")
    Return DllStructGetData($ttext, "Text")
EndFunc   ;==>_guictrllistbox_gettext

Func _GUICtrlListBox_GetTextLen($hwnd, $iindex)
    If IsHWnd($hwnd) Then
        Return _SendMessage($hwnd, 394, $iindex)
    Else
        Return GUICtrlSendMsg($hwnd, 394, $iindex, 0)
    EndIf
EndFunc   ;==>_guictrllistbox_gettextlen

Func _SendMessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
    Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
    If @error Then Return SetError(@error, @extended, "")
    If $ireturn >= 0 And $ireturn <= 4 Then Return $aresult[$ireturn]
    Return $aresult
EndFunc   ;==>_sendmessage
#EndRegion Includes

 

Hello :)

I have a small problem with my Stuff:

Sometimes when i Press F11 i get in Console that the Script was activated / running. But the Script isnt runnig.

Sometimes it load the Script thats what makes me worried.

 

Thanks for helping,

Xenos2017

Link to comment
Share on other sites

  • Moderators

@Xenos2017 your script A: isn't runnable. and B: looks a lot like a farming/game automation script. Locking thread, you are welcome to PM me to convince me otherwise.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...