Jump to content

While problems


Recommended Posts

Hello,

I have got while problems!

My while script is too long, and for this reason must I select it several times to make it work :S :whistle:

How can I make my while faster??

I have got made this program:

(snip)

$filemenu = GUICtrlCreateMenu ("&All of my Program`s")


$proga = GUICtrlCreateMenu ("a",$filemenu,1)

$A43        =GUICtrlCreateMenuItem("A43",$proga)
$aofpr      =GUICtrlCreateMenuItem("Accent Office Password Recovery",$proga)

etc....

$progg = GUICtrlCreateMenu ("g",$filemenu,1)
etc.
$progf = GUICtrlCreateMenu ("f",$filemenu,1)
etc.
$proge = GUICtrlCreateMenu ("e",$filemenu,1)
etc.
$progd = GUICtrlCreateMenu ("d",$filemenu,1)
etc.
$progc = GUICtrlCreateMenu ("c",$filemenu,1)
etc.
$progb = GUICtrlCreateMenu ("b",$filemenu,1)
etc.





While 1

    $msg = GUIGetMsg()

 
    If $msg = $A43 Then 
    ShellExecute(@ScriptDir & "\program`s\A\A43\A43.exe")

    ElseIf $msg = $aofpr Then
    ShellExecute(@ScriptDir & "\program`s\A\Accent Office Password Recovery\aofpr.exe")

etc...

Wend

I won't give al my programs for this reason have I set two programs but I have approximately 200 programs. and if I do al that programs in the wile must I select the program that I want to open several times.

can I some help, please?? :lmao:

Link to comment
Share on other sites

i don't exactly understand the problem, but i think you want to make the While loop faster. this example you gave us is working fine but you can make the loop smaller like this

While 1
     If $msg = $A43 Then 
         _functionprog1()
     ElseIf $msg = $aofpr Then
         _functionprog2()
     EndIf
WEnd

Func _functionprog1()
   ShellExecute(@ScriptDir & "\program`s\A\A43\A43.exe")
EndFunc

Func _functionprog2()
   ShellExecute(@ScriptDir & "\program`s\A\Accent Office Password Recovery\aofpr.exe")
EndFunc

but if you do this your script will be become bigger

Edited by mrbond007
Link to comment
Share on other sites

You're best solution is to learn to use Opt("GuiOnEventMode", 1) to get away from message loops all together. That leaves the script to handle the real work in the main loop, and only be interrupted if a GUI action actually occurs.

If you MUST have a message loop, my preferred form is:

While 1
    Switch GUIGetMsg()
        Case $A43
            ShellExecute(...)
        Case $aofpr
            ShellExecute(...)
    EndSwitch
WEnd

But that's just preference. Better performance is going to require a switch to event mode.

:whistle:

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
Link to comment
Share on other sites

I like how PsaltyDS thinks on this issue.

Example:

#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)

GUICreate('')
; Ctrl events
$menu = GUICtrlCreateMenu('&Menu')
GUICtrlCreateMenuItem('A43', $menu)
GUICtrlSetOnEvent(Default, '_A43')
GUICtrlCreateMenuItem('Accent Office Password Recovery', $menu)
GUICtrlSetOnEvent(Default, '_Accent_Office_Password_Recovery')
GUISetState()
; Gui events
GUISetOnEvent($GUI_EVENT_CLOSE, '_EndScript')

While 1
    Sleep(1000)
WEnd

Func _EndScript()
    Exit
EndFunc

Func _A43()
    MsgBox(0x40000, '', 'A43')
EndFunc

Func _Accent_Office_Password_Recovery()
    MsgBox(0x40000, '', 'Accent Office Password Recovery')
EndFunc

No more message loop slow down.

:whistle:

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