AutoHotkey Community

It is currently May 27th, 2012, 4:16 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15, 16  Next
Author Message
 Post subject: Some advice
PostPosted: February 3rd, 2010, 6:17 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
obviously ws4ahk provides an easy way to implement vbscript or jscript within ahk thus extending its functionality nicely.

However the question should not be
Quote:
if I want to use ws4ahk to add a certain value 2 cells to the left of a cell with "ABCD" in it, how would I do this? I can reference cells directly, but is there any way to get the address of a cell with a given value in it?
it should be what vbscript or jscript would be used to do this?.

Consider using the built in macro recorder within excel to get some clue. Note not all code that qualifies as VBA is transfered "as is" to vbscript. but this can be used to test and if it works hurrah but if not then you will need to look into finding out methods from vbscript. For this the MSDN is a great place to start as well as microsofts forums.

Once you have code that will work in a .vbs file then you begin using ws4ahk at that point it should be super easy

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2010, 9:29 pm 
This GoogleEarthPhotoTag script makes use of ws4ahk.ahk.
When I use Autohotkey_L (unicode) and run the script I get the error:

Code:
Windows Scripting has not been initialized.
Exiting application.


I guess ws4ahk must be modified for compatibility with Autohotkey_L (Unicode).
How to do that?

Thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 4:35 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
I had a feeling ws4ahk wasn't going to work with Lexikos's impressive Unicode improvement.

I can appreciate wanting it updated, but is there a reason why you need to run the GoogleEarthPhotoTag program with the new Authotkey_L (Unicode) instead of normal Autohotkey?

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 6:47 am 
Try this:
Code:
__WS_ANSI2Unicode(sAnsi, ByRef sUtf16)
{
    if A_IsUnicode
        return true, sUtf16 := sAnsi

...
If you pass a UTF-16 string (sAnsi in a Unicode build) to MultiByteToWideChar and tell it that the string is ANSI, you won't get meaningful output.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 10:12 am 
Hello, I would like to use this code to connect to my Web Cam. If I run this code, should it not produce a preview window of my connected cam? Am I missing something critically important?


Code:

code=
(
Public Class Form1
    '---constants for capturing the video from webcam---
    Const WM_CAP_START = &H400S
    Const WS_CHILD = &H40000000
    Const WS_VISIBLE = &H10000000

    Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
    Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
    Const WM_CAP_EDIT_COPY = WM_CAP_START + 30
    Const WM_CAP_SEQUENCE = WM_CAP_START + 62
    Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23

    Const WM_CAP_SET_SCALE = WM_CAP_START + 53
    Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
    Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50

    Const SWP_NOMOVE = &H2S
    Const SWP_NOSIZE = 1
    Const SWP_NOZORDER = &H4S
    Const HWND_BOTTOM = 1

    '---used as a window handle---
    Dim hWnd As Integer

'--The capGetDriverDescription function retrieves the version
    ' description of the capture driver--
    Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _
       (ByVal wDriverIndex As Short, _
        ByVal lpszName As String, ByVal cbName As Integer, _
        ByVal lpszVer As String, _
        ByVal cbVer As Integer) As Boolean

    '--The capCreateCaptureWindow function creates a capture window--
    Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
       (ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
        ByVal x As Integer, ByVal y As Integer, _
        ByVal nWidth As Integer, _
        ByVal nHeight As Short, ByVal hWnd As Integer, _
        ByVal nID As Integer) As Integer

    '--This function sends the specified message to a window or
    ' windows--
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
       (ByVal hwnd As Integer, ByVal Msg As Integer, _
        ByVal wParam As Integer, _
        <MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) _
        As Integer

    '--Sets the position of the window relative to the screen buffer--
    Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
       (ByVal hwnd As Integer, _
        ByVal hWndInsertAfter As Integer, ByVal x As Integer, _
        ByVal y As Integer, _
        ByVal cx As Integer, ByVal cy As Integer, _
        ByVal wFlags As Integer) As Integer

    '--This function destroys the specified window--
    Declare Function DestroyWindow Lib "user32" _
       (ByVal hndw As Integer) As Boolean

    '---preview the selected video source---
    Private Sub PreviewVideo(ByVal pbCtrl As PictureBox)
        hWnd = capCreateCaptureWindowA(0, _
            WS_VISIBLE Or WS_CHILD, 0, 0, 0, _
            0, pbCtrl.Handle.ToInt32, 0)
        If SendMessage( _
           hWnd, WM_CAP_DRIVER_CONNECT, _
           0, 0) Then
            '---set the preview scale---
            SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
            '---set the preview rate (ms)---
            SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0)
            '---start previewing the image---
            SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
            '---resize window to fit in PictureBox control---
            SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, _
               pbCtrl.Width, pbCtrl.Height, _
               SWP_NOMOVE Or SWP_NOZORDER)
        Else
            '--error connecting to video source---
            DestroyWindow(hWnd)
        End If
    End Sub

    Private Sub Form1_Load( _
       ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles MyBase.Load
        PreviewVideo(PictureBox1)
    End Sub
)

WS_Initialize("VBScript")
WS_Exec(Code)
WS_Uninitialize()



Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 2:50 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
What's the value of ErrorLevel after each call?

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 9:05 pm 
Code:
Public Class Form1
    '---constants for capturing the video from webcam---
    Const WM_CAP_START = &H400S
    Const WS_CHILD = &H40000000
    Const WS_VISIBLE = &H10000000

    Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
    Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
    Const WM_CAP_EDIT_COPY = WM_CAP_START + 30
    Const WM_CAP_SEQUENCE = WM_CAP_START + 62
    Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23

    Const WM_CAP_SET_SCALE = WM_CAP_START + 53
    Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
    Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50

    Const SWP_NOMOVE = &H2S
    Const SWP_NOSIZE = 1
    Const SWP_NOZORDER = &H4S
    Const HWND_BOTTOM = 1


^^^ After this portion, I am receiving an "Expected Identifier" errorlevel


Code:
    '---used as a window handle---
    Dim hWnd As Integer

'--The capGetDriverDescription function retrieves the version
    ' description of the capture driver--
    Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _
       (ByVal wDriverIndex As Short, _
        ByVal lpszName As String, ByVal cbName As Integer, _
        ByVal lpszVer As String, _
        ByVal cbVer As Integer) As Boolean

    '--The capCreateCaptureWindow function creates a capture window--
    Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
       (ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
        ByVal x As Integer, ByVal y As Integer, _
        ByVal nWidth As Integer, _
        ByVal nHeight As Short, ByVal hWnd As Integer, _
        ByVal nID As Integer) As Integer

    '--This function sends the specified message to a window or
    ' windows--
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
       (ByVal hwnd As Integer, ByVal Msg As Integer, _
        ByVal wParam As Integer, _
        <MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) _
        As Integer

    '--Sets the position of the window relative to the screen buffer--
    Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
       (ByVal hwnd As Integer, _
        ByVal hWndInsertAfter As Integer, ByVal x As Integer, _
        ByVal y As Integer, _
        ByVal cx As Integer, ByVal cy As Integer, _
        ByVal wFlags As Integer) As Integer

    '--This function destroys the specified window--
    Declare Function DestroyWindow Lib "user32" _
       (ByVal hndw As Integer) As Boolean

    '---preview the selected video source---
    Private Sub PreviewVideo(ByVal pbCtrl As PictureBox)
        hWnd = capCreateCaptureWindowA(0, _
            WS_VISIBLE Or WS_CHILD, 0, 0, 0, _
            0, pbCtrl.Handle.ToInt32, 0)
        If SendMessage( _
           hWnd, WM_CAP_DRIVER_CONNECT, _
           0, 0) Then
            '---set the preview scale---
            SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
            '---set the preview rate (ms)---
            SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0)
            '---start previewing the image---
            SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
            '---resize window to fit in PictureBox control---
            SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, _
               pbCtrl.Width, pbCtrl.Height, _
               SWP_NOMOVE Or SWP_NOZORDER)
        Else
            '--error connecting to video source---
            DestroyWindow(hWnd)
        End If
    End Sub

    Private Sub Form1_Load( _
       ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles MyBase.Load
        PreviewVideo(PictureBox1)
    End Sub
)


^ basically after any sub-portion up here, I am receiving an "Expected end of statement"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 10:22 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
It's good you posted your code, and checked what ErrorLevel says. You should also try putting your code into a .vbs file and running it. It will give you the same result. This is because you are doing several things that may be allowed in VB6 and VBA, but are not allowed in VBScript, which is what ws4ahk uses.

I could try walking through your code and identifying all VBScript incompatibilities, but there is plenty of that information already available on the web :)

If you still have problems after you update the code, let me know.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 10:35 pm 
Quote:
Try this:
...


That worked fine, thanks Lexikos. Your work and patience never stop amazing me :)

However, GoogleEarthPhotoTag exif part will not work anyways because exiv2 does not support unicode.
Another similar app, Exiftool, faces the same problem:

Quote:
In Windows, ExifTool will not process files with Unicode characters in the file name. This is due to an underlying lack of support for Unicode filenames in the Windows standard C I/O libraries.


The only solution I can think of is to temporarily rename path and filename.

Quote:
why you need to run the GoogleEarthPhotoTag program with the new Authotkey_L (Unicode) instead of normal Autohotkey?

I've got a lot of folders and files named in 2 different (non-english) languages. Like many others I am just in need of unicode suport many times

Sorry for going offtopic


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 1:03 pm 
I need to pass 3 values to my vbs code.
These values will come from a GUI, how do I put them in the VBS ?

They are USERNAME, PASSWORD, IPADDDRESS

Code:
 #Include ws4ahk.ahk
 WS_Initialize()
 objSO := WS_CreateObject("SuperOffice.Application")
 WS_AddObject(objSO, "objSO")
    Code =
    (
      Set ado = CreateObject("ADODB.Connection")
      ado.Provider = "ADSDSOObject"
      ado.Properties("User ID") = "USERNAME"
      ado.Properties("Password") = "PASSWORD"
      serverName = "IPADDRESS:386"
    )


Thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 1:17 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Code:
 #Include ws4ahk.ahk
 WS_Initialize()
 objSO := WS_CreateObject("SuperOffice.Application")
 WS_AddObject(objSO, "objSO")
    Code =
    (
      Set ado = CreateObject("ADODB.Connection")
      ado.Provider = "ADSDSOObject"
      ado.Properties("User ID") = "%USERNAME%"
      ado.Properties("Password") = "%PASSWORD%"
      serverName = "%IPADDRESS%:386"
    )
It amy look bizzzare to use modulous to call variable within quote but it is the correct answer within a line continuation block

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 1:29 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
Woah tank, you're fast. I couldn't even login before you finished replying ;)

To add to tank's correct reply, here is a bit more.
Code:
 #Include ws4ahk.ahk
 WS_Initialize()
 USERNAME := "<something>"
 PASSWORD := "<something>"
 IPADDRESS := "<something>"
    Code =
    (
      Set objSO = CreateObject("SuperOffice.Application")
      Set ado = CreateObject("ADODB.Connection")
      ado.Provider = "ADSDSOObject"
      ado.Properties("User ID") = "%USERNAME%"
      ado.Properties("Password") = "%PASSWORD%"
      serverName = "%IPADDRESS%:386"
    )

I'm not sure why people seem to like to use WS_CreateObject() and WS_AddObject() when it's less error-prone to just create the object in VBScript directly.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 1:31 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
ha ha i didnt even look at that im still half asleep

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 1:41 pm 
erictheturtle wrote:
I'm not sure why people seem to like to use WS_CreateObject() and WS_AddObject() when it's less error-prone to just create the object in VBScript directly.


Thanks for the reply.

Can you please explain this ? thank you


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 1:51 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
tov wrote:
erictheturtle wrote:
I'm not sure why people seem to like to use WS_CreateObject() and WS_AddObject() when it's less error-prone to just create the object in VBScript directly.


Thanks for the reply.

Can you please explain this ? thank you


Your code
Code:
... objSO := WS_CreateObject("SuperOffice.Application")
 WS_AddObject(objSO, "objSO")
...

vs mine
Code:
...
      Set objSO = CreateObject("SuperOffice.Application")
...


Your code basically works as well as mine, but it's more typing (and yours will have a memory leak if you don't WS_Release()ing the created object on the AHK side). But I'm really just expressing my general surprise that so many people choose the approach that takes more typing and requires explicit memory management.

_________________
-m35


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 ... 10, 11, 12, 13, 14, 15, 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Stigg 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