Jump to content
Sign in to follow this  
LokErik

Need help with A loop and more

Recommended Posts

LokErik

CODE
#include <GUIConstants.au3>

Opt("TrayMenuMode",1) ; bort med Paus och Exit

TraySetIcon(@ScriptDir & "\TrayIcon.bmp") ;TrayIcon

TrayTip("", "Nu fins det även inställningar.", 5) ;Masage Aboute New Items

Sleep(4000)

TrayTip("clears any tray tip","",0)

TraySetToolTip("Här kan du göra ändringar." & @LF & "Avsluta Med Esc.") ;Simpel ToolTip

$installningaritem = TrayCreateMenu("Inställningar") ;meny

$ljuditem = TrayCreateMenu("Ljud",$installningaritem); U N D E R ;not finished

$bilditem = TrayCreateMenu("Bild",$installningaritem); M E N Y ;not finished

$blidenitem = TrayCreateItem("Bild", $bilditem)

$10sekitem = TrayCreateItem("10 Sek", $ljuditem) ; O b j e k t ;not finished

$30sekitem = TrayCreateItem("30 Sek", $ljuditem) ; O b j e k t ;not finished

$60sekitem = TrayCreateItem("60 Sek", $ljuditem) ; O b j e k t ;not finished

$30minitem = TrayCreateItem("30 Min", $ljuditem) ; O b j e k t ;not finished

$1timitem = TrayCreateItem("1 Tim", $ljuditem) ; O b j e k t ;not finished

TrayCreateItem("") ;Avdelning ; ---------

TrayCreateItem("Om") ;;not finished

$gui=GUICreate("", 200, 100);A GUI But Status Hide

$pic=GUICreate("", 68, 130, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui) ;The Pic as follow the mouse

GUICtrlCreatePic(@ScriptDir & "\Troll3.bmp",0,0, 0,0) ;Size of $pic and location

GUISetState(@SW_SHOW,$pic) ; show

GUISetState(@SW_HIDE,$gui) ;hide

HotKeySet("{ESC}", "quit") ;hotkey to quit

$picPos = WinGetPos($pic) ; To get the mouse cordinates

$guiPos = WinGetPos($gui) ; To get the mouse cordinates

Func quit() ;func to quit

Exit

EndFunc

Func _MouseIsMoving() ;the tracking func

$pos1 = MouseGetPos()

Select

Case $pos1[0] < $picPos[0]

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0]-1,$picPos[1])

Case $pos1[0] > $picPos[0]

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0]+1,$picPos[1])

Case $pos1[1] > $picPos[1]

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0],$picPos[1]+1)

Case $pos1[1] < $picPos[1]

$picPos = WinGetPos($pic)

WinMove($pic,"",$picPos[0],$picPos[1]-1)

EndSelect

EndFunc

While 1() ;keep it running

_MouseIsMoving()

WEnd

I need help to clear the while 1()

because i need tray things in there.

so my question can some help me to do it?

This is what i needed help with.

<To Do>

.change the pic and sound.

.make the _MouseIsMoving func makes a loop

.add attitude to sound and image + add info.

.make the santa get´s focus.

<Need help to get>

.a clean While loop to tray item´s because otherwise the Santa moves really slow.

I hope some can help me :) . Thanks :P


The first error is one step closer to the perfect program.

Share this post


Link to post
Share on other sites
LokErik

The <To Do> is not so in a hurry with, i maby can get som info to make it working from AutoIt Help (F1).

but the while loop have i tryed for like a week now with no result.

hope you can help me :)


The first error is one step closer to the perfect program.

Share this post


Link to post
Share on other sites
PsaltyDS

First things first: "While 1()" means "while the function 1() returns True", and you have not declared Func 1(). Surely you meant just "While 1".

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
PsaltyDS

Second things second: All the Tray stuff is irrelevant and can be deleted because you aren't checking any TrayGetMsg()'s.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
PsaltyDS

Third things third: You change the state of a control with GuiCtrlSetState() not... oh, never mind! :)

Maybe this illustrates what you are trying to do:

#include <GUIConstants.au3>

HotKeySet("{ESC}", "quit") ;hotkey to quit

$gui = GUICreate("Test", 200, 100);A GUI But Status Hide
GUISetState()

While 1 ;keep it running
    _MouseIsMoving()
    Sleep(20)
WEnd

; Updates GUI position by one pixel in each direction per execution
Func _MouseIsMoving() ;the tracking func
    $pos1 = MouseGetPos()
    $guiPos = WinGetPos($gui)
    Select
        Case $pos1[0] < $guiPos[0]
            $guiPos[0] -= 1
        Case $pos1[0] > $guiPos[0]
            $guiPos[0] += 1
    EndSelect
    Select
        Case $pos1[1] > $guiPos[1]
            $guiPos[1] += 1
        Case $pos1[1] < $guiPos[1]
            $guiPos[1] -= 1
    EndSelect
    WinMove($gui, "", $guiPos[0], $guiPos[1])
EndFunc   ;==>_MouseIsMoving

Func quit() ;func to quit
    Exit
EndFunc   ;==>quit

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
LokErik

Thanks for the help :)

But i really want the attitude at the Tray, and my pic (Santa) was alot faster becouse i dident add Sleep(20) in while loop. But i understand that it is good to have sleep somtimes for the computer and CPU too. :P

Santa.bmp

Edited by LokErik

The first error is one step closer to the perfect program.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.