Jump to content
Sign in to follow this  
Fugo

I need some kind soul to help me on this one please

Recommended Posts

Fugo

Hello autoit community

I have a bunch of code from a friend who I asked for help on how to open files from a Logitech G13 script.

He said the G13 cant open files from it's inbuilt scripting engine, but it can output a Debug message and use autoit to capture that message and open the file. Problem though is hes a bizzy man and cant help me get the autoit script working for me.

This is the first time I've even opened autoit so I am less than useless at editing this code, but I do need it very badly indeed.

This is what I get when I try running it:

Line 43

If $ipRun Then

If ^ ERROR

Error:Variable used without being declared

And the full script:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\..\..\..\..\Program Files (x86)\AutoIt3\Aut2Exe\Icons\AutoIt_Main_v10_256x256_RGB-A.ico
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Misc.au3>
#include <GUIConstants.au3>
#include <Array.au3>
#include "DebugCapture.au3"

$MainForm = GUICreate("LogiServer", 300, 100) ; will create a dialog box that when displayed is centered.

$label = GUICtrlCreateLabel("LogiServer is a utility to allow Logitech Lua scripts to perform file operations as well as anything else AutoIt allows.", 5,5, 260, 40)
$close = GUICtrlCreateButton ("Close", 225, 70, 70) ; this creates the button, the first text is what is displayed on the button.
; the second is how far from the left, the third how far from the top, fourth is how long the button is.

GUISetState ()   ; will display dialog box;

Global $file

$dll = DllOpen("user32.dll")
$serverID = "LogiServer"

; Global variables for DebugCapturing
Global $strData

StartCapture()

GUISetState(@SW_MINIMIZE)

Global $timeSeed = TimerInit()

; Run the GUI until the dialog is closed.
While 1
$msg = GUIGetMsg() ; this checks for a message/input from the GUI.

If $msg = $GUI_EVENT_CLOSE or $msg = $close Then ExitLoop ; this states, on an exit event, exit the loop.

$strData = _GetDebugOutput()
If (Not @error) And ($strData <> "") Then
ExecuteString($strData)
EndIf

If $ipRun Then
ip_CheckIsPressed()
ip_CheckTimeout()
EndIf

Sleep(1)
Wend

StopCapture()

DllClose( $dll )

func ExecuteString($str)
; $str from game should include a $gameID, a command, and possibly a string to go with the command
; commands can be:
; FileOpen: filename: mode
; FileClose
; FileWrite: string
; FileDelete: filename
;
; mode can be: Overwrite, Append

local $s = StringSplit( $str, "|")
if $s[0] > 1 and $s[1] = $serverID Then
; MsgBox(0,"String", $str)
switch $s[2]
case "FileOpen"
if $s[4] = "Overwrite" Then
$file = fileopen( $s[3], 2)
elseif $s[4] = "Append" Then
$file = fileopen( $s[3], 1)
Else
msgbox(1, "ExecuteString($str)", "Improper FileOpen mode")
Return
EndIf
if $file = -1 Then
msgbox(1, "ExecuteString($str)", "Error Opening File: " & $s[3])
endif
case "FileClose"
if $file = -1 Then
msgbox(1, "ExecuteString($str)", "File to be closed is not open")
Else
fileClose( $file )
EndIf
case "FileWrite"
if $file = -1 Then
msgbox(1, "ExecuteString($str)", "File to be written to is not open")
Else
filewrite( $file, $s[3] )
EndIf
Case "FileDelete"
FileDelete( $s[3] )
Case "QuickFileWrite" ; arguments are: FileName, mode, text
logi_QuickFileWrite( $s[3], $s[4], $s[5] )
Case Else
msgbox(1, " ExecuteString($str) Error", "Do not know how to handle: " & $str)
EndSwitch
EndIf
Sleep(1) ; delay to prevent handling files to rapidly
EndFunc

Func StartCapture()
_StartDebugCapture()

Switch @error
Case 0
; do nothing, previously interacted with GUI
Case 1
MsgBox(16, @ScriptName, "Error loading DebugCapture.dll", 0, $MainForm)
Case 2
MsgBox(16, @ScriptName, "Initialization failed.", 0, $MainForm)
Case 3
MsgBox(64, @ScriptName, "Another debugger is already active.", 0, $MainForm)
EndSwitch
EndFunc

Func StopCapture()
_StopDebugCapture()
EndFunc

Func logi_QuickFileWrite( $filename, $mode, $string )
Local $file

if $mode = "Overwrite" Then
$file = fileopen( $filename, 2 )
elseif $mode = "Append" Then
$file = fileopen( $filename, 1)
Else
msgbox(1, "logi_QuickFileWrite( $filename, $mode, $string )", "Improper FileOpen mode")
Return
EndIf
if $file = -1 Then
msgbox(1, "logi_QuickFileWrite( $filename, $mode, $string )", "Error Opening File: " & $filename)
Else
FileWrite( $file, $string )
FileClose( $file )
endif
EndFunc

Func logi_ClearFlag( $flagFilename, $flagVar )
logi_QuickFileWrite( $flagFilename, "Overwrite", $flagVar & " = nil" & @LF)
EndFunc

Func logi_SetFlag( $flagFilename, $flagVar )
logi_QuickFileWrite( $flagFilename, "Overwrite", $flagVar & " = true" & @LF)
EndFunc

Func msg($text)
MsgBox( 0, "TEST", $text)
EndFunc

Func GetRunningTime()
return TimerDiff( $timeSeed )
EndFunc

I also need what type of message to send to Debug

fileopen: D\ll.project\working\vocal.wma

Would that execute the file I need?

I dont need this to send a message back to Debug after autoit is done with a command, only receive.

You also need the DebugCapture API for AutoIt. Be warned, win compiling, you need to use the 32 bit version. It will not work with the 64bit compiler.

Quote from him and I have done so.

Anyhelp you can provide, I will be in your debt for life.

Share this post


Link to post
Share on other sites
Jos

Line 43

If $ipRun Then

If ^ ERROR

Error:Variable used without being declared

I would say this is pretty descriptive. Where is this variable supposed to be defined?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Fugo

Ah the best I can do is quote him again

I sent you the basics of what I wrote in a private message. I had to cut out the parts that read normal key presses, because that requires it to send info back to the Lua script and requires handling on the Lua script side to work. Hopefully it still works in the form i sent it as.

I'm hoping
If $ipRun then
variable was defined in normal key presses.

Though I realy dont know.

Share this post


Link to post
Share on other sites
kylomas

Fugo,

Where is the include " "DebugCapture.au3"? I suspect that you are getting several errors.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
kylomas

Fugo,

You may want to read the forum riles. This line

; $str from game should include a $gameID, a command, and possibly a string to go with the command

raises flags.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Jos

Ah the best I can do is quote him again

I'm hoping

If $ipRun then
variable was defined in normal key presses.

Though I realy dont know.

So tell me why we should put in any effort when you aren't? ;)

Either way.. read the rules before continuing posting questions at these forum.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Fugo

So tell me why we should put in any effort when you aren't? ;)

Excuse me?

Just said I was a first time user with a bunch of code handed to me, tryed it didn't work thought I'd see if anyone can explain why it doesn't here.

And effort?

Wile not to do with autoit I have spent along time comming from no code experiance to working with Lua.

I see functions in this script and I belive Wile-Wend is loop, but it's like trying to read another language for the first time. I need point and tell from people who reads and writes autoit to get a good head start learning.

So why are you so rude?

; $str from game should include a $gameID, a command, and possibly a string to go with the command

This though I saw after I posted , GameID looked funny to me but I didn't know why Lua has nothing like this but to be honest I dont want this script for games, I'm not a gamer.

Anyway if you are a developer and happy with your comments I'll stay away from 'General Help and Support' as it doesn't apply here.

Share this post


Link to post
Share on other sites
Melba23

Fugo,

You appear not to understand the bit in the Forum Rules that tells you that any script involving game interaction is not permitted here. Whether you intend to use it for such purposes or not is immaterial - please find another example to learn from. I am locking this thread - make sure you read those rules before posting again. :naughty:

And I will leave it up to Jos to decide how to deal further with you. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×