Jump to content

Recommended Posts

Hello, I am trying to run a program using @SW-HIDE, and I need to save from inside the program, also in the save mode.

The code:

run("IE.exe","",@SW_HIDE)
winactivate("Internet")
send("^s")

When it executes send("^s") , the save as window comes up. Is there a way to save without showing the window? Any help is much apreciated ;) thanks!

Edited by richietheprogrammer1
Link to post
Share on other sites

#include <IE.au3>
#Include <WinAPI.au3>

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$UserName = "UserName"
$PassWord = "PassWord"
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php?app=core&module=global&section=login",0,0)
$UserNameInput = GetObject($oIE,"input","username","text")
$g_eventerror = 0
$PassWordInput = GetObject($oIE,"input","password","password")
$g_eventerror = 0
$input_submit = GetObject($oIE,"input","","submit","Sign In")
_IEFormElementSetValue ($UserNameInput,$UserName)
_IEFormElementSetValue ($PassWordInput,$PassWord)
$input_submit.click
$hwnd = _IEPropertyGet($oIE, "hwnd")
MsgBox(0,"MSG","SW_SHOW")
_WinAPI_ShowWindow($hWnd,@SW_SHOW)


Func GetObject($oIE,$tagName,$Name = "",$Type = "",$value = "",$Id = "")
Local $BOOL1 = 1, $BOOL2 = 1 , $BOOL3 = 1 , $BOOL4 = 1 , $BOOL5 = 1
for $i = 0 To $oIE.document.all.length - 1
$BOOL1 = StringUpper($oIE.document.all($i).tagName) == StringUpper($tagName)
if ($BOOL1) And $Name == "" And $Type == "" And $id == "" And $value == "" _ 
Then Return $oIE.document.all($i)

if ($BOOL1) And $Name <> "" Then
$BOOL2 = StringUpper($oIE.document.all($i).Name) == StringUpper($Name)
if ($BOOL2) And $Type == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $Type <> "" Then
$BOOL3 = StringUpper($oIE.document.all($i).Type) == StringUpper($Type)
if ($BOOL3) And $Name == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $value <> "" Then
$BOOL5 = StringUpper($oIE.document.all($i).value) == StringUpper($value)
if ($BOOL5) And $Name == "" And $Type == "" And $Id == "" Then Return $oIE.document.all($i)
EndIf


if ($BOOL1) And $Id <> "" Then
$BOOL4 = StringUpper($oIE.document.all($i).id) == StringUpper($Id)
if ($BOOL4) And $Name == "" And $Type == "" And $value == "" Then Return $oIE.document.all($i)
EndIf


if $BOOL1 And $BOOL2 And $BOOL3 And $BOOL4 And $BOOL5 Then Return $oIE.document.all($i)


Next
Return 0
EndFunc



Func MyErrFunc() 
Endfunc

صرح السماء كان هنا

 

Link to post
Share on other sites

#include <IE.au3>
#Include <WinAPI.au3>

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$UserName = "UserName"
$PassWord = "PassWord"
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php?app=core&module=global&section=login",0,0)
$UserNameInput = GetObject($oIE,"input","username","text")
$g_eventerror = 0
$PassWordInput = GetObject($oIE,"input","password","password")
$g_eventerror = 0
$input_submit = GetObject($oIE,"input","","submit","Sign In")
_IEFormElementSetValue ($UserNameInput,$UserName)
_IEFormElementSetValue ($PassWordInput,$PassWord)
$input_submit.click
$hwnd = _IEPropertyGet($oIE, "hwnd")
MsgBox(0,"MSG","SW_SHOW")
_WinAPI_ShowWindow($hWnd,@SW_SHOW)


Func GetObject($oIE,$tagName,$Name = "",$Type = "",$value = "",$Id = "")
Local $BOOL1 = 1, $BOOL2 = 1 , $BOOL3 = 1 , $BOOL4 = 1 , $BOOL5 = 1
for $i = 0 To $oIE.document.all.length - 1
$BOOL1 = StringUpper($oIE.document.all($i).tagName) == StringUpper($tagName)
if ($BOOL1) And $Name == "" And $Type == "" And $id == "" And $value == "" _ 
Then Return $oIE.document.all($i)

if ($BOOL1) And $Name <> "" Then
$BOOL2 = StringUpper($oIE.document.all($i).Name) == StringUpper($Name)
if ($BOOL2) And $Type == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $Type <> "" Then
$BOOL3 = StringUpper($oIE.document.all($i).Type) == StringUpper($Type)
if ($BOOL3) And $Name == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $value <> "" Then
$BOOL5 = StringUpper($oIE.document.all($i).value) == StringUpper($value)
if ($BOOL5) And $Name == "" And $Type == "" And $Id == "" Then Return $oIE.document.all($i)
EndIf


if ($BOOL1) And $Id <> "" Then
$BOOL4 = StringUpper($oIE.document.all($i).id) == StringUpper($Id)
if ($BOOL4) And $Name == "" And $Type == "" And $value == "" Then Return $oIE.document.all($i)
EndIf


if $BOOL1 And $BOOL2 And $BOOL3 And $BOOL4 And $BOOL5 Then Return $oIE.document.all($i)


Next
Return 0
EndFunc



Func MyErrFunc() 
Endfunc

Thanks, but I do not think this is what I need. Also, it is not an internet explorer window, it is another program. The question is how can I do things like ctrl s inside a window that is running in hidden mode. Thanks!

Edited by richietheprogrammer1
Link to post
Share on other sites

It would be useless to create a hidden, or to hide a, 'save as' dialog window, as that window expects user input.. Why not go with 'Save', instead of 'Save As'?

Here is why: let's say you have a program that reads data from somewhere once you open it, and you want to save the data and send it to somebody.

I want to script the process. So I want to make the program run, save the data automatically, with nothing showing. So far I was able to launch that program silently (hidden). When you hit ctr s, you have to choose the path. So there is no way I can automatically call it "test.txt" or whatever and save it without showing the save as window? I find that strange.

Link to post
Share on other sites

The point remains there's no way to prevent it from showing. Just Send("test.txt{ENTER}") or something when the window appears.

That is what I am doing now. I was just thinking about this, and I wonder: There has to be a way to make the save as window act like it is a seperate program. Or maybe create a program that acts the same way as that save as window, and hide it. Any thoughts about that?

Link to post
Share on other sites

Thanks, but I do not think this is what I need. Also, it is not an internet explorer window, it is another program. The question is how can I do things like ctrl s inside a window that is running in hidden mode. Thanks!

#Include <WinAPI.au3>
#include <WindowsConstants.au3>
$PID = run("Example.exe","",@SW_HIDE)
Dim $BOOL = False , $hWnd
$begin = TimerInit()
While 1
$var = WinList()
For $i = 1 To $var[0][0]
$iPID = WinGetProcess($var[$i][1])
if $PID = $iPID Then
$hWnd = $var[$i][1]
$BOOL  = True
ExitLoop
EndIf
Next
if $BOOL = True Or TimerDiff($begin) > 60000 Then ExitLoop
WEnd
MsgBox(0,"MSG","SW_SHOW")
_WinAPI_ShowWindow($hWnd,@SW_SHOW)

or

#include <IE.au3>
#Include <WinAPI.au3>
#include <WindowsConstants.au3>

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$UserName = "UserName"
$PassWord = "PassWord"
$PID = run("C:\Program Files\Internet Explorer\iexplore.exe","",@SW_HIDE)
$BOOL = False
$begin = TimerInit()
While 1
$var = WinList()
For $i = 1 To $var[0][0]
$iPID = WinGetProcess($var[$i][1])
if $PID = $iPID Then
$oIE = _IEAttach ($var[$i][1],"HWND")
if IsObj($oIE) Then
_IELoadWait ($oIE)
$BOOL  = True
ExitLoop
EndIf
EndIf
Next
if $BOOL = True Or TimerDiff($begin) > 60000 Then ExitLoop
WEnd

if $BOOL  = True Then
_IENavigate ($oIE,"http://www.autoitscript.com/forum/index.php?app=core&module=global&section=login")
$UserNameInput = GetObject($oIE,"input","username","text")
$PassWordInput = GetObject($oIE,"input","password","password")
$input_submit = GetObject($oIE,"input","","submit","Sign In")
if IsObj($UserNameInput) Then $UserNameInput.Value = $UserName
if IsObj($PassWordInput) Then $PassWordInput.Value = $PassWord
;if IsObj($input_submit) Then $input_submit.click
MsgBox(0,"MSG","SW_SHOW")
_WinAPI_ShowWindow($var[$i][1],@SW_SHOW)
EndIf


Func GetObject($oIE,$tagName,$Name = "",$Type = "",$value = "",$Id = "")
Local $BOOL1 = 1, $BOOL2 = 1 , $BOOL3 = 1 , $BOOL4 = 1 , $BOOL5 = 1
for $i = 0 To $oIE.document.all.length - 1
$BOOL1 = StringUpper($oIE.document.all($i).tagName) == StringUpper($tagName)
if ($BOOL1) And $Name == "" And $Type == "" And $id == "" And $value == "" _ 
Then Return $oIE.document.all($i)

if ($BOOL1) And $Name <> "" Then
$BOOL2 = StringUpper($oIE.document.all($i).Name) == StringUpper($Name)
if ($BOOL2) And $Type == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $Type <> "" Then
$BOOL3 = StringUpper($oIE.document.all($i).Type) == StringUpper($Type)
if ($BOOL3) And $Name == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $value <> "" Then
$BOOL5 = StringUpper($oIE.document.all($i).value) == StringUpper($value)
if ($BOOL5) And $Name == "" And $Type == "" And $Id == "" Then Return $oIE.document.all($i)
EndIf


if ($BOOL1) And $Id <> "" Then
$BOOL4 = StringUpper($oIE.document.all($i).id) == StringUpper($Id)
if ($BOOL4) And $Name == "" And $Type == "" And $value == "" Then Return $oIE.document.all($i)
EndIf


if $BOOL1 And $BOOL2 And $BOOL3 And $BOOL4 And $BOOL5 Then Return $oIE.document.all($i)


Next
Return 0
EndFunc



Func MyErrFunc() 
Endfunc
Edited by wolf9228

صرح السماء كان هنا

 

Link to post
Share on other sites

#Include <WinAPI.au3>
#include <WindowsConstants.au3>
$PID = run("Example.exe","",@SW_HIDE)
Dim $BOOL = False , $hWnd
$begin = TimerInit()
While 1
$var = WinList()
For $i = 1 To $var[0][0]
$iPID = WinGetProcess($var[$i][1])
if $PID = $iPID Then
$hWnd = $var[$i][1]
$BOOL  = True
ExitLoop
EndIf
Next
if $BOOL = True Or TimerDiff($begin) > 60000 Then ExitLoop
WEnd
MsgBox(0,"MSG","SW_SHOW")
_WinAPI_ShowWindow($hWnd,@SW_SHOW)

or

#include <IE.au3>
#Include <WinAPI.au3>
#include <WindowsConstants.au3>

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$UserName = "UserName"
$PassWord = "PassWord"
$PID = run("C:\Program Files\Internet Explorer\iexplore.exe","",@SW_HIDE)
$BOOL = False
$begin = TimerInit()
While 1
$var = WinList()
For $i = 1 To $var[0][0]
$iPID = WinGetProcess($var[$i][1])
if $PID = $iPID Then
$oIE = _IEAttach ($var[$i][1],"HWND")
if IsObj($oIE) Then
_IELoadWait ($oIE)
$BOOL  = True
ExitLoop
EndIf
EndIf
Next
if $BOOL = True Or TimerDiff($begin) > 60000 Then ExitLoop
WEnd

if $BOOL  = True Then
_IENavigate ($oIE,"http://www.autoitscript.com/forum/index.php?app=core&module=global&section=login")
$UserNameInput = GetObject($oIE,"input","username","text")
$PassWordInput = GetObject($oIE,"input","password","password")
$input_submit = GetObject($oIE,"input","","submit","Sign In")
if IsObj($UserNameInput) Then $UserNameInput.Value = $UserName
if IsObj($PassWordInput) Then $PassWordInput.Value = $PassWord
;if IsObj($input_submit) Then $input_submit.click
MsgBox(0,"MSG","SW_SHOW")
_WinAPI_ShowWindow($var[$i][1],@SW_SHOW)
EndIf


Func GetObject($oIE,$tagName,$Name = "",$Type = "",$value = "",$Id = "")
Local $BOOL1 = 1, $BOOL2 = 1 , $BOOL3 = 1 , $BOOL4 = 1 , $BOOL5 = 1
for $i = 0 To $oIE.document.all.length - 1
$BOOL1 = StringUpper($oIE.document.all($i).tagName) == StringUpper($tagName)
if ($BOOL1) And $Name == "" And $Type == "" And $id == "" And $value == "" _ 
Then Return $oIE.document.all($i)

if ($BOOL1) And $Name <> "" Then
$BOOL2 = StringUpper($oIE.document.all($i).Name) == StringUpper($Name)
if ($BOOL2) And $Type == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $Type <> "" Then
$BOOL3 = StringUpper($oIE.document.all($i).Type) == StringUpper($Type)
if ($BOOL3) And $Name == "" And $Id == "" And $value == "" Then Return $oIE.document.all($i)
EndIf

if ($BOOL1) And $value <> "" Then
$BOOL5 = StringUpper($oIE.document.all($i).value) == StringUpper($value)
if ($BOOL5) And $Name == "" And $Type == "" And $Id == "" Then Return $oIE.document.all($i)
EndIf


if ($BOOL1) And $Id <> "" Then
$BOOL4 = StringUpper($oIE.document.all($i).id) == StringUpper($Id)
if ($BOOL4) And $Name == "" And $Type == "" And $value == "" Then Return $oIE.document.all($i)
EndIf


if $BOOL1 And $BOOL2 And $BOOL3 And $BOOL4 And $BOOL5 Then Return $oIE.document.all($i)


Next
Return 0
EndFunc



Func MyErrFunc() 
Endfunc

Both of these scripts just show the program that I ran, they do not save using a hidden way..

Link to post
Share on other sites

What kind of file needs saving? Can it be done with AutoIt? If it can, that would certainly help this matter.. :)

Ok so here is the answer to your question: I am trying to export the IE browsing history, using this program http://www.nirsoft.net/utils/iehv.html

Please note I must use that specific program. Once I run that exe, I need to do a save as. Again, I am able to run the actual program in hidden mode,

but once it executes "ctr s", the save as window pops up. Thoughts? Thanks a lot ;)

Link to post
Share on other sites

If you read to the bottom of the page you posted you would see that there are Commandline Parameters for that app.

iehv /shtml "c:\temp\urls.html"

iehv /stext "c:\temp\urls.txt"

Etc.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...