AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Embedded Windows Scripting (VBScript & JScript) and COM
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 14, 15, 16  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Sun Feb 22, 2009 8:03 am    Post subject: Reply with quote

Ah webber, if you had checked ErrorLevel, it would have helped you with what the problem is.

The WshShell is not available for the Microsoft Scripting Control, so the code will fail if either of these lines are run.
Code:
WshShell.Sleep 50
Code:
WshShell.quit
If you remove those lines, you will see the clipboard.

But I don't understand why are you using VBScript to get the clipboard when it's so much easier with Autohotkey.
_________________
-m35
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Sun Feb 22, 2009 5:29 pm    Post subject: Reply with quote

that seems to have done the trick.

I will look into error level if I can find where/how to access it.

the simplistic intent of the function was to allow exchanging use of the clipboard between the two environments.

there's probably a better way to do this....
________
BMW N73


Last edited by webber on Thu Mar 10, 2011 11:28 pm; edited 1 time in total
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Sun Feb 22, 2009 5:39 pm    Post subject: sample script problem Reply with quote

I got this sample script from the API docs. It throws an error when run. Can someone explain why the error on line 14 is occurring ?

line 14: WS_Exec("DHtmlControl.LoadUrl %s", "http://www.autohotkey.com")

Code:


    ; Creates a WYSIWYG html editor in just 20 lines (method 2)
    #Include ws4ahk.ahk
    WS_Initialize()
    WS_InitComControls()

    Gui, +LastFound
    Gui, Show, w800 h600 Center, DhtmlEdit Test
    hWnd := WinExist()
    COMhWnd := WS_CreateComControlContainer(hWnd, 10, 10, 780, 580, "DhtmlEdit.DhtmlEdit")
    ppvDEdit := WS_GetComControlInHWND(COMhWnd)
    WS_AddObject(ppvDEdit, "DHtmlControl")
    ; the scripting environment has the object, so we don't need it anymore
    WS_ReleaseObject(ppvDEdit)
    WS_Exec("DHtmlControl.LoadUrl %s", "http://www.autohotkey.com")
    Return

    GuiClose:
        Gui, %A_Gui%:Destroy
        WS_UninitComControls()
        WS_Uninitialize()
        ExitApp


________
BABI MAC BREAKAWAY


Last edited by webber on Thu Mar 10, 2011 11:28 pm; edited 1 time in total
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Sun Feb 22, 2009 5:50 pm    Post subject: Reply with quote

Ok that one is my fault. That example needs to be updated with more recent changes to the API.

If you change that line giving you the error, to
Code:
WS_Exec("DHtmlControl.LoadUrl ""http://www.autohotkey.com""")
it will work fine.
_________________
-m35
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Sun Feb 22, 2009 6:11 pm    Post subject: Reply with quote

thanks that fixed the example.

How might I change the example to load an .hta file into the AHK window, so I can manage it from Autohotkey ?
________
HERO HONDA KARIZMA R


Last edited by webber on Thu Mar 10, 2011 11:28 pm; edited 1 time in total
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Sun Feb 22, 2009 6:34 pm    Post subject: Reply with quote

It's getting harder and harder to find OLE/COM documentation on the web these days.

Finally found some info for the DHTMLEdit. I think you want to use
Code:
WS_Exec("DHtmlControl.LoadDocument ""file.hta""")


You also might look at the code n-l-i-d was nice enough to update.
http://www.autohotkey.com/forum/viewtopic.php?p=220934#220934
It seems to have a few errors, but it's mostly working.
_________________
-m35
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Sun Feb 22, 2009 7:04 pm    Post subject: Reply with quote

my bad...I was not clear in my request

That does load the hta file but it comes in for editing.

I was wanting to run the hta inside the ahk window.

I don't know what to 'execute' to run the hta application.
________
Uggs


Last edited by webber on Thu Mar 10, 2011 11:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Sun Feb 22, 2009 7:10 pm    Post subject: Reply with quote

webber wrote:
I was wanting to run the hta inside the ahk window.

Mmm, that is a difficult requirement. You may want to look at using a normal Internet Explorer control and have it load the .HTA file. I can't help you with much more than that. This is getting beyond what I know.
_________________
-m35
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Sun Feb 22, 2009 8:45 pm    Post subject: Reply with quote

FYI
hta files do not run in a IE browser control
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Thu Mar 26, 2009 7:38 pm    Post subject: hiding icon on task-bar button Reply with quote

when a msgbox dialog is created by vbscript, a taskbar button appears with the autohotkey icon.

how can I prevent the taskbar button from appearing or how can I omit the autohotkey icon when using "msgbox" from vbscript ?

ahk code:

Code:

#include ws4ahk.ahk
#include vbs_msgbox.ahk
WS_Exec("showmsgbox()")


vbs code:

Code:

#Include ws4ahk.ahk
 
;Initialize vbscript
;-------------------
WS_Initialize()

;create vbscript functions
;---------------------------
VBCode =
(
sub showmsgbox()
   msgbox "hello world!"
end sub
)

; add the VB functions to the environment
;----------------------------------------
WS_Exec(VBCode)

________
New Jersey Marijuana Dispensaries


Last edited by webber on Thu Mar 10, 2011 11:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Thu Mar 26, 2009 8:39 pm    Post subject: Re: hiding icon on task-bar button Reply with quote

webber wrote:
when a msgbox dialog is created by vbscript, a taskbar button appears with the autohotkey icon.

how can I prevent the taskbar button from appearing or how can I omit the autohotkey icon when using "msgbox" from vbscript ?

By default, Autohotkey's Msgbox also appears in the taskbar. To remove it, you can give the message box a window to use as its parent.

The same solution works for message boxes shown using VBScript. To set the parent window HWND, use this code:
Code:

#Include ws4ahk.ahk

SetWSParentHwnd(iHwnd)
{
   global __WS_iScriptControlObj__
   iErr := DllCall(__WS_VTable(__WS_iScriptControlObj__, 11), "UInt", __WS_iScriptControlObj__
            , "Int", iHwnd
            , "Int")         
}

; Test
WS_Initialize()
; Set the Program Manager window as the message box parent
; (not a very good window to use because it blocks the user from the desktop)
iProgManagerHwnd := WinExist("Program Manager")
SetWSParentHwnd(iProgManagerHwnd)
WS_Exec("Msgbox ""Testing""")


Hope this meets your needs.
_________________
-m35
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Thu Mar 26, 2009 9:21 pm    Post subject: Reply with quote

that worked great, thanks.

On my machine, win xp pro , the desktop was not blocked. i could click outside the msgbox and do whatever...

The msgbox remained on screen, behind other active windows, until it was closed.

on a separate function to browse for a folder I am finding yet another autohotkey button...


Code:

WS_Eval(res,"Browse(""Select folder"")")


Code:


   Function Browse(Msg)
      Dim a,f,i,B
      Set a=CreateObject("Shell.Application")
      On Error Resume Next
      Set f=a.BrowseForFolder(&H0&, Msg, &h1&)
      B=f.ParentFolder.ParseName(f.Title).Path
      If Err.Number<>0 Then
         B=Null
         i=InStr(f.Title,":")
         If i>0 Then B=Mid(f.Title,i-1,2) & "\"
      End If
      Browse = B
      Set a=Nothing
   End Function



any tips for this problem ?
________
MEDICAL MARIJUANA DISPENSARIES


Last edited by webber on Thu Mar 10, 2011 11:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Fri Mar 27, 2009 3:02 am    Post subject: Reply with quote

Looks like you can use the same idea for that function. Just pass it a HWND of some window to use as its parent.

Code:
#Include ws4ahk.ahk

WS_Initialize()


sVBCode =
(
Function Browse(Msg, Hwnd)
  Dim a,f,i,B
  Set a=CreateObject("Shell.Application")
  On Error Resume Next
  Set f=a.BrowseForFolder(Hwnd, Msg, &h1&)
  B=f.ParentFolder.ParseName(f.Title).Path
  If Err.Number<>0 Then
    B=Null
    i=InStr(f.Title,":")
    If i>0 Then B=Mid(f.Title,i-1,2) & "\"
  End If
  Browse = B
  Set a=Nothing
End Function
)


WS_Exec(sVBCode)

iProgManagerHwnd := WinExist("Program Manager") + 0 ; add 0 to convert from hex to decimal
Msgbox % iProgManagerHwnd
WS_Eval(res,"Browse(""Select folder"", " . iProgManagerHwnd . ")")

_________________
-m35
Back to top
View user's profile Send private message
ramin
Guest





PostPosted: Fri Apr 10, 2009 6:07 pm    Post subject: Reply with quote

I'm trying to use ws4ahk for a patch PPT file processor that I'm developing. I have a gui that opens PowerPoint files and then i want to open the files one by one (and do some more stuff later).

Hire is my code:
Code:
#Include ws4ahk.ahk
WS_Initialize()
WS_InitComControls()


Gui, Add, Button, x6 y10 w140 h30, &Load PowerPoint Files
Gui, Add, Button, x428 y10 w140 h30, &Open PPT
Gui, 1:Add, ListBox, X6 Y70 R28 W564 +VScroll +HScroll vTCLIST
Gui, Show
return

ButtonLoadPowerPointFiles:
 FileSelectFile, files, M3, , Select PowerPoint files to print:, PowerPoint (*.ppt)
 If ( files="" OR ErrorLevel ) {
     MsgBox, The user pressed cancel.
     Return
 }
 FileList := ""
 Loop, Parse, files, `n
 {
    If ( A_Index = 1 )
    {
       Folder := A_LoopField
       Continue
    }         
    FileList .= ((FileList<>"") ? "|" : "" ) Folder "\" A_LoopField
 }
 GuiControl,,TCLIST, %FileList%
Return

ButtonOpenPPT:
pptObj := WS_CreateObject("PowerPoint.Application")

WS_AddObject(pptObj, "ppApp")
WS_ReleaseObject(pptObj)

Loop, Parse, FileList, |
{
   WS_Exec("ppApp.Presentations.Open(""" %A_LoopField% """)")
}
Return

GuiClose:
    Gui, %A_Gui%:Destroy
    WS_UninitComControls()
   WS_Uninitialize()

ExitApp


When I load PPTs and try to open them, I get the following error:

Code:
Error: The following variable name contains an illegal character:
"C:\pptfile.ppt"


Any ideas on how I should pass in A_LoopField variable?
Back to top
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Fri Apr 10, 2009 6:49 pm    Post subject: Reply with quote

Basically your problem is you shouldn't have the %% around A_LoopField. Here is your working code with that fix, and a few other updates you may or may not want to use.

Code:
#Include ws4ahk.ahk
WS_Initialize()


Gui, Add, Button, x6 y10 w140 h30, &Load PowerPoint Files
Gui, Add, Button, x428 y10 w140 h30, &Open PPT
Gui, 1:Add, ListBox, X6 Y70 R28 W564 +VScroll +HScroll vTCLIST
Gui, Show
return

ButtonLoadPowerPointFiles:
   FileSelectFile, files, M3, , Select PowerPoint files to print:, PowerPoint (*.ppt)
   If ( files="" OR ErrorLevel ) {
      MsgBox, The user pressed cancel.
      Return
   }
   FileList := ""
   Loop, Parse, files, `n
   {
      If ( A_Index = 1 )
      {
         Folder := A_LoopField
         Continue
      }         
      FileList .= ((FileList<>"") ? "|" : "" ) Folder "\" A_LoopField
   }
   GuiControl,,TCLIST, %FileList%
Return

ButtonOpenPPT:
   
   WS_Exec("Set ppApp = CreateObject(""PowerPoint.Application"")")
   WS_Exec("ppApp.Visible = true")

   Loop, Parse, FileList, |
   {
      WS_Exec("ppApp.Presentations.Open(""" A_LoopField """)")
   }
Return

GuiClose:
   Gui, %A_Gui%:Destroy
   WS_Uninitialize()

ExitApp

_________________
-m35


Last edited by erictheturtle on Fri Apr 10, 2009 8:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 14, 15, 16  Next
Page 11 of 16

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group