AutoHotkey Community

It is currently May 26th, 2012, 4:59 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12, 13, 14 ... 16  Next
Author Message
 Post subject:
PostPosted: February 22nd, 2009, 9:03 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 6:29 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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 March 11th, 2011, 12:28 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: sample script problem
PostPosted: February 22nd, 2009, 6:39 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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 March 11th, 2011, 12:28 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 6:50 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 7:11 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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 March 11th, 2011, 12:28 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 7:34 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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/viewtop ... 934#220934
It seems to have a few errors, but it's mostly working.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 8:04 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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 March 11th, 2011, 12:29 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 8:10 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2009, 9:45 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
FYI
hta files do not run in a IE browser control

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 26th, 2009, 8:38 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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 March 11th, 2011, 12:33 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 26th, 2009, 9:39 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2009, 10:21 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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 March 11th, 2011, 12:33 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2009, 4:02 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2009, 7:07 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2009, 7:49 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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 April 10th, 2009, 9:23 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12, 13, 14 ... 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group