Jump to content

Compiled Script crashes


Recommended Posts

Describe the crash. What do you mean by "at a certain spot"? Do you get any errors? And what does the script do? Are there any differences between the circumstances in which you run the compiled and the non-compiled script? (E.g. are you running it on the same machine, with the same input etc.)

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

The script I'm making is that it will open up certain chrome tabs and automates some login processes if the correct password is entered in the input box. If a wrong password is entered in the input box, it would take a picture of the user by using the webcam and saves it (custom UDF) . So basically when I ran it in the script editor ( as in pressing F5 in the editor) , it worked perfectly fine. After compiling it into an exe , I ran it and when I entered the wrong password , it takes the picture and saves it then the "script.exe has stopped working" window would pop up.

Link to comment
Share on other sites

22 minutes ago, Jos said:

Well... show the script so we can have a look in case you like help from us.

Jos

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
#include <webcam.au3>
$i = _FileCountLines(@ScriptDir & "\games.txt") ; Detects the numbers of games


Global $Mainbox, $pass, $colour, $colour2, $colour3, $colour4, $game[$i], $line, $specificgame, $launchrequest, $wrong, $cheeky, $bypass

dailyroutine()
RainmeterAutoCloser()

Func dailyroutine()
    Do

        $Mainbox = InputBox(" Daily Routine ", "Access codes", "", "*")
        $pass = "thxforhelpingout"
        $cheeky = "ichangethepasswordscauseitsprivate"
        $bypass = "bypass"


        Select
            Case $Mainbox = $pass
                AutoItSetOption("MouseCoordMode", 0)
                AutoItSetOption("PixelCoordMode", 0)
                ShellExecute("chrome.exe")
                WinWait("New Tab - Google Chrome", "Chrome Legacy Window")
                WinSetState("New Tab - Google Chrome", "Chrome Legacy Window", @SW_MAXIMIZE)
                Sleep(500)
                Send("f")
                Send("{ENTER}")
                Do ; check to see whether Facebook is loaded
                    $colour = PixelGetColor(36, 20)
                    Sleep(200)
                Until $colour = 4743843
                Send("email@yahoo.com" & "{TAB}")
                Send("facebookpassword")
                Send("{ENTER}")
                Sleep(500)
                Send("^t")
                Send("https://www.youtube.com/user/DashieGames/videos")
                Send("{ENTER}")
                MsgBox(0, "Routine has been Executed", "Background processes are running and have a nice day :)")


            Case $Mainbox = $cheeky
                AutoItSetOption("MouseCoordMode", 0)
                AutoItSetOption("PixelCoordMode", 0)
                ShellExecute("chrome.exe")
                WinWait("New Tab - Google Chrome", "Chrome Legacy Window")
                WinSetState("New Tab - Google Chrome", "Chrome Legacy Window", @SW_MAXIMIZE)
                Sleep(500)
                Send("g")
                Send("{ENTER}")
                Sleep(500)
                Send("Tom Cruise")
                Send("{ENTER}")


            Case $Mainbox = $bypass
                Sleep(200)

            Case Else
                $gui = GUICreate("Webcam UDF Test", 640, 480)
                _WebcamInit()
                _Webcam($gui, 640, 480, 0, 0)
                GUISetState(@SW_HIDE)
                Sleep(500)
                _WebcamSnapShot(@ScriptDir & "\snapshot" & @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC & ".bmp")
                _WebcamStop()                                                                                          ; it crashes over here ###############################################################################################
                $wrong = MsgBox(69, "Access Denied", "Wrong code detected," & @CRLF & "Retry or Cancel?")

        EndSelect


        If $wrong = 2 Then
            ExitLoop
        EndIf

    Until $Mainbox = $pass Or $Mainbox = $cheeky Or $Mainbox = $bypass

EndFunc   ;==>dailyroutine

Func RainmeterAutoCloser()
    If $i = 0 Then
        MsgBox(16, "Error", "File needs to have at least one entry")
        Exit
    EndIf

    $launchrequest = MsgBox(36, "Rainmeter Auto Closer", $i & " game(s) successfully detected." & @CRLF & "Activate Rainmeter Auto Closer?")

    If $launchrequest = 6 Then
        MsgBox(64, "Rainmeter Auto Closer", " Script is now running. " & @CRLF & "To end the script, navigate to the system tray and end it.")
        For $a = 0 To UBound($game) - 1 ; assigns arrays to their respective games
            $line = $a + 1
            $game[$a] = FileReadLine(@ScriptDir & "\games.txt", $line)
        Next

        While 1

            While 1
                For $b = 0 To UBound($game) - 1
                    If ProcessExists($game[$b]) <> 0 Then ; detects if either one of the games are running
                        $specificgame = $b ; stated to be used for detecting the specific program that is launched
                        ConsoleWrite("Detected process exists" & @CRLF)
                        ProcessClose("Rainmeter.exe")
                        ExitLoop 2
                    EndIf
                    Sleep(200)
                Next
            WEnd

            ConsoleWrite("Exited First Function Loops" & @CRLF)

            While 1
                If ProcessExists($game[$specificgame]) = 0 Then ; detects if the specific program that is launched has been closed
                    ConsoleWrite("Specific Game has ended" & @CRLF)
                    Run("C:\Program Files\Rainmeter\Rainmeter.exe")
                    ExitLoop
                EndIf
                Sleep(200)

            WEnd

        WEnd
    EndIf

    If $launchrequest = 7 Then
        MsgBox(64, "Rainmeter Auto Closer", "Script Stopped")
    EndIf
EndFunc   ;==>RainmeterAutoCloser


 

Edited by Jos
Added codebox
Link to comment
Share on other sites

  • Developers

I don't have your include files and likely the cause is in that include file.
Did you do any debugging by adding some sort of logging?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

21 minutes ago, Jos said:

I don't have your include files and likely the cause is in that include file.
Did you do any debugging by adding some sort of logging?

Jos

#include-once
#include <GUIConstants.au3>

;~ #####################################################
;~ ###                                               ###
;~ ###                  Webcam UDF                   ###
;~ ###                                               ###
;~ ### Functions : _WebcamInit()                     ###
;~ ###             _Webcam()                         ###
;~ ###             _WebcamStop()                     ###
;~ ###             _WebcamSnapShot()                 ###
;~ ###                                               ###
;~ ###                Made by L|M|TER                ###
;~ ### --------------------------------------------- ###
;~ ###                                               ###
;~ ###           Copyright ©2008 - L|M|TER          ###
;~ ###                                               ###
;~ #####################################################

;~ Declaring Variables

$WM_CAP_START = 0x400
$WM_CAP_UNICODE_START = $WM_CAP_START +100 
$WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 
$WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 
$WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW 
$WM_CAP_ABORT = $WM_CAP_START + 69 
$WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 
$WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 
$WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 
$WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 
$WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 
$WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 
$WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 
$WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 
$WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 
$WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 
$WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 
$WM_CAP_EDIT_COPY = $WM_CAP_START + 30 
$WM_CAP_END = $WM_CAP_UNICODE_END 
$WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 
$WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 
$WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 
$WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 
$WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 
$WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 
$WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 
$WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 
$WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 
$WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 
$WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 
$WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 
$WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 
$WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 
$WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 
$WM_CAP_GET_STATUS = $WM_CAP_START + 54 
$WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 
$WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 
$WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 
$WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 
$WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 
$WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 
$WM_CAP_PAL_OPENA = $WM_CAP_START + 80 
$WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 
$WM_CAP_PAL_PASTE = $WM_CAP_START + 82 
$WM_CAP_SEQUENCE = $WM_CAP_START + 62 
$WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 
$WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 
$WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 
$WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 
$WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 
$WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 
$WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 
$WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 
$WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 
$WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 
$WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 
$WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 
$WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 
$WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 
$WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 
$WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 
$WM_CAP_SET_SCALE = $WM_CAP_START + 53 
$WM_CAP_SET_SCROLL = $WM_CAP_START + 55 
$WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 
$WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 
$WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 
$WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 
$WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 
$WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 
$WM_CAP_STOP = $WM_CAP_START + 68
$cap = ""
$avi = ""
$user = ""
$snapfile = @ScriptDir & "\snapshot.bmp"

;~ ##########################################################
;~ Function Name : _WebcamInit()
;~ Description : Starts the webcam image capturing session
;~ Author : L|M|TER
;~ ##########################################################

Func _WebcamInit()
$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")
EndFunc

;~ ##########################################################
;~ Function Name : _Webcam($gui,$h,$w,$l,$t)
;~ Description : Creates a webcam preview window
;~ Parameter(s):
;~  $gui - The gui where the webcam window should be created
;~  $h - The height of the webcam window
;~  $w - The width of the webcam window
;~  $l - The left position of the webcam window
;~  $t - The top position of the webcam window
;~ NOTE : All parameters required !
;~ Author : L|M|TER
;~ ##########################################################

Func _Webcam($gui,$w,$h,$l,$t)
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", $l, "int", $t, "int", $w, "int", $h, "hwnd", $gui, "int", 1)

DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)
EndFunc

;~ ##########################################################
;~ Function Name : _WebcamStop()
;~ Description : Closes the webcam image capturing session
;~ Author : L|M|TER
;~ ##########################################################

Func _WebcamStop()
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
        DllClose($user)
        DllClose($avi)
EndFunc

;~ ##########################################################
;~ Function Name : _WebcamSnapShot($file)
;~ Description : Takes a snapshot
;~ Parameter(s):
;~  $file (Optional) - The path to the file where the snapshot will be saved (Default : @ScriptDir & "\snapshot.bmp")
;~ Author : L|M|TER
;~ ##########################################################

Func _WebcamSnapShot($file = $snapfile)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $file)
EndFunc

Here's the webcam.au3 file, and also one question. Why would it work before compiling and wouldn't work after compiling?

Link to comment
Share on other sites

  • Developers

Probably, but you/somebody will have to dive into fixing the UDF you use to make a snapshot with the PC camera.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

How about a simple reproducer?

#include <File.au3>
#include <Webcam.au3>

$gui = GUICreate("Webcam UDF Test", 700, 500)
GUISetState()
_WebcamInit()
_Webcam($gui, 640, 480, 0, 0)
Sleep(1000)
_WebcamStop()

It's a lot easier to troubleshoot without all that other unrelated code blurring possible paths.

Good luck fixing :) 

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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