Jump to content
Sign in to follow this  
jinyue115

Till now , nobody can fix this issue ! U want try?

Recommended Posts

jinyue115

use this script #### shellexecute("c:\asdf")##### a windows will pop after run this script , the question is: can u close the popup windows with this 'shellexecute("c:\asdf")' in one script ? u clear?

eg.

$a=ShellExecute("d:\aaa")

If $a=0 Then Exit

WinWaitActive("aaa");wait and active the window "aaa"

If WinExists("aaa") Then

Send("{enter}");send ENTER to click that OK button

Else

MsgBox(48,"2","sorry",2)

EndIf

or any other scripts you can try !

Thank you very much for your reading .

Share this post


Link to post
Share on other sites
PsaltyDS

You'll find people on this forum quite helpful without the childish language of the dare. :blink:

An AutoIt script can't click on it's own MsgBox() because that's a "blocking" function. It can, however, spawn a child process that will take care of it. The important thing is for the child process to be aware of it's role so you don't just get many copies of the parent, all blocked.

You can do this either with _Singleton():

#include <Misc.au3>

If _Singleton("Global\ClickMyOwnMsgBoxTest", 1) Then
    Run(@ScriptFullPath)
    MsgBox(64, "Message Box", "This box will be closed by the second instance in five seconds...")
Else
    WinWait("[CLASS:#32770;TITLE:Message Box]", "")
    Sleep(5000)
    ControlClick("[CLASS:#32770;TITLE:Message Box]", "", "[CLASS:Button; INSTANCE:1]")
EndIf

...or by a command line switch:

#include <Misc.au3>

If $CmdLine[0] And $CmdLine[1] = "/ClickIt" Then
    WinWait("[CLASS:#32770;TITLE:Message Box]", "")
    Sleep(5000)
    ControlClick("[CLASS:#32770;TITLE:Message Box]", "", "[CLASS:Button; INSTANCE:1]")
Else
    Run(@ScriptFullPath & " /ClickIt")
    MsgBox(64, "Message Box", "This box will be closed by the second instance in five seconds...")
EndIf

;)

Edit: Typo.

Edited by PsaltyDS

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
jinyue115

How foolish i am !!!

Global $Path="d:\aa"

$dll = DllOpen("user32.dll")

$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")

$TimerDLL = DllCall($dll, "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 100, "ptr", DllCallbackGetPtr($Timer))

ShellExecute($Path)

;Exit

;~ While 1

;~ Sleep(100)

;~ WEnd

Func quit()

DllCall($dll, "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)

DllCallbackFree($Timer)

DllClose($dll)

Exit

EndFunc

Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)

If WinExists($Path) Then ControlClick($Path,"","Button1","left",1)

EndFunc

Share this post


Link to post
Share on other sites
PsaltyDS

Yes, that's another method, which is also wrapped up already in _Timer_SetTimer() (see help file).

Handling MsgBox() with your version:

$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 5000, "ptr", DllCallbackGetPtr($Timer))

MsgBox(64, "Message Box", "This box will be closed by the second instance in five seconds...")

DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
DllCallbackFree($Timer)

Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
    ConsoleWrite("_Timer()" & @LF)
    ControlClick("[CLASS:#32770;TITLE:Message Box]", "", "[CLASS:Button; INSTANCE:1]")
EndFunc   ;==>Timer

(Note: It doesn't save any time to DllOpen() a DLL like user32.dll which Windows always has in memory already anyway.)

Using the _Timer_SetTimer() UDF:

#Include <Timers.au3>

$idTimer = _Timer_SetTimer(0, 5000, "Timer")

MsgBox(64, "Message Box", "This box will be closed by the second instance in five seconds...")

_Timer_KillTimer(0, $idTimer)

Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
    ConsoleWrite("_Timer()" & @LF)
    ControlClick("[CLASS:#32770;TITLE:Message Box]", "", "[CLASS:Button; INSTANCE:1]")
EndFunc   ;==>Timer

:blink:

Edit: Added demos.

Edited by PsaltyDS

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
jinyue115

Yes, that's another method, which is also wrapped up already in _Timer_SetTimer() (see help file).

Handling MsgBox() with your version:

$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 5000, "ptr", DllCallbackGetPtr($Timer))

MsgBox(64, "Message Box", "This box will be closed by the second instance in five seconds...")

DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
DllCallbackFree($Timer)

Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
    ConsoleWrite("_Timer()" & @LF)
    ControlClick("[CLASS:#32770;TITLE:Message Box]", "", "[CLASS:Button; INSTANCE:1]")
EndFunc   ;==>Timer

(Note: It doesn't save any time to DllOpen() a DLL like user32.dll which Windows always has in memory already anyway.)

Using the _Timer_SetTimer() UDF:

#Include <Timers.au3>

$idTimer = _Timer_SetTimer(0, 5000, "Timer")

MsgBox(64, "Message Box", "This box will be closed by the second instance in five seconds...")

_Timer_KillTimer(0, $idTimer)

Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
    ConsoleWrite("_Timer()" & @LF)
    ControlClick("[CLASS:#32770;TITLE:Message Box]", "", "[CLASS:Button; INSTANCE:1]")
EndFunc   ;==>Timer

:blink:

Edit: Added demos.

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.