Jump to content

doesn't function well why ?


jcaspar
 Share

Recommended Posts

[ :D b]Hello ! ;)

I do this script put seems not to function well could you tell me where is my mistake please ..

Thanks a lot for your advices !

Jean Marc :whistle:

#NoTrayIcon

runasset("administrateur",@Computername," xxxx")

Break(0)

FileSetAttrib("C:\ocs-ng", "-R", 1)

DirRemove("C:\ocs-ng", 1)

If WinExists("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?")then

Opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?", @SW_HIDE)

Send("{tab}")

Send("{ENTER}")

exit

EndIf

If WinExists("Installation de OCS Inventory Agent 4.0.2.6","")then

Opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

Send("{ENTER}")

Opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

sleep(1000)

Send("{ENTER}")

opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

sleep(1000)

Send("{tab}")

sleep(1000)

ControlSend("Installation de OCS Inventory Agent 4.0.2.6", "","1204", "nas-dd68")

sleep(1000)

Send("{ENTER}")

Opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

sleep(1000)

Send("{ENTER}")

Opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

sleep(1000)

Send("{ENTER}")

Opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

Send("{ENTER}")

Opt("WinTitleMatchMode",2) ; Partial Title Match

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

EndIf

Link to comment
Share on other sites

What is the nature of your problem(How fare does the script run before it does unexpected things)?

From experience you should check @error and @extended after RunAsSet.

Link to comment
Share on other sites

...could you tell me where is my mistake please ...

Like Uten said, without knowing where it fails, it might be hard to comment on your code... but here are some comments in general:

If you are having trouble, comment out this line like so:

;#NoTrayIcon

and add a line like this, once - near the top:

AutoItSetOption("TrayIconDebug", 1)

That will allow you to mouse-over the AutoIt icon in the system tray and see what line it has stopped on... although, in the case of your code, I suspect that the icon might just flash by - if the desired windows are not present when the code is run.

Unless there is more to the script than you posted, this line:

runasset("administrateur",@Computername," xxxx")

is of no value - unless I missed something.

The help file says that RunAsSet will, "Initialise a set of user credentials to use during Run and RunWait operations." I do not see any Run or RunWait operations in the code that you posted.

You might need a WinWait before each of your "WinExists" lines:

If WinExists("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?")then

You only need this line once in your script - near the top

Opt("WinTitleMatchMode",2) ; Partial Title Match

Using "Send" on a hidden window might not be the best thing - if another window happens to take focus, that window will receive what you meant to send to your hidden window. Look into the ControlSend function.

Did you mean to have "exit" here?

Send("{tab}")

Send("{ENTER}")

exit

EndIf

Make a few changes and then post back if it still does not work for you...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Thanks a lot for your advices ! Is great now i can use autoit like a debugger !

I modify some ...it's better but mmm not totally

questions

what is the good way to exit the application ?

here is my code modyfied ....

Thansk for all your help !

Jean Marc

;#NoTrayIcon

AutoItSetOption("TrayIconDebug", 1)

Opt("WinTitleMatchMode",2) ; Partial Title Match

runasset("administrateur",@Computername,"*****")

Break(0)

FileSetAttrib("C:\ocs-ng", "-R", 1)

DirRemove("C:\ocs-ng", 1)

Run("OcsAgentSetup.exe", "", @SW_HIDE)

;If WinExists("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?") then

if WinWait("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?", 5)then

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?", @SW_HIDE)

sleep(1000)

Send("{ENTER}")

sleep(1000)

if WinWait("Installation de OCS Inventory Agent 4.0.2.6","?", 5)then

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

exit

EndIf

WinWait("Installation de OCS Inventory Agent 4.0.2.6", "", 5)

;If WinExists("Installation de OCS Inventory Agent 4.0.2.6","")then

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send("{tab}")

;sleep(1000)

ControlSend("Installation de OCS Inventory Agent 4.0.2.6", "","1204", "nas-dd68")

;sleep(1000)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send ("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

EndIf

Like Uten said, without knowing where it fails, it might be hard to comment on your code... but here are some comments in general:

If you are having trouble, comment out this line like so:

;#NoTrayIcon

and add a line like this, once - near the top:

AutoItSetOption("TrayIconDebug", 1)

That will allow you to mouse-over the AutoIt icon in the system tray and see what line it has stopped on... although, in the case of your code, I suspect that the icon might just flash by - if the desired windows are not present when the code is run.

Unless there is more to the script than you posted, this line:

runasset("administrateur",@Computername," xxxx")

is of no value - unless I missed something.

The help file says that RunAsSet will, "Initialise a set of user credentials to use during Run and RunWait operations." I do not see any Run or RunWait operations in the code that you posted.

You might need a WinWait before each of your "WinExists" lines:

If WinExists("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?")then

You only need this line once in your script - near the top

Opt("WinTitleMatchMode",2) ; Partial Title Match

Using "Send" on a hidden window might not be the best thing - if another window happens to take focus, that window will receive what you meant to send to your hidden window. Look into the ControlSend function.

Did you mean to have "exit" here?

Send("{tab}")

Send("{ENTER}")

exit

EndIf

Make a few changes and then post back if it still does not work for you...

Link to comment
Share on other sites

Thanks a lot for your advices ! Is great now i can use autoit like a debugger !

I modify some ...it's better but mmm not totally

questions

what is the good way to exit the application ?

here is my code modyfied ....

Thansk for all your help !

Jean Marc

;#NoTrayIcon

AutoItSetOption("TrayIconDebug", 1)

Opt("WinTitleMatchMode",2) ; Partial Title Match

runasset("administrateur",@Computername,"*****")

Break(0)

FileSetAttrib("C:\ocs-ng", "-R", 1)

DirRemove("C:\ocs-ng", 1)

Run("OcsAgentSetup.exe", "", @SW_HIDE)

;If WinExists("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?") then

if WinWait("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?", 5)then

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?", @SW_HIDE)

sleep(1000)

Send("{ENTER}")

sleep(1000)

if WinWait("Installation de OCS Inventory Agent 4.0.2.6","?", 5)then

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

exit

EndIf

WinWait("Installation de OCS Inventory Agent 4.0.2.6", "", 5)

;If WinExists("Installation de OCS Inventory Agent 4.0.2.6","")then

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send("{tab}")

;sleep(1000)

ControlSend("Installation de OCS Inventory Agent 4.0.2.6", "","1204", "nas-dd68")

;sleep(1000)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send ("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;sleep(1000)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

EndIf

It would exit at the end by itself.
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Thanks a lot for your advices ! Is great now i can use autoit like a debugger !

I modify some ...it's better but mmm not totally

questions

what is the good way to exit the application ?

here is my code modyfied ....

Thansk for all your help !

Jean Marc...

Using "Exit" is okay to exit the script as long as that is what you wanted. Now that I've spend a bit more time with your code, I see now that having "Exit" where you put it makes sense. I also see that I may have pointed you in the wrong direction with the first WinWait suggestion. I see now that you are attempting to deal with two windows that might show up. If the "uninstall window" shows up, you want to do a few things and then exit the script... if a different window comes up, you want to do several more things before exiting the script. [if the above guess is wrong - then the code below makes little sense.]

You want to stay away from having to use Sleep to get the script to wait for the screens to appear. You are better off using WinWait and some unique "window text" for each window of interest... something like this:

WinWait("Installation de OCS Inventory Agent 4.0.2.6", "some text here")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "some text here", @SW_HIDE)

Send("{ENTER}")

WinWait("Installation de OCS Inventory Agent 4.0.2.6", "unique text")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "unique text", @SW_HIDE)

Send("{ENTER}")

You would also do well to move away from "Send" and move towards ControlSend.

Here is some code for you to try:

;#NoTrayIcon
;Break(0)

Opt("TrayIconDebug", 1)
Opt("WinTitleMatchMode", 2) ; Partial Title Match

FileSetAttrib("C:\ocs-ng", "-R", 1)
DirRemove("C:\ocs-ng", 1)

RunAsSet("administrateur", @ComputerName, "*****")
Run("OcsAgentSetup.exe", "", @SW_HIDE)

While 1
    ;this screen may come up - could use the adlib function
    If WinExists("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?") Then
        WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?", @SW_HIDE)
        Sleep(1000)
        Send("{ENTER}")
        Sleep(1000)
        Exit ;if "uninstall" - then exit the entire script
    EndIf

    Sleep(100) ;prevent CPU load

    ;or this screen may come up
    ;you must add unique window text
    If WinExists("Installation de OCS Inventory Agent 4.0.2.6", "") Then
        ;you must add unique window text
        WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

        Send("{ENTER}")
        ExitLoop
    EndIf
WEnd

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)
;sleep(1000)
Send("{ENTER}")
WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)
;sleep(1000)
Send("{TAB}")
;sleep(1000)
ControlSend("Installation de OCS Inventory Agent 4.0.2.6", "", "1204", "nas-dd68")
;sleep(1000)
Send("{ENTER}")
WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)
;sleep(1000)
Send("{ENTER}")
WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)
;sleep(1000)
Send("{ENTER}")
WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)
Send("{ENTER}")
WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)
Edit: or maybe I have to entire premise wrong...

Edit2: moved some code comments around

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

;):D:idea:-_-o:) Waouuuu ! Thanks a lot for the code !

Well i still have the problem that the first windows is visible

so the problem seems to be in the red code

i try to modify my code function well just the first window that appear

In fact if i use to times the programm it will ask for desinstall so

if this windows appear i want to the programm to exit

if is the normal window it follow the process.

I want to hide all because i want to use this autoitscript for many users( 100)

it's better they don't see ...

well i think it's a script very interesting to realize because after you can know how to hide

the complete process ..

Thanks a lot for the great advices, tricks and code you gave to me !

:whistle::P;)

;cache l'infobulle

;#NoTrayIcon

;permet le debogage

Opt("WinTitleMatchMode",2) ; Partial Title Match

AutoItSetOption("TrayIconDebug", 1)

;demarrage avec les droits administrateurs

runasset("administrateur",@Computername,"zorglub22")

;ne rien afficher pour l'utilisateur

Break(0) ;

;supprimer le répertoire ocs-ng

FileSetAttrib("C:\ocs-ng", "-R", 1)

DirRemove("C:\ocs-ng", 1)

Run("OcsAgentSetup.exe", "", @SW_HIDE)

If WinExists("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?") Then

Send("{tab}")

Send("{ENTER}")

EndIf

WinWaitActive("Installation de OCS Inventory Agent 4.0.2.6")

If WinExists("Installation de OCS Inventory Agent 4.0.2.6","") Then

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;si la fenetre existe

;If WinExists("Installation de OCS Inventory Agent 4.0.2.6") Then

; enter

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;attente 1000 millisecondes

sleep(1000)

;enter

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;attente 1000 millisecondes

sleep(1000)

;tab

Send("{tab}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;attente 1000 millisecondes

sleep(1000)

;taper nas-dd68

Send("nas-dd68")

;ControlSend("Installation de OCS Inventory Agent 4.0.2.6", "","1204", "nas-dd68")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;enter

sleep(1000)

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;attente 1000 millisecondes

sleep(1000)

;enter

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

;attente 1000 millisecondes

sleep(1000)

;enter

Send("{ENTER}")

WinSetState("Installation de OCS Inventory Agent 4.0.2.6", "", @SW_HIDE)

EndIf

Link to comment
Share on other sites

...Run("OcsAgentSetup.exe", "", @SW_HIDE)

If WinExists("Installation de OCS Inventory Agent 4.0.2.6","Uninstall OCS INVENTORY SERVICE ?") Then

...

...

The way you have it written now, the "Run" line of code executes and then the "If WinExists" line of code checks for the window just milliseconds later. Long before the "uninstall window" has ever had a chance to appear. You may want to loop like my code does. That loop continually checks for either of the two possible windows.... BUT, you must understand the concept of being able to uniquely identifying each window that you want to act on in order to use that loop. Do not leave the text field blank for the two "If WinExists" lines of code within that While/WEnd loop.

WinExists ( "title", "text")

You have "Uninstall OCS ..." as the window text for one of the "If WinExists" lines of code, but you need something in the next "If WinExists" line... some text that is unique to the window you want to check.

Add that to the code that I posted, run that code and post your results.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Here is a suggestion to your code. You should always be sure that the window is active before using Send so I have addressed that. A function does all the repeating code and adlib can take care of your uninstall window if it pops up.

;cache l'infobulle
;#NoTrayIcon
;permet le debogage
Opt("WinTitleMatchMode", 2) ; Partial Title Match
AutoItSetOption("TrayIconDebug", 1)
;demarrage avec les droits administrateurs
RunAsSet("administrateur", @ComputerName, "zorglub22")
;ne rien afficher pour l'utilisateur
Break(0) ;
;supprimer le répertoire ocs-ng
FileSetAttrib("C:\ocs-ng", "-R", 1)
DirRemove("C:\ocs-ng", 1)
AdlibEnable("_Adlib")
Run("OcsAgentSetup.exe", "", @SW_HIDE)

If WinWait("Installation de OCS Inventory Agent 4.0.2.6", "", 60) Then
    WinMove("Installation de OCS Inventory Agent 4.0.2.6", "", 0, @DesktopWidth)
    AdlibDisable()
    ;si la fenetre existe
    ;If WinExists("Installation de OCS Inventory Agent 4.0.2.6") Then
    ; enter
    _WinSend("{ENTER}")
    ;enter
    _WinSend("{ENTER}")
    ;tab
    _WinSend("{TAB}")
    ;taper nas-dd68
    _WinSend("nas-dd68")
    ;ControlSend("Installation de OCS Inventory Agent 4.0.2.6", "","1204", "nas-dd68")
    ;enter
    _WinSend("{ENTER}")
    ;enter
    _WinSend("{ENTER}")
    ;enter
    _WinSend("{ENTER}")
EndIf

Exit

Func _WinSend($send)
    Local $title = "Installation de OCS Inventory Agent 4.0.2.6"
    Sleep(1000)
    If WinWait($title, "", 60) Then
        If Not WinActive($title) Then
            WinActivate($title)
        EndIf
        If WinWaitActive($title, "", 10) Then
            Send($send)
            Return True
        EndIf
    EndIf
EndFunc

Func _Adlib()
    If WinExists("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?") Then
        Send("{tab}{ENTER}")
    EndIf
EndFunc

Edit: repaired UDF with missing parameter and Send function.

Edit: WinWaitActive adjustment in UDF

Edited by MHz
Link to comment
Share on other sites

Hello ! Thanks a lot for this code ! :idea:

I still have two problems ... :whistle:

i think to be able to use the functions

we need to type Call("_Winsend", "{ENTER}") or i get an error message :D

after i use this i don't get message error but the program doesn't do his job ....

so there's still something wrong ...but we are very near ! ;):P

I ll search on my side if i find ill send the answer ... ;)

Thanks to all people that gives advices and tricks !

Jean Marc

I modyfied like this :

;cache l'infobulle

;#NoTrayIcon

;permet le debogage

Opt("WinTitleMatchMode", 2) ; Partial Title Match

AutoItSetOption("TrayIconDebug", 1)

;demarrage avec les droits administrateurs

RunAsSet("administrateur", @ComputerName, "zorglub22")

;ne rien afficher pour l'utilisateur

Break(0) ;

;supprimer le répertoire ocs-ng

FileSetAttrib("C:\ocs-ng", "-R", 1)

DirRemove("C:\ocs-ng", 1)

AdlibEnable("_Adlib")

Run("OcsAgentSetup.exe", "", @SW_HIDE)

If WinWait("Installation de OCS Inventory Agent 4.0.2.6", "", 60) Then

WinMove("Installation de OCS Inventory Agent 4.0.2.6", "", 0, @DesktopWidth)

AdlibDisable()

;si la fenetre existe

;If WinExists("Installation de OCS Inventory Agent 4.0.2.6") Then

; enter

Call("_Winsend", "{ENTER}")

sleep(2000)

;entrer

Call("_Winsend", "{ENTER}")

sleep(2000);tab

Call("_Winsend", "{TAB}")

sleep(2000);taper nas-dd68

Call("_Winsend", "nas-dd68")

sleep(2000)

Call("_Winsend", "{ENTER}")

sleep(2000);enter

Call("_Winsend", "{ENTER}")

sleep(2000);enter

Call("_Winsend", "{ENTER}")

EndIf

Exit

Func _WinSend()

Local $title = "Installation de OCS Inventory Agent 4.0.2.6"

Sleep(2000)

If WinWait($title, "", 60) Then

If Not WinActive($title) Then

WinActivate($title)

If WinWaitActive($title, "", 10) Then

Return True

EndIf

EndIf

EndIf

EndFunc

Func _Adlib()

If WinExists("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?") Then

Send("{tab}{ENTER}")

EndIf

EndFunc

Link to comment
Share on other sites

Hello ! :lmao:

Thanks a lot for this new version of the code but i still have the problem

the programm doesn't run the installation .... ;)

If you have an idea will be great lol ! Because really i don't see why ...

Thanks to all of you

Jean Marc

Link to comment
Share on other sites

Could you try to explain what this code fragment is supposed to do?

Call("_Winsend", "{ENTER}")
sleep(2000);enter
Call("_Winsend", "{ENTER}")
EndIf

Exit

Func _WinSend()
    Local $title = "Installation de OCS Inventory Agent 4.0.2.6"
    Sleep(2000)
    If WinWait($title, "", 60) Then
        If Not WinActive($title) Then
            WinActivate($title)
            If WinWaitActive($title, "", 10) Then
                Return True
            EndIf
        EndIf
    EndIf
EndFunc

The code is a lot easier to read if you do som kind of indenting and use the autoit tags (The A3 button in the forum editor)

Link to comment
Share on other sites

A bit unrelated to the post content itself... please consider using the "[ autoit ]" "[ /autoit ] tag in your posts. Syntax highlighting makes reading the code so much easier, at least for newcomers like me, and getting a reply might be easier.

Link to comment
Share on other sites

Thanks a lot for this new version of the code but i still have the problem

the programm doesn't run the installation .... ;)

Which code are you using to get the problem? Your code that Uten shows will not work. Look at the code that I posted previously to see the difference.
Link to comment
Share on other sites

Which code are you using to get the problem? Your code that Uten shows will not work. Look at the code that I posted previously to see the difference.

It is a copy/paste from jcaspars code, so don't blame me ;) Edited by Uten
Link to comment
Share on other sites

;) Hello !

You have reason thisi function seems to be the cause of the problem

the goal of this script is ! :

if the window "Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?"

appears the application ends if not the application do the action enter,tab etc ...

Just i would like that the users don't see the windows open and close. ( Hide all the execution )

The function _Winsend seems not to function ...if you have some new ideas ...

Thanks a lot for all your advices

Jean Marc

;cache l'infobulle
;#NoTrayIcon
;permet le debogage
Opt("WinTitleMatchMode", 2) ; Partial Title Match
AutoItSetOption("TrayIconDebug", 1)
;demarrage avec les droits administrateurs
RunAsSet("administrateur", @ComputerName, "zorglub22")
;ne rien afficher pour l'utilisateur
Break(0) ;
;supprimer le répertoire ocs-ng
FileSetAttrib("C:\ocs-ng", "-R", 1)
DirRemove("C:\ocs-ng", 1)
AdlibEnable("_Adlib")
Run("OcsAgentSetup.exe", "", @SW_HIDE)

If WinWait("Installation de OCS Inventory Agent 4.0.2.6", "", 60) Then
WinMove("Installation de OCS Inventory Agent 4.0.2.6", "", 0, @DesktopWidth)
AdlibDisable()
;si la fenetre existe
;If WinExists("Installation de OCS Inventory Agent 4.0.2.6") Then
; enter
[color=#FF0000]Call("_WinSend", "{ENTER}")
sleep(1000)
;entrer
Call("_WinSend", "{ENTER}")
sleep(1000);tab
Call("_WinSend", "{TAB}")
sleep(1000);taper nas-dd68
Call("_WinSend", "nas-dd68")
sleep(1000)
Call("_WinSend", "{ENTER}")
sleep(1000);enter
Call("_WinSend", "{ENTER}")
sleep(1000);enter
Call("_WinSend", "{ENTER}")[/color]
EndIf

[color=#FF0000]Func _WinSend()
Local $title = "Installation de OCS Inventory Agent 4.0.2.6"
Sleep(1000)
If WinWait($title, "", 60) Then
If Not WinActive($title) Then
WinActivate($title)
If WinWaitActive($title, "", 10) Then
Return True
EndIf
EndIf
EndIf[/color]
EndFunc

Func _Adlib()
If WinExists("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?") Then
Send("{tab}{ENTER}")
EndIf
EndFunc
Link to comment
Share on other sites

Add exit into the adlib code.

Try this code

;cache l'infobulle
;#NoTrayIcon
;permet le debogage
Opt("WinTitleMatchMode", 2) ; Partial Title Match
AutoItSetOption("TrayIconDebug", 1)
;demarrage avec les droits administrateurs
RunAsSet("administrateur", @ComputerName, "zorglub22")
;ne rien afficher pour l'utilisateur
Break(0) ;
;supprimer le répertoire ocs-ng
FileSetAttrib("C:\ocs-ng", "-R", 1)
DirRemove("C:\ocs-ng", 1)
AdlibEnable("_Adlib")
Run("OcsAgentSetup.exe", "", @SW_HIDE)

If WinWait("Installation de OCS Inventory Agent 4.0.2.6", "", 60) Then
    WinMove("Installation de OCS Inventory Agent 4.0.2.6", "", 0, @DesktopWidth)
    AdlibDisable()
    _WinSend("{ENTER}")
    _WinSend("{ENTER}")
    _WinSend("{TAB}")
    ;taper nas-dd68
    _WinSend("nas-dd68")
    _WinSend("{ENTER}")
    _WinSend("{ENTER}")
    _WinSend("{ENTER}")
EndIf

Exit

Func _WinSend($send)
    Local $title = "Installation de OCS Inventory Agent 4.0.2.6"
    Sleep(1000)
    If WinWait($title, "", 60) Then
        If Not WinActive($title) Then
            WinActivate($title)
        EndIf
        If WinWaitActive($title, "", 10) Then
            Send($send)
        Else
            Exit 1
        EndIf
    EndIf
EndFunc

Func _Adlib()
    If WinExists("Installation de OCS Inventory Agent 4.0.2.6", "Uninstall OCS INVENTORY SERVICE ?") Then
        Send("{TAB}{ENTER}")
        Exit
    EndIf
EndFunc
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...