Jump to content
Sign in to follow this  
ShadowElf

Lost control after _IECreateEmbedded

Recommended Posts

ShadowElf

Func excelfurnizori()
$IE2 = _IECreateEmbedded()
$Formdebloc2 = GUICreate("Lista furnizoricc", @DesktopWidth-100, @DesktopHeight-100, -1, -1)
$GUIActiveX2 = GUICtrlCreateObj( $IE2, 1, 1, @DesktopWidth-102, @DesktopHeight-200)
$urlll2=$urlll&"&&export=1"
_IENavigate($IE2, $urlll2)
GUISetState(@SW_HIDE)
sleep(5000)
GUIDelete($Formdebloc2)
EndFunc

the php url contain:

$filename ="excelreport.xls";

header('Content-type: application/ms-excel');

header('Content-Disposition: attachment; filename='.$filename);

and then a table

when I start this function, it ask me to save excelreport.xls,

but after that I lost controll of all the aplication, no butoon work, no close.. etc

any sugestion?


I like IT: php, mysql, codeingiter, css, jquery and AUTOIT

Share this post


Link to post
Share on other sites
PsaltyDS

Your _IENavigate() is blocking, so set $f_wait = False in the function if you want the script to continue, but you don't have anything after that to deal with the popup either.

:mellow:


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
ShadowElf

this function is executed when press a button. when i press the button, i lost control of all aplication


I like IT: php, mysql, codeingiter, css, jquery and AUTOIT

Share this post


Link to post
Share on other sites
PsaltyDS

Well, it is a security dialog, so you might have to Run() a separate process to handle it. Add a command line check to the beginning of the script, so it can run a second instance of itself with a command line switch that tells it just to handle the security dialog and exit. So you would have something like this near the start of the script:

; Test command line
If ($CmdLine[0] = 2) And ($CmdLine[1] = "\IeFileSave") Then
    $iPPID = Int(StringTrimLeft($CmdLine[2], 6)) ; Get \PPID:n parameter
    While ProcessExists($iPPID) ; Terminate if parent does
        If WinExists("[CLASS:Your_Class; TITLE:Your File Save Title]", "") Then
            $hWin = WinGetHandle("[CLASS:Your_Class; TITLE:Your File Save Title]", "") ; Get dialog handle
            ControlSend($hWin, "", "", "{ENTER}") ; Send 'OK'
            ExitLoop
        EndIf
        Sleep(100)
    WEnd
    Exit
EndIf

Then whenever you navigate to something with a blocking file save dialog:

Run(@ScriptFullPath & " \IeFileSave \PPID:" & @AutoItPID)
_IENavigate($IE2, $urlll2)

:mellow:


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
ShadowElf

I posted a bigger part of the code, pls help.

I don't understannd the help from PsaltyDS (sorry)

Func genereazalistafurnizori is apelated from a file menu

Func genereazalistafurnizori()
Global $Formlistafurnizori,$ffnume,$ffro,$ffj,$fflocalitate,$ffadresa,$ffjudet,$ffcapsoc1,$ffcapsoc2,$ffpunctlucru,$ffperscontact,$fftel
Global $fffax,$ffmail,$ffurl,$ffbanca1,$ffbanca2,$ffbanca3,$afnume,$afro,$afj,$aflocalitate,$afadresa,$afjudet,$afcapsocial,$afpunctlucru
Global $afperscontact,$aftelefon,$aftelefon,$affax,$afmail,$afurl,$afcont1,$afcont2,$afcont3,$afbanca1,$afbanca2,$afbanca3, $ffexclusiv
$Formlistafurnizori = GUICreate("Generare lista furnizori", 686, 470, 195, 140)
$Group1 = GUICtrlCreateGroup("Filtre", 16, 24, 649, 201)
GUICtrlCreateLabel("Nume:", 32, 48, 35, 17)
$ffnume = GUICtrlCreateInput("", 115, 44, 121, 21)
GUICtrlCreateLabel("Cod Fiscal (RO):", 32, 72, 81, 17)
$ffro = GUICtrlCreateInput("", 115, 68, 121, 21)
GUICtrlCreateLabel("Numar Inreg (J):", 32, 96, 79, 17)
$ffj = GUICtrlCreateInput("", 115, 92, 121, 21)
GUICtrlCreateLabel("Localitate:", 33, 121, 53, 17)
$fflocalitate = GUICtrlCreateInput("", 115, 115, 121, 21)
GUICtrlCreateLabel("Adresa:", 33, 145, 40, 17)
$ffadresa = GUICtrlCreateInput("", 115, 139, 121, 21)
GUICtrlCreateLabel("Judet:", 32, 168, 33, 17)
$ffjudet = GUICtrlCreateInput("", 115, 163, 121, 21)
GUICtrlCreateLabel("Cap Social:", 32, 192, 58, 17)
$ffcapsoc1 = GUICtrlCreateInput("", 139, 188, 41, 21)
$ffcapsoc2 = GUICtrlCreateInput("", 195, 188, 41, 21)
GUICtrlCreateLabel("intre:", 109, 192, 27, 17)
GUICtrlCreateLabel("si", 183, 191, 11, 17)
GUICtrlCreateLabel("Punct Lucru:", 263, 47, 65, 17)
$ffpunctlucru = GUICtrlCreateInput("", 336, 43, 121, 21)
GUICtrlCreateLabel("Pers Contact:", 264, 71, 68, 17)
$ffperscontact = GUICtrlCreateInput("", 336, 67, 121, 21)
GUICtrlCreateLabel("Telefon:", 263, 96, 43, 17)
$fftel = GUICtrlCreateInput("", 336, 91, 121, 21)
GUICtrlCreateLabel("Fax:", 264, 120, 24, 17)
$fffax = GUICtrlCreateInput("", 336, 114, 121, 21)
GUICtrlCreateLabel("Mail:", 264, 144, 26, 17)
$ffmail = GUICtrlCreateInput("", 336, 138, 121, 21)
GUICtrlCreateLabel("URL:", 265, 167, 29, 17)
$ffurl = GUICtrlCreateInput("", 336, 162, 121, 21)
GUICtrlCreateLabel("Banca1:", 480, 49, 44, 17)
$ffbanca1 = GUICtrlCreateInput("", 528, 44, 121, 21)
GUICtrlCreateLabel("Banca2:", 480, 72, 44, 17)
$ffbanca2 = GUICtrlCreateInput("", 528, 67, 121, 21)
GUICtrlCreateLabel("Banca3:", 480, 96, 44, 17)
$ffbanca3 = GUICtrlCreateInput("", 528, 90, 121, 21)
$ffexclusiv = GUICtrlCreateCheckbox("Toate filtrele/Oricare dintre ele", 480, 192, 160, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Ce afisez", 16, 240, 649, 177)
$afnume = GUICtrlCreateCheckbox("Nume", 32, 264, 97, 17)
GUICtrlSetState($afnume, $GUI_CHECKED)
$afro = GUICtrlCreateCheckbox("Cod Fiscal (RO)", 32, 288, 97, 17)
$afj = GUICtrlCreateCheckbox("Numar Inreg (J)", 32, 312, 97, 17)
GUICtrlSetState($afnume, $GUI_CHECKED)
$aflocalitate = GUICtrlCreateCheckbox("Localitatea", 32, 336, 97, 17)
$afadresa = GUICtrlCreateCheckbox("Adresa", 32, 360, 97, 17)
$afjudet = GUICtrlCreateCheckbox("Judet", 32, 384, 97, 17)
$afcapsocial = GUICtrlCreateCheckbox("Cap Social", 160, 264, 97, 17)
$afpunctlucru = GUICtrlCreateCheckbox("Punct lucru", 160, 288, 97, 17)
$afperscontact = GUICtrlCreateCheckbox("Pers Contact", 160, 312, 97, 17)
$aftelefon = GUICtrlCreateCheckbox("Telefon", 160, 336, 97, 17)
$affax = GUICtrlCreateCheckbox("Fax", 160, 360, 97, 17)
$afmail = GUICtrlCreateCheckbox("Mail", 160, 384, 97, 17)
$afurl = GUICtrlCreateCheckbox("URL", 280, 264, 97, 17)
$afcont1 = GUICtrlCreateCheckbox("Cont1", 400, 264, 97, 17)
$afbanca1 = GUICtrlCreateCheckbox("Banca1", 400, 288, 97, 17)
$afcont2 = GUICtrlCreateCheckbox("Cont2", 400, 312, 97, 17)
$afbanca2 = GUICtrlCreateCheckbox("Banca2", 400, 336, 97, 17)
$afcont3 = GUICtrlCreateCheckbox("Cont3", 400, 360, 97, 17)
$afbanca3 = GUICtrlCreateCheckbox("Banca3", 400, 382, 97, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Genereaza lista", 265, 425, 139, 33)
GUICtrlSetOnEvent(-1, "listafurnizori")
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "outgenereazalistafurnizori")
EndFunc
Func outgenereazalistafurnizori()
            GUIDelete($Formlistafurnizori)
EndFunc   ;==
Func listafurnizori()
Global $IE, $Formlistafurnizori2
Global $Formlistafurnizori2, $furcli, $urlll, $GUIActiveX
    if $Formlistafurnizori2 Then
        GUIDelete($Formlistafurnizori2)
    EndIf
        ; Test command line
If ($CmdLine[0] = 2) And ($CmdLine[1] = "\IeFileSave") Then
    $iPPID = Int(StringTrimLeft($CmdLine[2], 6)) ; Get \PPID:n parameter
    While ProcessExists($iPPID) ; Terminate if parent does
        If WinExists("[TITLE:Lista Furnizori]", "") Then
            $hWin = WinGetHandle("[TITLE:Lista Furnizori]", "") ; Get dialog handle
            ControlSend($hWin, "", "", "{ENTER}") ; Send 'OK'
            ExitLoop
        EndIf
        Sleep(100)
    WEnd
    Exit
EndIf
$furcli="furnizori"
$IE = _IECreateEmbedded()
$Formdebloc = GUICreate("Lista furnizori", @DesktopWidth-100, @DesktopHeight-100, -1, -1)
$GUIActiveX = GUICtrlCreateObj( $IE, 1, 1, @DesktopWidth-102, @DesktopHeight-200)
GUICtrlCreateButton("Print", (@DesktopWidth-100)/2-87, @DesktopHeight-150, 177, 41)
GUICtrlSetOnEvent(-1, "printfurnizori")
GUICtrlCreateButton("Export Excel", (@DesktopWidth-100)/2+90, @DesktopHeight-150, 177, 41)
GUICtrlSetOnEvent(-1, "excelfurnizori")
$urlll="http://localhost/pos/furcli.php?a="&$furcli&"&&ffexclusiv="&_GUICtrlButton_GetState($ffexclusiv)&"&&afnume="&_GUICtrlButton_GetState($afnume)&"&&afro="&_GUICtrlButton_GetState($afro)&"&&afj="&_GUICtrlButton_GetState($afj)&"&&aflocalitate="&_GUICtrlButton_GetState($aflocalitate)&"&&afadresa="&_GUICtrlButton_GetState($afadresa)&"&&afjudet="&_GUICtrlButton_GetState($afjudet)&"&&afcapsocial="&_GUICtrlButton_GetState($afcapsocial)&"&&afpunctlucru="&_GUICtrlButton_GetState($afpunctlucru)&"&&afperscontact="&_GUICtrlButton_GetState($afperscontact)&"&&aftelefon="&_GUICtrlButton_GetState($aftelefon)&"&&affax="&_GUICtrlButton_GetState($affax)&"&&afmail="&_GUICtrlButton_GetState($afmail)&"&&afurl="&_GUICtrlButton_GetState($afurl)&"&&afcont1="&_GUICtrlButton_GetState($afcont1)&"&&afbanca1="&_GUICtrlButton_GetState($afbanca1)&"&&afcont2="&_GUICtrlButton_GetState($afcont2)&"&&afbanca2="&_GUICtrlButton_GetState($afbanca2)&"&&afcont3="&_GUICtrlButton_GetState($afcont3)&"&&afbanca3="&_GUICtrlButton_GetState($afbanca3)&"&&ffnume="&GUICtrlRead($ffnume)&"&&ffro="&GUICtrlRead($ffro)&"&&ffj="&GUICtrlRead($ffj)&"&&fflocalitate="&GUICtrlRead($fflocalitate)&"&&ffadresa="&GUICtrlRead($ffadresa)&"&&ffjudet="&GUICtrlRead($ffjudet)&"&&ffcapsocial1="&GUICtrlRead($ffcapsoc1)&"&&ffcapsocial2="&GUICtrlRead($ffcapsoc2)&"&&ffpunctlucru="&GUICtrlRead($ffpunctlucru)&"&&ffperscontact="&GUICtrlRead($ffperscontact)&"&&fftelefon="&GUICtrlRead($fftel)&"&&fffax="&GUICtrlRead($fffax)&"&&ffmail="&GUICtrlRead($ffmail)&"&&ffurl="&GUICtrlRead($ffurl)&"&&afcont1="&_GUICtrlButton_GetState($afcont1)&"&&ffbanca1="&GUICtrlRead($ffbanca1)&"&&ffbanca2="&GUICtrlRead($ffbanca2)&"&&ffbanca3="&GUICtrlRead($ffbanca3)

;~ MsgBox(-1, "", $urlll)
_IENavigate($IE, $urlll)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "outlistafurnizori")
EndFunc
Func outlistafurnizori()
            GUIDelete($Formlistafurnizori2)
        EndFunc   ;==
Func excelfurnizori()


$IE2 = _IECreateEmbedded()
$Formdebloc2 = GUICreate("Lista furnizoricc", @DesktopWidth-100, @DesktopHeight-100, -1, -1)
$GUIActiveX2 = GUICtrlCreateObj( $IE2, 1, 1, @DesktopWidth-102, @DesktopHeight-200)
$urlll2=$urlll&"&&export=1"
Run(@ScriptFullPath & " \IeFileSave \PPID:" & @AutoItPID)
_IENavigate($IE2, $urlll2)
GUISetState(@SW_HIDE)
sleep(5000)
GUIDelete($Formdebloc2)
EndFunc   ;==
Func printfurnizori()
$IE.execWB(7,2) ; IDM_PRINTPREVIEW not work
EndFunc

I like IT: php, mysql, codeingiter, css, jquery and AUTOIT

Share this post


Link to post
Share on other sites
ShadowElf

problem fixed

_IENavigate($IE, $urlll2, 0)

thx


I like IT: php, mysql, codeingiter, css, jquery and AUTOIT

Share this post


Link to post
Share on other sites
PsaltyDS

problem fixed

_IENavigate($IE, $urlll2, 0)

Uhm, that was the suggestion in post #2 ($f_wait = False). The more complicated technique in post #4 assumed that hadn't worked.

Whatever...

:mellow:


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

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  

×