Jump to content

Script pausing


rdwray
 Share

Recommended Posts

  • Moderators

rdwray,

Not a very helpful description. :x

If you are referring to the script pausing when you click on the tray icon, then using Opt("TrayAutoPause", 0) will prevent that. You can alsO prevent it by removing the default tray icon menu items using Opt("TrayMenuMode", 1).

If not, please can we have a few more clues? :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

I don't know, it just quits working. The last time it quit and restarted by itself.

Seriously: What on earth do you expect to hear from us after given no information at all here?

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

Seriously: What on earth do you expect to hear from us after given no information at all here?

Here is all the information I have.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\Images\ico\Bible48.ico
#AutoIt3Wrapper_outfile=ShortCutBar.exe
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.3.6.1
 Author:         myName

 Script Function:
    Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#Include <ButtonConstants.au3>
#Include <Misc.au3>
#Include <WinAPI.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
Opt("TrayAutoPause",0)
Opt("MustDeclareVars", 0)

; Variables
Global $ASSOCF_VERIFY = 0x00000040
Global $ASSOCSTR_EXECUTABLE = 2

Global $dll =  DllOpen("user32.dll")                                                    ; _IsKeypressed events.
Global $i, $x, $y, $str, $WinPos                                                        ; Generic values
Global $ID, $hGuiBar, $bCtrl[27], $sc[27][3], $wOrt, $wLeft, $wTop                      ; GuiBar window.
Global $hGuiOpt, $file, $alias, $key, $showbar, $clear, $orient, $Save, $close, $exit   ; Options window.
Global $moved, $bID, $teststr                                                           ; Misc.

HotKeySet("!{F1}", "Help")

;=====================Read in data.=====================
LoadData()
Func LoadData()
    For $i = 1 to 26    ; Must have same value as control ID or tooltip crashes program.
        $sc[$i][1] = IniRead(@ScriptDir & "\ShortCuts.ini", "ShortCuts" & $i, "Program" & $i,  "")
        $sc[$i][2] = IniRead(@ScriptDir & "\ShortCuts.ini", "ShortCuts" & $i, "Alias" & $i,  "")
    Next

    $wOrt = IniRead(@ScriptDir & "\ShortCuts.ini", "Orientation", "Orient",  "")
    $wLeft = IniRead(@ScriptDir & "\ShortCuts.ini", "Position", "Left",  "")
    $wTop = IniRead(@ScriptDir & "\ShortCuts.ini", "Position", "Top",  "")
EndFunc
;=====================Create bar.=====================
CreateBar()
Func CreateBar()
    $x = 0
    $y = 0
    If $wOrt = "" Then $wOrt = 4    ; In case .ini is not found. .ini is generated on first save or exit.
    If $wOrt = 4 Then   ; Horizontal. $GUI_SS_DEFAULT_GUI, $WS_EX_TOOLWINDOW
        $hGuiBar = GUICreate("ShortCutBar", 24 * 26, 24, $wLeft, $wTop, $WS_POPUP, $WS_EX_TOOLWINDOW)
;       GUICtrlSetDefBkColor (0xff0000, $hGuiBar )  ; Keeps icons from appearing.
        GUISetFont(11, 400, 0, "Algerian")
        For $i = 1 to 26
            $bCtrl[$i] = GUICtrlCreateButton("", $x, 0, 24, 24, $BS_ICON)
;           GUICtrlSetBkColor( $bCtrl[$i], 0xff0000)    ; Keeps icons from appearing.
            LoadIcon($i)
            $x += 24
        Next
    Else    ; Verical.
        $hGuiBar = GUICreate("ShortCutBar", 24, 24 * 26,$wLeft, $wTop,  $WS_POPUP ,$WS_EX_TOOLWINDOW)
        GUISetFont(11, 400, 0, "Algerian")
        For $i = 1 to 26
            $bCtrl[$i] = GUICtrlCreateButton("", 0, $y, 24, 24, $BS_ICON + $BS_DEFPUSHBUTTON)
            LoadIcon($i)
            $y += 24
        Next
    EndIf
    GUISetState(@SW_SHOW, $hGuiBar)
EndFunc ; CreateBar()

Func LoadIcon($i)
Local $prog, $iconfound, $int
; Full internet string: ".ac",".af",".al",".am",".as",".at",".au",".az",".be",".biz",".bt",".ca",".cc",".ch",".cn",".coop",".cx",".cz",".de",".dk",".dz",".ec",".edu",".ee",".eg",".es",".fo",".fr",".ga",".gf",".gl",".gov",".gr",".gs",".hk",".il",".in",".info",".io",".is",".it",".jp",".kr",".kz",".li",".lu",".ly",".mc",".mil",".mm",".ms",".mx",".net",".nl",".no",".nu",".nz",".org",".pl",".pt",".ro",".ru",".se",".sg",".sg",566".tc",".st",".tc",".tf",".th",".tj",".tm",".to",".uk",".us",
Local $http[9] = [".com",".net",".org",".edu",".info",".us",".biz",".gov",".mil"]
; Executable
    If $sc[$i][1] = "" Then                                                 ; No data.
        GUICtrlSetData($bCtrl[$i], Chr($i + 64))
    ElseIf StringRight($sc[$i][1], 4) = ".exe" then                         ; Executable.
        GUICtrlSetImage($bCtrl[$i], $sc[$i][1], 1, 0)
    ElseIf StringMid($sc[$i][1], Stringlen($sc[$i][1]) -3, 1) = "." Then    ; Misc files
        $prog = _FileAssociation(StringRight($sc[$i][1], 4))                ; Get associated program for file type.
        If $prog ="" Then $prog = "Shell32.dll"                             ; Generic icon used when program not found.
        GUICtrlSetImage($bCtrl[$i], $prog, 1, 0)
    ElseIf StringLeft($sc[$i][1], 6) = "mailto" then                        ; Mail
        $var = RegRead("HKEY_CLASSES_ROOT\mailto\DefaultIcon", "")
        $var = StringLeft($var, Stringlen($var) -2)
        GUICtrlSetImage($bCtrl[$i], $var, 1, 0)
    ElseIf StringMid($sc[$i][1], 2, 2) = ":\"  And StringMid($sc[$i][1], Stringlen($sc[$i][1]) -3, 1) <> "." Then   ; Folders
        GUICtrlSetImage($bCtrl[$i], "Shell32.dll", 4, 0)    ; Folder icon.
    EndIf
; Internet
    For $int = 0 to 8
        If StringRight($sc[$i][1], StringLen($http[$int])) = $http[$int] Then
            GUICtrlSetImage($bCtrl[$i], @ProgramFilesDir & "\Internet Explorer\iexplore.exe", 1, 0)
        EndIf
    Next
EndFunc ; LoadIcon($i)
; _FileAssociation By WideBoyDixon
; http://www.autoitscript.com/forum/topic/96988-winapi-findexecutable-replacement/page__p__697477__hl__assocquerystringw__fromsearch__1#entry697477
Func _FileAssociation($sExt)
Local $aCall
    Local $aCall = DllCall("shlwapi.dll", "int", "AssocQueryStringW", _
            "dword", $ASSOCF_VERIFY, _
            "dword", $ASSOCSTR_EXECUTABLE, _
            "wstr", $sExt, _
            "ptr", 0, _
            "wstr", "", _
            "dword*", 65536)

    If @error Then
        Return SetError(1, 0, ""); call failed
    EndIf

    If Not $aCall[0] Then
        Return SetError(0, 0, $aCall[5])
    ElseIf $aCall[0] = 0x80070002 Then
        Return SetError(0, 0, "{unknown}"); COM Error 0x80070002, ?The system cannot find the file specified.'
    ElseIf $aCall[0] = 0x80004005 Then
        Return SetError(0, 0, "{fail}"); E_FAIL

    Else
        Return SetError(2, $aCall[0], "");
    EndIf
EndFunc ; _FileAssociation()

;=====================Create Options.=====================
    $hGuiOpt = GUICreate("Options", 500, 350, (@DesktopWidth / 2) -250, (@DesktopHeight / 2) - 150, $WS_BORDER )
    GUISetFont(11, 400, 0, "Tahoma")
    GUICtrlCreateLabel("Press Alt+F1 for help...", 20, 10)
    GUICtrlCreateLabel("Enter program path or:", 90, 40)
    $browse = GUICtrlCreateButton("Browse", 280, 30)
    $file = GUICtrlCreateInput("", 90, 70, 390, 30)
    GUICtrlSetData($file, $sc[1][1])
    GUICtrlCreateLabel("Enter name for shortcut:", 90, 110)
    $alias = GUICtrlCreateInput("", 90, 140, 390, 30)
    $Clear = GUICtrlCreateButton("&Clear", 200, 180, 120)

    GUICtrlSetData($alias, $sc[1][2])
    GUICtrlCreateLabel("Select" & @CRLF & "Key", 20, 45)
    $key = GUICtrlCreateList("A", 20, 90, 50, 150)
    For $i = 66 to 89
        $str &= Chr($i) & "|"
    Next
    $str &= "Z"
    GUICtrlSetData($key, $str, "A")
    $orient = GUICtrlCreateCheckbox("Checked = Verticle; Uncheck = Horizontal", 90, 220, 390)
    GUICtrlSetState($orient, $wOrt)
    GUICtrlCreateLabel("Save after each change!", 150, 250)
    $Save = GUICtrlCreateButton("&Save", 65, 280, 120)
    $close = GUICtrlCreateButton("&Close Options", 189, 280, 120)
    $exit = GUICtrlCreateButton("&Exit Program", 313, 280, 120)

 ; ExtractAssociatedIcon
Main()

Func Main()
    Local $tPOINT, $hWnd
    Local $oldBut, $oldkey
    $moved = False
    While 1
        $ID = GUIGetCursorInfo($hGuiBar)

        $tPOINT = _WinApi_GetMousePos()
        $hWnd = _WinApi_WindowFromPoint($tPOINT)
        $hParent = _WinApi_GetParent($hWnd)

        If _IsPressed("01", $dll) And WinActive($hGuiBar) Then RunProg()
        If _IsPressed("02", $dll)  And WinActive($hGuiBar) Then
            MoveBar($hGuiBar)
            If $moved = False And $ID[4] > 2 Then       ; If $moved = true the bar was moved - don't open options.
                GUICtrlSetData($key, Chr($ID[4] + 62))
                GUICtrlSetData($file, $sc[$ID[4]-2][1])
                GUICtrlSetData($alias, $sc[$ID[4]-2][2])
                $bID = $ID[4]   ; Open different window, save ID of button selected.
                GUISetState(@SW_SHOW, $hGuiOpt)   ; Open options window if the shortcur bar has not been moved.
                _WinAPI_SetFocus($save)
            EndIf
        EndIf

        If $hParent = $hGuiBar And $ID[4] > 2 And $ID[4] <> $oldBut Then
            If $sc[$ID[4]-2][2] <> "" Then
                Tooltip($sc[$ID[4]-2][2])
            else
                ToolTip("Press Alt+F1 for help." & @CRLF _
                    & "Right click to open options." & @CRLF _
                    & "Right click and hold to move.")
            EndIf
            $oldBut = $ID[4]
        EndIf
        If $hParent <> $hGuiBar Then ToolTip("")

        Switch  GUIGetMsg(0)
            Case $browse
                GUICtrlSetData($file, FileOpenDialog("Select file for shortcut", @HomeDrive, "All (*.*)", 1 ))
            Case $clear
                GUICtrlSetData($file, "")
                GUICtrlSetData($alias, "")
            Case $key   ; Load data based on key value.
                If GUICtrlRead($key) <> $oldkey Then
                    $oldkey = (Asc(GUICtrlRead($key))-64)
                    GUICtrlSetData($file, $sc[$oldkey][1])
                    GUICtrlSetData($alias, $sc[$oldkey][2])
                    $bID = $oldkey + 2  ; Update in case of concurrent save.
                EndIf
            Case $orient
                WriteFile()
                GUIDelete($hGuiBar)
                LoadData()
                CreateBar()
            Case $save
                $sc[$bID -2][1] = GUICtrlRead($file)
                $sc[$bID -2][2] = GUICtrlRead($alias)
                WriteFile()
                GUIDelete($hGuiBar)
                LoadData()
                CreateBar()
            Case $close
                GUISetState(@SW_HIDE, $hGuiOpt)
            Case $exit
                WriteFile()         ; Save position of window.
                GUIDelete($hGuiOpt)  ; Delete Options window.
                GUIDelete($hGuiBar)  ; Delete Shortcut window.
                Exit
        EndSwitch


    Wend
EndFunc ;<<--Main()

Func MoveBar($hWnd)
Local $PosDiff[2], $WinPos2
    While 1
Local $MousePos = MouseGetPos ()
    $WinPos = WinGetPos ($hWnd,"")
    $PosDiff[0] = $WinPos[0] - $MousePos[0]
    $PosDiff[1] = $WinPos[1] - $MousePos[1]

    While _IsPressed ("02", $dll)
        $MousePos = MouseGetPos ()
        WinMove ($hWnd, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
        WEnd
        Sleep (10)
        ExitLoop
    WEnd
    $WinPos2 = WinGetPos ($hWnd,"")
    If $WinPos2[0] < 0 Then WinMove("ShortCutBar", "", 0, $WinPos2[1])
    If $WinPos2[1] < 0 Then WinMove("ShortCutBar", "", $WinPos2[0], 0)
; +-3 allows for some movement error when trying to run program.
    If ($WinPos[0] < $WinPos2[0] - 3) Or ($WinPos[1] < $WinPos2[1] - 3) Or _
        ($WinPos[0] > $WinPos2[0] + 3) Or ($WinPos[1] > $WinPos2[1] + 3)Then
        $moved = True   ; If the window was moved, don't run program on return.
    Else
        $moved = False
    EndIf
    Sleep (10)
EndFunc

Func WriteFile()
    For $i = 1 to 26
        IniWrite(@ScriptDir & "\ShortCuts.ini", "ShortCuts" & $i, "Key" & $i,  Chr($i + 64))
        IniWrite(@ScriptDir & "\ShortCuts.ini", "ShortCuts" & $i, "Program" & $i,  $sc[$i][1])
        IniWrite(@ScriptDir & "\ShortCuts.ini", "ShortCuts" & $i, "Alias" & $i,  $sc[$i][2])
    Next

    IniWrite(@ScriptDir & "\ShortCuts.ini", "Orientation", "Orient", GUICtrlRead($orient))

    $WinPos = WinGetPos("ShortCutBar")
    If $WinPos[0] = "" then $WinPos[0] = 0
    If $WinPos[1] = "" then $WinPos[1] = 0
    IniWrite(@ScriptDir & "\ShortCuts.ini", "Position", "Left", $WinPos[0])
    IniWrite(@ScriptDir & "\ShortCuts.ini", "Position", "Top", $WinPos[1])
EndFunc

Func RunProg()
    If $ID[4] > 2 And $sc[$ID[4]-2][1] <> "" then ShellExecuteWait ($sc[$ID[4]-2][1])
    Sleep(100)  ; Got to give enough time for program to open or more copies will be ran.
EndFunc

Func Help()
Local $help = "Enter entire program path or button will may be blank." & @CRLF & @CRLF _
                & "If program does not have an icon and the full path is entered the button will not be changed." & @CRLF & @CRLF _
                & "If a file's full is entered in the program box, the associated program's icon will be on the button." & @CRLF & @CRLF _
                & "if a website is entered, it must be complete; your browser's icon will be on the button." & @CRLF & @CRLF _
                & "Enter anything in the name for shortcut box, it will show up in the tooltip." & @CRLF & @CRLF _
                & "Bar can be placed anywhere and it will be remembered."&  @CRLF & @CRLF _
                & "Right click to open options." & @CRLF & @CRLF _
                & "Right click and hold to move bar."

    MsgBox(0, "Shortcut Bar Help", $help)
EndFunc

BTW: As far as I know all AutoIt scripts will shut down if let to sit.

Edited by rdwray

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Link to comment
Share on other sites

  • Developers

Ok so we now have a script, so what exactly is your problem and when does it happen?

When your script stalls you probably want to add the Opt("TrayIconDebug", 1) option which could help you determine at what location in the script is is hanging.

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

Ok so we now have a script, so what exactly is your problem and when does it happen?

When your script stalls you probably want to add the Opt("TrayIconDebug", 1) option which could help you determine at what location in the script is is hanging.

Jos

Adding Opt("TrayIconDebug", 1). It happened last time when I had several (maybe 5) IE8 windows open. After I got done and closed the IE8 windows, it started working.

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Link to comment
Share on other sites

  • Developers

All the ones I have created do... Not one stays running all the time.

This says something about your scripts, not AutoIt3 itself :x

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

  • Moderators

rdwray,

I have several scripts that run on my machine from bootup to shutdown and I have never had one "shut down" unless I command it or there is an internal error which I have not managed correctly - which still happens every now and again, :P

Are you saying that all your AutoIt scripts shut down at some point with no error indicated? If so, do you have a periodic scan by some form of AV which might flag them as a problem? :x

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Obviously a script that ends will stop running, if you want it to keep running add in an endless loop somewhere.

while 1
    sleep(10)
wend

toonboon, I understand what you are saying, but I have a loop that feeds tooltips all the time based on the cursors position starting at line 161 and ending at line 231. If this is not correct, I will be more than happy to fix it. Edited by rdwray

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Link to comment
Share on other sites

rdwray,

I have several scripts that run on my machine from bootup to shutdown and I have never had one "shut down" unless I command it or there is an internal error which I have not managed correctly - which still happens every now and again, :P

Are you saying that all your AutoIt scripts shut down at some point with no error indicated? If so, do you have a periodic scan by some form of AV which might flag them as a problem? :x

M23

Yep, I have had them all to shut down. I am running MS security, Comodo firewall on MS OS 64bit. I am sure that MS Security is looking at every bit that is running on the machine.

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Link to comment
Share on other sites

I really didn't take a good enought look, but it shuts down any time IE8 has a window open and it doesn't make any difference if it minimized or not. I set the cursor up to change and that works, but nothing else including tooltips.

Edit: One more thing; if I set window to Always On Top, it works.

New Edit: I tried with Excel and it also takes presense over script. If I open another window like Explorer or Thunderbird or even another script after IE8 or Excel, the script starts working again.

Edited by rdwray

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

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