Autoit - "possibly used before declaration" and "undeclared global variable" Compile Error - autoit

This is my first aproach to AutoIt and my apologies for the basic questions
I have an AutoIt program/code that is made of 2 .au3 files
1 - I would like to ask, how does that files work together (how they can be combined, if this is possbile) or are they supposed to be 2 seperate programs?
2 - When I run AutoIt3_x64, in one of them, I get the error
Line xxxx
Error: Variable used without being declared.
I have run Au3Stripper before compile and I got the followin errors/warning
-> 3 Change(s) made.
>Running AU3Check (3.3.14.5) from:C:\..\AutoIt3 input:C:\..\project.au3
"C:\..\project.au3"(203,110) : warning: $key: possibly used before declaration.
File($CommonFilesDir & "\" & $first_run, $CommonFilesDir & "\" & $first_run & $first_run, $key,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\..\project.au3"(203,110) : error: $key: undeclared global variable.
File($CommonFilesDir & "\" & $first_run, $CommonFilesDir & "\" & $first_run & $first_run, $key,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\..\project.au3"(273,32) : error: server(): undefined function.
$get_table = server()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\..\project.au3 - 2 error(s), 1 warning(s)
!>06:52:51 AU3Check ended. Press F4 to jump to next error.rc:2
+>06:52:51 AutoIt3Wrapper Finished.
What is causing these errors/warning and how can I fix it?
Thank you
EDIT:
Unfortunately, following the link sugestions, I didn't managed to succeed and for sure it's my fault. Th structure of the link exemple is diferente
one of the errors refers to this part of the code
if not FileExists($CommonFilesDir & "\" & $first_run & $first_run) Then
File($CommonFilesDir & "\" & $first_run, $CommonFilesDir & "\" & $first_run & $first_run, $key)
FileWrite($CommonFilesDir & "\" & $reverse_diskid, Get_Table())
FileDelete($CommonFilesDir & "\" & $first_run)
endif
I don't see how can I replicate the link suggestion

Related

Chilkat: $oImap.ListMailboxes - return "Null object"

I try to use IMAP object from Chilkat AcitveX component.
$oImap.Login($sImapUserName, $sImapPassword)
ConsoleWrite(#ScriptLineNumber & ' LOGIN: ' &$oImap.LastErrorText & #CRLF)
Returns:
Login:
DllDate: Sep 28 2020
ChilkatVersion: 9.5.0.84
UnlockPrefix: ******************
Architecture: Little Endian; 32-bit
Language: ActiveX
VerboseLogging: 0
loginX:
greeting: * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot (Debian) ready.
authenticateLogin:
loginImap:
ConnectionType: Unencrypted TCP/IP
--loginImap
isOK:
serverResponse: aaab OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY LITERAL+ NOTIFY SPECIAL-USE QUOTA] Logged in
--isOK
--authenticateLogin
--loginX
Success.
--Login
I use this snippet:
Local $s_refName = ''
Local $s_wildcardedMailbox = '*'
Local $oMBoxes = $oImap.ListMailboxes($s_refName, $s_wildcardedMailbox)
ConsoleWrite(#ScriptLineNumber & ' ' &$oImap.LastErrorText & #CRLF)
Returns:
ListMailboxes:
DllDate: Sep 28 2020
ChilkatVersion: 9.5.0.84
UnlockPrefix: *****
Architecture: Little Endian; 32-bit
Language: ActiveX
VerboseLogging: 0
listMailboxes:
bSubscribedOnly: 0
reference:
mailbox: *
Escaping quotes and backslashes in mailbox name...
utf7EncodedMailboxPath: *
isOK:
serverResponse: aaac OK List completed (0.016 + 0.000 + 0.015 secs).
--isOK
Success.
--listMailboxes
Success.
--ListMailboxes
Problem description:
I try to get Listboxes collection object but I do not get properly collections of objects.
If I check it like this:
ConsoleWrite('! ' & IsObj($oMBoxes) & #CRLF)
RESULT: ! 0
ConsoleWrite('! ' & VarGetType($oMBoxes) & #CRLF)
RESULT: ! Object
ConsoleWrite('! ' & $oMBoxes.Count)
RESULT: from COM Error Handler I get:
err.number is: 0x00000004
err.windescription: NULL Pointer assignment
eventually using diffrent version of AutoIt I get:
err.number is: 0x00000003
err.windescription: Object Invoke failed
Question:
Any idea of the cause of the problem?
Registering object by using:
regsvr32 ChilkatAx-9.5.0-win32.dll
Fix this issue.

Why Function "if ProcessExist" Don't Work in Others Computers

I'm trying to execute an IF ProcessExist.
in my win 10 64bit computer it works, but when i execute in other PC with win 7 or even with win 10. It do not execute.
#AutoIt3Wrapper_UseX64=N
If ProcessExists ("program.exe") Then
MsgBox ("", "Hold", "Test", 10)
Exit
Else
#RequireAdmin
Run(#ComSpec & " /c " & "C:\folder\file.bat", "", #SW_HIDE)
EndIf
Keep getting as if program.exe exist, but it's not.
#RequireAdmin must be on the very top of your script.
I assume it's not working when you compile the executable. It's probably called program.exe and it's finding its own process.
As for the Singleton see this:
_Singleton ( $sOccurrenceName [, $iFlag = 0] )
Enforce a design paradigm where only one instance of the script may be running
Example
#include <Misc.au3>
#include <MsgBoxConstants.au3>
If _Singleton("test", 1) = 0 Then
MsgBox($MB_SYSTEMMODAL, "Warning", "An occurrence of test is already running")
Exit
EndIf
MsgBox($MB_SYSTEMMODAL, "OK", "the first occurrence of test is running")

vtiger 7.1 installation error Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP

I am facing an issue in vtiger 7.1 installation
insted of setup page , it shows error page with this content
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; RecurringType has a deprecated constructor in /home/domainname/domains/domainfolder/public_html/vtigercrm/include/utils/RecurringType.php on line 16
error is generating because of invalid "error_reporting" variable in php.ini
as you may know , the required value of error_reporting for installing vtigercrm is "E_WARNING & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT"
so if current value is E_All or something else , In php.ini set "error_reporting" as below
error_reporting = E_WARNING & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
Add the following line in config.inc.php
ini_set('display_errors','on'); error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED & ~E_STRICT);
Or turn off error reporting:
error_reporting(0);

mruby-require error: NoMethodError: undefined method 'puts' for main

I managed to compile the mruby code adding the mrubygem - mruby-require from https://github.com/mattn/mruby-require
However when I try to call the require './' I get an error. Below is my code:
inc.rb
def test(a, b)
print "Inside the include->test(..)"
return a+b
end
test1.rb
require 'inc.rb'
def helloworld(var1)
print 'hello world ' + var1 + ". Test number = " + test(4, 5)
end
helloworld('test')
When I execute test1.rb I get this error from mruby:
NoMethodError: undefined method 'puts' for main
After some analysis I found out the 'puts' is not working with mruby. Infact after adding mruby-require gem, no ruby code gets execute. Do I need to add any dependency with mruby-require?
Can someone help me please?
Update: Pasting the content of build_config.rb as requested. I have removed the lines which are commented.
build_config.rb
MRuby::Build.new do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# adding the mruby-require library
conf.gem 'mrbgems/mruby-require'
conf.gembox 'default'
end
MRuby::Build.new('host-debug') do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
conf.gembox 'default'
conf.cc.defines = %w(ENABLE_DEBUG)
conf.gem :core => "mruby-bin-debugger"
end
The following quote is from its README.md:
When mruby-require is being used, additional mrbgems that appear after mruby-require in build_config.rb must be required to be used.
This is from your build_config.rb:
conf.gem 'mrbgems/mruby-require'
conf.gembox 'default'
The default gembox contains mruby-print. So either require mruby-print or preferably swap the lines to make it a built-in gem (the default behavior without mruby-require).

Autoit change name on window and use it in WinActivate

I have a function that starts some files and then change their names to their ids:
Global $PID2 = Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\Hub", $Hide)
WinWaitActive("C:\Windows\system32\java.exe")
WinSetTitle("C:\Windows\system32\java.exe","",$PID2)
Global $PID3 =Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\Survival", $Hide)
WinWaitActive("C:\Windows\system32\java.exe")
WinSetTitle("C:\Windows\system32\java.exe","",$PID3)
Global $PID4 =Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\KnarWorld", $Hide)
WinWaitActive("C:\Windows\system32\java.exe")
WinSetTitle("C:\Windows\system32\java.exe","",$PID4)
Global $PID5 =Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\Plotworld", $Hide)
WinWaitActive("C:\Windows\system32\java.exe")
WinSetTitle("C:\Windows\system32\java.exe","",$PID5)
Global $PID1 =Run("java " & $chosen & ' -jar "BungeeCord.jar"', 'E:\Spill\Alle spill\Minecraft\bungee', $Hide)
WinWaitActive("C:\Windows\system32\java.exe")
WinSetTitle("C:\Windows\system32\java.exe","",$PID1)
I also have a function to stop the files:
WinActivate($PID1)
Send("end {ENTER}")
WinActivate($PID2)
Send("stop{ENTER}")
WinActivate($PID3)
Send("stop{ENTER}")
WinActivate($PID4)
Send("stop{ENTER}")
WinActivate($PID5)
Send("stop{ENTER}")
The problem is on the second function that instead of finding the ids and sending the wanted commands one by one, it starts spamming in whatever window is active. How can I make it run once and stop, but still work if I trigger it again?
The whole code: http://pastebin.com/U8XBk4HE
For these kind of tasks there are two functions:
SendKeepActive(...) to make AutoIt to attempt to reset the active window in between each simulated keystroke from Send().
ControlSend(...) to send keystrokes to a specific window independently of it being active.
Maybe you should put a WinWaitActive to make it wait:
WinActivate($PID1)
WinWaitActive($PID1)
Send("end {ENTER}")

Resources