Sign in to follow this  
Followers 0
Zoroxeus

Incorporating VBS in AuoIt

15 posts in this topic

#1 ·  Posted (edited)

Hello,

I have been trying to incorporate my VBS script in AutoIt,

Can't I just copy/paste ? because it does not seem to work...

Thanks

My code is below !

'Create a WshShell Object

Set WshShell = Wscript.CreateObject("Wscript.Shell")

'Create a WshShortcut Object

Set oShellLink = WshShell.CreateShortcut("ImpAct.lnk")

'Set the Target Path for the shortcut

oShellLink.TargetPath = "http://trakwebtest/qireg/createiap.asp?user=&project=6400"

'oShellLink.SetIconLocation "C:\Windows\System32\SHELL32.dll", 46

oShellLink.IconLocation = "C:\WINDOWS\system32\tourstart.exe, 0"

'oShellLink.IconLocation = "C:\WINDOWS\system32\SHELL32.dll, 88"

'oShellLink.IconLocation = "C:\WINDOWS\system32\user32.dll, 1"

'Save the shortcut

oShellLink.Save

'Clean up the WshShortcut Object

Set oShellLink = Nothing

SelfDestruct

Sub SelfDestruct()

Set objFso = CreateObject("Scripting.FileSystemObject")

objFso.DeleteFile WScript.ScriptFullName

Set objFso = Nothing

End Sub

Edited by Zoroxeus

Share this post


Link to post
Share on other sites



>I have been trying to incorporate my VBS script in AutoIt,

>Can't I just copy/paste ?

Um, no

>because it does not seem to work...

Why would you expect it to?

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Now that you have posted some code, I'll tell you that you need to convert it to AutoIt syntax. It is similar in some ways (at least more similar than curly-brace languages like C), but it is still quite different.

In your case you should particularly look at the helpfile section on Obj/COM and look for examples in the forum.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Now that you have posted some code, I'll tell you that you need to convert it to AutoIt syntax. It is similar in some ways (at least more similar than curly-brace languages like C), but it is still quite different.

In your case you should particularly look at the helpfile section on Obj/COM and look for examples in the forum.

Dale

Thanks,

I did look at the Obj/Com section but I learn better from the real code rather than the syntax most of the time...

The obj/com section is quite limited and does not have examples for my case..

I did use $ to set variables and work with them... but it is not really working...

Share this post


Link to post
Share on other sites

Thanks,

I did look at the Obj/Com section but I learn better from the real code rather than the syntax most of the time...

The obj/com section is quite limited and does not have examples for my case..

I did use $ to set variables and work with them... but it is not really working...

Show what you have ... you might get help ...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Show what you have ... you might get help ...

This is what I have... but obviously it is not working,....

$WshShell = CreateObject("Wscript.Shell")

$WshShell.Wscript()

$oShellLink = WshShell.CreateShortcut("ImpAct.lnk")

$oShellLink.TargetPath = "http://trakwebtest/qireg/createiap.asp?user=&project=6400"

$oShellLink.IconLocation = "C:\WINDOWS\system32\tourstart.exe, 0"

$oShellLink.Save

$oShellLink = Nothing

Call ("SelfDestruct")

Func SelfDestruct()

$objFso = CreateObject("Scripting.FileSystemObject")

objFso.DeleteFile WScript.ScriptFullName

$objFso = Nothing

EndFunc

Share this post


Link to post
Share on other sites

$WshShell = ObjCreate("Wscript.Shell")
$oShellLink = $WshShell.CreateShortcut ("ImpAct.lnk")
$oShellLink.TargetPath = "http://trakwebtest/qireg/createiap.asp?user=&project=6400"
$oShellLink.IconLocation = "C:\WINDOWS\system32\tourstart.exe, 0"
$oShellLink.Save
$oShellLink = ""

But whats wrong with FileCreateShortCut() ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

$WshShell = ObjCreate("Wscript.Shell")
$oShellLink = $WshShell.CreateShortcut ("ImpAct.lnk")
$oShellLink.TargetPath = "http://trakwebtest/qireg/createiap.asp?user=&project=6400"
$oShellLink.IconLocation = "C:\WINDOWS\system32\tourstart.exe, 0"
$oShellLink.Save
$oShellLink = ""

But whats wrong with FileCreateShortCut() ?

Nothing, but I did not manage to create a link ... because I have to link the shortcut to a file... and I did not know wich one... ? I would be curious to know however if you have a better way ? (I know it's shorter)

Also I am looking to delete the exe autoamticly, any idea ?

Thanks man you rule ! :whistle: (i was not that far)

Share this post


Link to post
Share on other sites

Nothing, but I did not manage to create a link ... because I have to link the shortcut to a file... and I did not know wich one... ? I would be curious to know however if you have a better way ? (I know it's shorter)

Also I am looking to delete the exe autoamticly, any idea ?

Thanks man you rule ! :whistle: (i was not that far)

Sure posted many times in the forum:

; Your code
_SelfDelete()

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '" > nul' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Nothing, but I did not manage to create a link ... because I have to link the shortcut to a file... and I did not know wich one... ? I would be curious to know however if you have a better way ? (I know it's shorter)

FileCreateShortcut("http://trakwebtest/qireg/createiap.asp?user=&project=6400","ImpAct2.lnk",Default,Default, "", "C:\WINDOWS\system32\tourstart.exe, 0")

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

FileCreateShortcut("http://trakwebtest/qireg/createiap.asp?user=&project=6400","ImpAct2.lnk",Default,Default, "", "C:\WINDOWS\system32\tourstart.exe, 0")

Thanks ! I could have never guessed for the "Default" trick... neither for the self destruct ! (I searched 'destrcut' and did not find anything on the forum). Going to go through it to try to understand it as it seems a bit complicated....

I have also this code below in VBS that I did:

Set myOlApp = CreateObject("Outlook.Application")

Set myNameSpace = myOlApp.GetNameSpace("MAPI")

Set myFolder = myNamespace.GetDefaultFolder(6)

Set myNewFolder = myFolder.Folders.Add("ImpActs")

Set myNewBisFolder = myNewFolder.Folders.Add("ImpActs2")

tried to move it to autoit this way:

$myOlApp = ObjCreate("Outtlook.Application")

$myNameSpace = $myOlApp.GetNameSpace("MAPI")

$myFolder = $myNameSpace.GetDefaultFolder(6)

$myNewFolder = $myFolder.Folders.Add("ImpActs")

$myNewBisFolder = $myNewFolder.Folders.Add("ImpAct2")

Gives me an error "Variable must be of type object" ....

is not myOldApp of type object ? since I used "ObjCreate" ??

Thanks

Share this post


Link to post
Share on other sites

T to many ?

Fantastic !!!!! :whistle:

Thanks a lot ! I thought for some moment I had not understood the concepts ;)

Any idea where i should start if I want to import rules in outlook ?

Share this post


Link to post
Share on other sites

Fantastic !!!!! :whistle:

Thanks a lot ! I thought for some moment I had not understood the concepts ;)

Any idea where i should start if I want to import rules in outlook ?

MSDN


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Thanks I looked there... I could not find anything about importing rules though... ?

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  
Followers 0