Sign in to follow this  
Followers 0
stuka

...

11 posts in this topic

#1 ·  Posted (edited)

.

Edited by stuka

Share this post


Link to post
Share on other sites



Here's my try at the scrolling anyways...

#include <GUIConstants.au3>

$Form1 = GUICreate("Window", 293, 427, 235, 242)
$Button1 = GUICtrlCreateButton("Exit", 16, 392, 123, 25, 0)

$Label1 = GUICtrlCreateLabel("James", Round(235/2), 100)
$Label2 = GUICtrlCreateLabel("Mike", Round(235/2), 120)
$Label3 = GUICtrlCreateLabel("Randy", Round(235/2), 140)
$Label4 = GUICtrlCreateLabel("Albert", Round(235/2), 160)
$Label5 = GUICtrlCreateLabel("Marcello", Round(235/2), 180)

GUISetState(@SW_SHOW)

$begin = TimerInit()
$sec = 0
$i = 200

While 1

    $nMsg = GUIGetMsg()
    $dif = TimerDiff($begin)
    If $dif > $sec Then
        GUICtrlSetPos($Label1, Round(235/2), $i)
        GUICtrlSetPos($Label2, Round(235/2), $i+20)
        GUICtrlSetPos($Label3, Round(235/2), $i+40)
        GUICtrlSetPos($Label4, Round(235/2), $i+60)
        GUICtrlSetPos($Label5, Round(235/2), $i+80)
        $i = $i - 1
        If $i = -180 Then
            $i = 427
        EndIf
        $sec = $sec + 40
    EndIf
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Here's my try at the scrolling anyways...

#include <GUIConstants.au3>

$Form1 = GUICreate("Window", 293, 427, 235, 242)
$Button1 = GUICtrlCreateButton("Exit", 16, 392, 123, 25, 0)

$Label1 = GUICtrlCreateLabel("James", Round(235/2), 100)
$Label2 = GUICtrlCreateLabel("Mike", Round(235/2), 120)
$Label3 = GUICtrlCreateLabel("Randy", Round(235/2), 140)
$Label4 = GUICtrlCreateLabel("Albert", Round(235/2), 160)
$Label5 = GUICtrlCreateLabel("Marcello", Round(235/2), 180)

GUISetState(@SW_SHOW)

$begin = TimerInit()
$sec = 0
$i = 200

While 1

    $nMsg = GUIGetMsg()
    $dif = TimerDiff($begin)
    If $dif > $sec Then
        GUICtrlSetPos($Label1, Round(235/2), $i)
        GUICtrlSetPos($Label2, Round(235/2), $i+20)
        GUICtrlSetPos($Label3, Round(235/2), $i+40)
        GUICtrlSetPos($Label4, Round(235/2), $i+60)
        GUICtrlSetPos($Label5, Round(235/2), $i+80)
        $i = $i - 1
        If $i = -180 Then
            $i = 427
        EndIf
        $sec = $sec + 40
    EndIf
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
    EndSwitch
WEnd
Tested your code, works, but there is a flicker.....not sure on how to solve that one...

Share this post


Link to post
Share on other sites

You could tweak the AdlibEnable time.

Original:

AdlibEnable('Adlib', 100)

Compiled uses 50% cpu / 4,060 K ram

Modified:

AdlibEnable('Adlib', 200)

Compiled uses 50% cpu / 4,056 K ram ???

Hmm not such a change after all.

Share this post


Link to post
Share on other sites

It seem like the AdlibEnable function is eating up cpu time.

If you comment out:

;AdlibEnable('Adlib', 250)

and add this right below it:

While 1
$iScrollPos += 1
ControlMove($child, '', $label, 0, -$iScrollPos)
If $iScrollPos > 510 Then $iScrollPos = -60
Sleep(250)
WEnd

Your cpu usage will drop to almost zero but ram usage will still be >4K

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Done. Using AutoIt's native functions only.. Includes transparency.

#include <GUIConstants.au3>

$sScrollText = 'A long time ago in a galaxy' & @CRLF & _
'far, far away...' & @CRLF & _
@CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & _
'It is a period of civil war.' & @CRLF & _
'Rebel spaceships, striking' & @CRLF & _
'from a hidden base, have won' & @CRLF & _
'their first victory against' & @CRLF & _
'the evil Galactic Empire.' & @CRLF & _
@CRLF & _
'During the battle, Rebel' & @CRLF & _
'spies managed to steal secret' & @CRLF & _
'plans to the Empire''s' & @CRLF & _
'ultimate weapon, the DEATH' & @CRLF & _
'STAR, an armored space' & @CRLF & _
'station with enough power to' & @CRLF & _
'destroy an entire planet.' & @CRLF & _
@CRLF & _
'Pursued by the Empire''s' & @CRLF & _
'sinister agents, Princess' & @CRLF & _
'Leia races home aboard her' & @CRLF & _
'starship, custodian of the' & @CRLF & _
'stolen plans that can save her' & @CRLF & _
'people and restore' & @CRLF & _
'freedom to the galaxy...'

$sMain = GUICreate("Firefox About window", 270 ,370,-1,-1)
GUISetBkColor(0xFFFFFF)

GUISetFont(12,400,0,"Verdana")

$sLabel = GUICtrlCreateLabel($sScrollText,10,370/3,250,10000,$ES_CENTER)

$sTransHeight = 5
For $x = 0 to 15
    $stemp = GUICreate("",270, $sTransHeight, 0, $sTransHeight * $x ,BitOR($WS_POPUP,$WS_CHILD),$WS_EX_MDICHILD,$sMain)
    GUISetState()
    WinSetTrans($stemp,"",(255/15)*(-1*($x-15)))
Next

For $x = 0 to 15
    $stemp = GUICreate("",270, $sTransHeight, 0, 365 - ($sTransHeight * $x) ,BitOR($WS_POPUP,$WS_CHILD),$WS_EX_MDICHILD,$sMain)
    GUISetState()
    WinSetTrans($stemp,"",(255/15)*(-1*($x-15)))
Next

GUISetState(@SW_SHOW,$sMain)
$sTime = TimerInit()

$sScroll = 5
$sFirstTime = 1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If ($sFirstTime AND TimerDiff($sTime) > 2000) OR (Not $sFirstTime AND TimerDiff($sTime) > 30) Then
        $sFirstTime = 0
        $sTime = TimerInit()
        ControlMove($sMain,"",$sLabel,10,(370/3)-$sScroll)
        $sScroll += 1
    EndIf
WEnd
Edited by Manadar

Share this post


Link to post
Share on other sites

Added the repeating part:

#include <GUIConstants.au3>

$sScrollText = 'A long time ago in a galaxy' & @CRLF & _
'far, far away...' & @CRLF & _
@CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & _
'It is a period of civil war.' & @CRLF & _
'Rebel spaceships, striking' & @CRLF & _
'from a hidden base, have won' & @CRLF & _
'their first victory against' & @CRLF & _
'the evil Galactic Empire.' & @CRLF & _
@CRLF & _
'During the battle, Rebel' & @CRLF & _
'spies managed to steal secret' & @CRLF & _
'plans to the Empire''s' & @CRLF & _
'ultimate weapon, the DEATH' & @CRLF & _
'STAR, an armored space' & @CRLF & _
'station with enough power to' & @CRLF & _
'destroy an entire planet.' & @CRLF & _
@CRLF & _
'Pursued by the Empire''s' & @CRLF & _
'sinister agents, Princess' & @CRLF & _
'Leia races home aboard her' & @CRLF & _
'starship, custodian of the' & @CRLF & _
'stolen plans that can save her' & @CRLF & _
'people and restore' & @CRLF & _
'freedom to the galaxy...'

$sMain = GUICreate("Firefox About window", 270 ,370,-1,-1)
GUISetBkColor(0xFFFFFF)

GUISetFont(12,400,0,"Verdana")

$sLabel = GUICtrlCreateLabel($sScrollText,10,370/3,250,10000,$ES_CENTER)

$sTransHeight = 5
For $x = 0 to 15
    $stemp = GUICreate("",270, $sTransHeight, 0, $sTransHeight * $x ,BitOR($WS_POPUP,$WS_CHILD),$WS_EX_MDICHILD,$sMain)
    GUISetState()
    WinSetTrans($stemp,"",(255/15)*(-1*($x-15)))
Next

For $x = 0 to 15
    $stemp = GUICreate("",270, $sTransHeight, 0, 365 - ($sTransHeight * $x) ,BitOR($WS_POPUP,$WS_CHILD),$WS_EX_MDICHILD,$sMain)
    GUISetState()
    WinSetTrans($stemp,"",(255/15)*(-1*($x-15)))
Next

GUISetState(@SW_SHOW,$sMain)
$sTime = TimerInit()

$sScroll = 5
$sFirstTime = 1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If ($sFirstTime AND TimerDiff($sTime) > 2000) OR (Not $sFirstTime AND TimerDiff($sTime) > 30) Then
        $sFirstTime = 0
        $sTime = TimerInit()
        ControlMove($sMain,"",$sLabel,10,(370/3)-$sScroll)
        $sScroll += 1
        If $sScroll > 700 Then
            $sScroll = - 270
        EndIf
    EndIf
WEnd

Share this post


Link to post
Share on other sites

Manadar, how did you add a Pause before it starts scrolling? My way of adding a Pause isn't that effective especially in my script.

You think you can figure what's wrong with my script?(a few replies above) I have problems implementing the About window into my full script as well.

Thank you.

Using TimerDiff () :)

Share this post


Link to post
Share on other sites

The scrolling About window's script has a loop in it but my full script also has another loop in it because i used TrayCreateItem to create the tray menu options.

The problem is now there are 2 loops, I've tried integrating the 'About' window script into my full script but the About window window fails to start scrolling, even if it does, the other part of the script fails to function.

I'm not very sure about inserting a loop in a loop and for it to still work...any ideas?

If my question is vague, I can further explain :)

Are you able to give us the loops? I might be able to merge them. The other option is AdLibEnable.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I was kind of hoping you would go with my layout, but I guess it is your choice to make. :)

#include <GUIConstants.au3>
#Include <Constants.au3>
#include <Misc.au3>

$sScrollText = 'A long time ago in a galaxy' & @CRLF & _
'far, far away...' & @CRLF & _
@CRLF & _
'It is a period of civil war.' & @CRLF & _
'Rebel spaceships, striking' & @CRLF & _
'from a hidden base, have won' & @CRLF & _
'their first victory against' & @CRLF & _
'the evil Galactic Empire.' & @CRLF & _
@CRLF & _
'During the battle, Rebel' & @CRLF & _
'spies managed to steal secret' & @CRLF & _
'plans to the Empire''s' & @CRLF & _
'ultimate weapon, the DEATH' & @CRLF & _
'STAR, an armored space' & @CRLF & _
'station with enough power to' & @CRLF & _
'destroy an entire planet.' & @CRLF & _
@CRLF & _
'Pursued by the Empire''s' & @CRLF & _
'sinister agents, Princess' & @CRLF & _
'Leia races home aboard her' & @CRLF & _
'starship, custodian of the' & @CRLF & _
'stolen plans that can save her' & @CRLF & _
'people and restore' & @CRLF & _
'freedom to the galaxy...'

Global $sScroll = 5
Global $sFirstTime = 1
Global $iScrollPos = -5

Global $sStart = 0

; prevent duplicate processes
If _Singleton (@ScriptName, 1) = 0 Then
    Exit
EndIf

; prevent script exit on error
Opt ("RunErrorsFatal", 0)

; remove default tray icon menu
Opt ("TrayMenuMode", 1)

; no pause when tray icon clicked
Opt ("TrayAutoPause", 0)

Opt("GUIOnEventMode",1)

; label variable
$title = "software"

; install temp billygoat.jpg file
FileInstall ("picture.jpg", @TempDir & "\picture.jpg", 1)

; tool splash image
SplashImageOn ($title, @TempDir & "\picture.jpg", 300, 225, -1, -1, 1)
Sleep (3000)
SplashOff ()

FileDelete (@TempDir & "\picture.jpg")

; ----------------- tray menu label start -----------------

; play sound
SoundPlay (@ScriptDir & "\sound.wav", 1)

TraySetClick (16)

; about label
$name = TrayCreateItem ("About")

; help label
$webpage = TrayCreateItem ("homepage!")

; help label
$help = TrayCreateItem ("Help")

; hotkeys label
$hotkeys = TrayCreateItem ("Hotkeys")

; divider
TrayCreateItem ("")

; start label
$StartItem = TrayCreateItem ("Start")

; stop label
$StopItem = TrayCreateItem ("Stop")

; pause label
$PauseItem = TrayCreateItem ("Pause/Unpause    (Pause)")

; divider
TrayCreateItem ("")

; scan priority label
$scanpriority = TrayCreateMenu ("Scan Priority")
$normalpriority = TrayCreateItem ("Normal",$scanpriority , -1, 1)
$highpriority = TrayCreateItem ("High",$scanpriority , -1, 1)
TrayItemSetState($normalpriority, BitOR(TrayItemGetState($normalpriority), $TRAY_CHECKED))

; divider
TrayCreateItem ("")

; scan results label
$scanresults = TrayCreateMenu ("Scan Results")
$viewlog = TrayCreateItem ("View Log", $scanresults)
$deletelog = TrayCreateItem ("Delete Log", $scanresults)


; divider
TrayCreateItem ("")

; remove startup entry label
$addrun = TrayCreateItem ("Add To System Startup")

; remove startup entry label
$remrun = TrayCreateItem ("Remove From System Startup")

; divider
TrayCreateItem ("")

; exit label
$exit = TrayCreateItem ("Exit")

; show tray icon
TraySetState ()

; tool start tray tip
TrayTip ($title, "Right click to start...", 1, 1)

TraySetToolTip("software" & @CRLF & "Scan Not Started...")

; -------------------- tray menu label end -------------------

; ----------------- tray menu function start -----------------

; grey out menu option
AdlibEnable ("adlib1", 250)

func adlib1()
    If Not ProcessExists ("software.exe") Then
       
        TrayItemSetState ($StartItem, $GUI_ENABLE)
       
        TrayItemSetState ($StopItem, $GUI_DISABLE)
       
        TrayItemSetState ($PauseItem, $GUI_DISABLE)
       
       
       
    Else
       
        TrayItemSetState ($StartItem, $GUI_DISABLE)
       
        TrayItemSetState ($StopItem, $GUI_ENABLE)
       
        TrayItemSetState ($PauseItem, $GUI_ENABLE)
       
       
       
    EndIf
   
    If Not FileExists (@ScriptDir & "\results.log") Then
        TrayItemSetState ($scanresults, $GUI_DISABLE)
       
    Else
        TrayItemSetState ($scanresults, $GUI_ENABLE)
    EndIf
   
EndFunc


; begin loop
While 1

    $msg = TrayGetMsg ()
    Select
        Case $msg = 0
            BitAND(TrayItemGetState($normalpriority), $TRAY_CHECKED)

            ; ----- info label-----

            ; info msg box
        Case $msg = $name
            
            #region About Window Creation
            If Not $sStart Then
                $about = GuiCreate("software",270,300,-1,-1, BitOR($WS_CAPTION,$WS_SYSMENU))
                GUISetBkColor(0xFFFFFF)
                GUISetOnEvent ($GUI_EVENT_CLOSE, "AboutOK" )
                GUICtrlCreateIcon (@AutoItExe,-1,180,11)
                GUICtrlCreateLabel ("software",44,11,100,20)
                GUICtrlSetFont (-1,9.5, 800, 0, "Arial") ; bold
                GUICtrlCreateLabel ("©2007",44,30,100,40)
                GUICtrlCreateLabel ("Credits:" ,44,50,135,12)
                GUICtrlSetFont (-1,9.5, 800, 0, "Arial")

                GUICtrlCreateButton ("OK",95,250,75,23,BitOr($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))
                GUICtrlSetState (-1, $GUI_FOCUS)
                GUICtrlSetOnEvent(-1, "AboutOK")
                GUISetState(@SW_SHOW, $about)

                $child = GUICreate('', 180, 150, 43, 70, $WS_CHILD, $WS_EX_CLIENTEDGE, $about)
                GUISetBkColor(0xFFFFFF)
                $label = GUICtrlCreateLabel($sScrollText, 0, 5, 250, 510)
                GUICtrlSetFont(-1, 9.5)
                GUICtrlSetColor(-1, 0x000000)
                GUISetState()
                
                $iScrollPos = -5

                $sTime = TimerInit()
                $sScroll = 5
                $sFirstTime = 1
                $sStart = 1
            EndIf
            #endregion
   

            ; ----- webpage label-----

            ; webpage option
        Case $msg = $webpage
            If FileExists ("C:\Program Files\Mozilla Firefox\firefox.exe") Then
                Run (@ComSpec & ' /c start firefox.exe "http://website.com" ', "", @SW_HIDE)
            Else
                ShellExecute ("iexplore.exe", "http://website.com")
            EndIf
           
            ; ----- help label-----

            ; help option
        Case $msg = $help
            If FileExists ("C:\Program Files\Mozilla Firefox\firefox.exe") Then
                Run (@ComSpec & ' /c start firefox.exe "C:\Program Files\software\help.html" ', "", @SW_HIDE)
            Else
                ShellExecute ("iexplore.exe", @ScriptDir & "\help.html")
            EndIf

            ; ----- hotkey label-----

            ; hotkeys traytip
        Case $msg = $hotkeys
            MsgBox (64, "Keyboard Hotkeys", "You can press on your keyboard's 'Pause' key at any time to pause or unpause scanning." & @CRLF & "" & @CRLF & "Keyboard 'Pause' key = Pause/Unpause scanning")

            ; ----- start label-----

            ; start software option
        Case $msg = $StartItem
           
            ;start sound
                SoundPlay (@ScriptDir & "\sound.wav", 1)

            ; start software
                ShellExecute (@ScriptDir & "\software.exe")
               
                ; scan started traytip
                TrayTip ("Tool Status", "Scan Started", 1, 1)
               
                TraySetToolTip("software" & @CRLF & "Scan Started..." & @CRLF & "Priority: Normal")
           
            ; ----- stop label-----

            ; stop software option
        Case $msg = $StopItem

            ; stop sound
            SoundPlay (@ScriptDir & "\sound.wav", 1)

            ; stop software
            ProcessClose ("software.exe")

            ; scan stopped traytip
            TrayTip ("Tool Status", "Scan Stopped...", 1, 1)
           
            TraySetToolTip("software" & @CRLF & "Scan Not Started...")

            ; ----- pause label-----

            ; pause software option
        Case $msg = $PauseItem

            ; pause software sound
            SoundPlay (@ScriptDir & "\sound.wav", 1)

            ; pause software
            Send ("{PAUSE}")
           
            TraySetToolTip("software" & @CRLF & "Scan Paused...")

            ; ----- normal scan priority label-----
        Case $msg = $normalpriority
            TrayItemSetState($highpriority, $TRAY_UNCHECKED)
            TrayItemSetState($normalpriority, $TRAY_CHECKED)
           
            ProcessSetPriority ("software.exe", 2)
           
            ; normal priority scan traytip
            TrayTip ("Scan Priority", "Normal", 1, 1)
           
            TraySetToolTip("software" & @CRLF & "Scan Started..." & @CRLF & "Priority: Normal")
           
            ; ----- real time scan priority label-----
        Case $msg = $highpriority
            TrayItemSetState($normalpriority, $TRAY_UNCHECKED)
            TrayItemSetState($highpriority, $TRAY_CHECKED)
           
            ProcessSetPriority ("software.exe", 4)
           
            ; high priority scan traytip
            TrayTip ("Scan Priority", "High", 1, 1)
           
            TraySetToolTip("software" & @CRLF & "Scan Started..." & @CRLF & "Priority: High")
           
            ; ----- view log label-----
        Case $msg = $viewlog
           
            ; open results log
            ShellExecute (@ScriptDir & "\results.log" , 0)
           
            ; ----- delete log label-----
        Case $msg = $deletelog
           
            Dim $iMsgBoxAnswer
                $iMsgBoxAnswer = MsgBox(292,"Autorun Eater v1.0","Are you sure you want to delete the results log?")
               
                If $iMsgBoxAnswer = 7 Then
                    ContinueLoop
                   
                Else
                    FileDelete (@ScriptDir & "\results.log")
               
                    ; log deleted traytip
                    TrayTip ("Scan Results", "Results Log Deleted", 1, 1)
                EndIf
               
           
            ; ----- startup key label-----

            ; add startup entry option
        Case $msg = $addrun

            ; add startup entry sound
            SoundPlay (@ScriptDir & "\sound.wav", 1)

            ; add startup entry to registry
            RegWrite ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "software", "REG_SZ", @ScriptFullPath)

            ; ----- remove key label-----

            ; remove startup entry option
        Case $msg = $remrun

            ; remove startup entry sound
            SoundPlay (@ScriptDir & "\sound.wav", 1)

            ; remove startup entry from registry
            RegDelete ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "software")

            ; ----- exit label-----

        Case $msg = $exit
            ExitLoop

            ; ----------------- tray menu function end -----------------

            EnvUpdate ()
    EndSelect
    If $sStart AND (($sFirstTime AND TimerDiff($sTime) > 3000) OR (Not $sFirstTime AND TimerDiff($sTime) > 30)) Then
        $sFirstTime = 0
        $sTime = TimerInit()
        $iScrollPos += 1
        ControlMove($child, '', $label, 0, -$iScrollPos)
        If $iScrollPos > 360 Then $iScrollPos = -150
        sleep(50)
    EndIf
WEnd
; end of loop
 
; close software process
ProcessClose ("software.exe")

; tool exit sound sound
SoundPlay (@ScriptDir & "\sound.wav", 1)

Exit

Func AboutOK()
    GUIDelete($about)
    $sStart = 0
EndFunc

There you go!

Edited by Manadar

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  
Followers 0