Sign in to follow this  
Followers 0
redcrusher

iniWrite

17 posts in this topic

Why does this not work... it says it expects an "="

VB6

Dim au3 As AUTOITX3
au3.IniWrite(app.Path & "\fishing.ini", "Vars2", "Cursor", "1")

--redcrusher

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try:

Dim au3 As AUTOITX3
Dim iResult as integer
iResult = au3.IniWrite(app.Path & "\fishing.ini", "Vars2", "Cursor", "1")

or, thinking about it more:

Dim au3 As AUTOITX3
au3.IniWrite app.Path & "\fishing.ini", "Vars2", "Cursor", "1"

Brackets imply a function, rather than sub.

Edited by Stumpii

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try:

Dim au3 As AUTOITX3
Dim iResult as integer
iResult = au3.IniWrite(app.Path & "\fishing.ini", "Vars2", "Cursor", "1")

or, thinking about it more:

Dim au3 As AUTOITX3
au3.IniWrite app.Path & "\fishing.ini", "Vars2", "Cursor", "1"

Brackets imply a function, rather than sub.

it is not writing... for some reason... i get no error, but it is not writing anthing...

have any ideas?

--redcrusher

Edited by redcrusher

Share this post


Link to post
Share on other sites

i keep getting the integer back as "0"... what is wrong?

--redcrusher

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

(a) Failure: Returns 0 if file is read-only. So it is a function.

(be) what is the filename? i.e. what is app.Path, is it valid, and I would TRY, at this time, to write to "c:\myfile.ini"

Edited by PeterSwiss

Share this post


Link to post
Share on other sites

Note the following that may be of use:

App.Path returns a string with the "\" character at the end if the path is the root drive (e.g., "C:\") but without that character if it isn't (e.g., "C:\Program Files"). So your code will not work if you are testing it with a file in the root.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

i tryed "C:\testing.ini" , but it still dodn't work... any other ideas?

maybe you could make a VB6 program that would iniwrite and then post the form code.

--redcrusher

Edited by redcrusher

Share this post


Link to post
Share on other sites

Dim au3 As AUTOITX3

(a) I don't understand above Dim statement

(be) I tried the following, in Javascript, in a file named "xyz".js with positive result:

var ws = WScript; //WSH Grundobjekt

var autoit = WScript.CreateObject("AutoItX3.Control"); //AutoIt V3 Objekt

v = new Date();

ws.echo(v);

var err;

err=autoit.IniWrite ("c:\inifile.ini","mysection","myvalue","20");

err=autoit.IniWrite ("c:\inifile.ini","mysection","myvalue1",30);

err=autoit.IniWrite ("c:\inifile.ini","Vars2", "Cursor", "1");

ws.echo("err="+err);

ws.Quit();

.

Share this post


Link to post
Share on other sites

zip and post your entire VB program so we can look at it.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Here is the code

Option Explicit
Dim au3 As AutoItX3
Dim iResult As Integer

Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Type PCURSORINFO
    cbSize As Long
    flags As Long
    hCursor As Long
    ptScreenPos As POINTAPI
End Type
'To grab cursor shape -require at least win98 as per Microsoft documentation...
Private Declare Function GetCursorInfo Lib "user32.dll" (ByRef pci As PCURSORINFO) As Long
'To get a Handle to the cursor
Private Declare Function GetCursor Lib "USER32" () As Long
'To draw cursor shape on bitmap
Private Declare Function DrawIcon Lib "USER32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
     
'to get the cursor position
Private Declare Function GetCursorPos Lib "USER32" (lpPoint As POINTAPI) As Long
'to end a waiting loopp
Dim GotIt As Boolean
'To use the scrollbars
Dim lngVer As Long
Dim lngHor As Long
Const iconSize As Integer = 9
Dim TxtPathName As String
Dim TxtPathName2 As String


Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long 'use GetPixel API
'used to indicate pixel location
Dim Pix1 As Long
Dim Pix2 As Long





Private Sub Form_Load()
    Set PicFish.Picture = LoadPicture(App.Path & "\fish.bmp")
End Sub

Private Sub TCapture_Timer()
   
   'disable timer
   TCapture.Enabled = False
   
   Set PicCapture.Picture = PicBlank.Image
   
   
   'now to get the icon of mouse and paint on form the mouse
   Dim pcin As PCURSORINFO
   pcin.hCursor = GetCursor
   pcin.cbSize = Len(pcin)
   Dim ret
   ret = GetCursorInfo(pcin)
   DrawIcon PicCapture.hdc, 12 - iconSize, 12 - iconSize, pcin.hCursor
   'The following paint only mouse shape for this app
   'DrawIcon PicCapture.hdc, Point.x - iconSize, Point.y - iconSize, CopyIcon(GetCursor)
   'assign to picture the image
   Set PicCapture.Picture = PicCapture.Image
   'clear clipboard here if you can
   On Error Resume Next
   Clipboard.Clear
   'signal you've done to exit the waiting loop
   GotIt = True
   
   Pix1 = GetPixel(PicCapture.hdc, 5, 5) 'get pixel at (5 x 5 y)
   Pix2 = GetPixel(PicFish.hdc, 5, 5) 'get pixel at (5 x 5 y)
   
   If Pix1 = Pix2 Then
        lblYAY = lblYAY.Caption + 1
        Dim mousex As Double
        Dim mousey As Double
        mousex = au3.MouseGetPosX
        mousey = au3.MouseGetPosY
        iResult = au3.IniWrite("C:\test.ini", "Vars2", "Cursor", "1")
        Me.Caption = iResult
        
        
   End If
   
   lblTimes = lblTimes.Caption + 1
   TCapture.Enabled = True
   
   'TxtPathName = "./" & lblTimes.Caption & "aaScreen.bmp"
   'SavePicture PicCapture.Image, TxtPathName
   
End Sub

--redcrusher

Share this post


Link to post
Share on other sites

Can you post the actual project. That way we can see if you have valid references to the AutoItX dll.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Don't worry, try this:

Dim au3 As New AutoItX3

instead of

Dim au3 As AutoItX3

I get an error 91 with your code. I don't know why you do not get it.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Don't worry, try this:

Dim au3 As New AutoItX3

instead of

Dim au3 As AutoItX3

I get an error 91 with your code. I don't know why you do not get it.

yay it works great now !!! THANKS A LOT GUYS !

--redcrusher

Share this post


Link to post
Share on other sites

No problem.

You need to investigate how you have VB setup. You should have got the error that I did, which imediatly indicated what the problem was. Under Tools>Options, you may have 'Break on unhandled errors' selected, which along with the 'On error resume' code you have, could cause this. Not a very good thing to do, as this hidden error shows.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Dim au3 As New AutoItX3

What else was needed to make "new AutoITX3" legal? instead of "AutoItX3.Control" as in VBS, JS? Question is simply from a non VB knower.

Thanks,

Peter

Share this post


Link to post
Share on other sites

What else was needed to make "new AutoITX3" legal? instead of "AutoItX3.Control" as in VBS, JS? Question is simply from a non VB knower.

Thanks,

Peter

VB allows you to create a reference to a control at design time, through the IDE as well as at runtime. The advantage of this is that the IDE can then expose all the methods, propertites and events for you to program with. In this way VB already knows what AutoITX3 is and where the dll is located.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

VB allows you to create a reference to a control at design time, through the IDE as well as at runtime. The advantage of this is that the IDE can then expose all the methods, propertites and events for you to program with. In this way VB already knows what AutoITX3 is and where the dll is located.

Thanks!!

Peter

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