Quantcast
Channel: AutoIt v3 - Developer Chat
Viewing all 750 articles
Browse latest View live

winkill, send, winclose, controlclick etc. are not working

$
0
0

winkill, send, winclose, controlclick etc. are not working for my windows 7 system. I am making one old xp application (that is for checking the presence of some software in the machine) compatible with windows 7. In xp, all this function was working. But in windows 7 cert machine non of this is working. But i am sure this is not a problem with windows 7. Because all the above function is working for some application like notepad.


Need insight on AutoIt's support for PNGs

$
0
0

I'd like to get some insight and guidance from someone versed in the mechanics AU3’s support for images in PNG format.

 

I’ve used PNGs in various ways in AutoIt for years.  But I happened upon a case where a screen capture resulted in a PNG file that was over 2 megabytes. It seemed odd that a 1200x900 pixel image would be that large. Comparable images that I work with are always less than a megabyte ... usually, far less.  In fact, the efficiency of PNG (as a lossless format) has always impressed me.

 

So I searched the Au3 help and found a function I’ve never noticed:

_WinAPI_CompressBitmapBits() ... “Creates a compressed data block from the specified bitmap ($hBitmap)”

 

As a crude test, I added it to my script to post-process the 1200-pixel image and got an unexpected result: the PNG increased by 1000 bytes.

 

So I searched the Internet looking for insights and came to a rather comprehensive description of PNG:

http://www.libpng.org/pub/png/book/chapter01.html

 

Here are a couple of notable excerpts:

 

"Practically speaking, independent implementation of the deflate algorithm is both difficult and unnecessary. Almost every PNG implementation available today makes use of the freely available zlib compression library"

 

"Despite PNG's potential for excellent compression, not all implementations take full advantage of the available power. Even those that do can be thwarted by unwise choices on the part of the user."

 

And there are some really interesting points in these sections:

  1.2.4. Compression

  1.2.4.1. Compression filters

  1.2.4.2. Compression oopers

 

  9.4. Practical Compression Tips

  9.4.1. Tips for Users

  9.4.2. Tips for Programmers

 

So, I think my most-basic question is this:

Does _GDIPlus_ImageSaveToFile( "...png") apply a compression step?

 

And related:  Is there ever a reason to try to apply _WinAPI_CompressBitmapBits()?

If so, are there any examples of compressing images for PNGs in this manner?

 

Obviously, this can be quite involved ... a real forest of possibilities.  What I'm seeking is an efficient path through those woods.

 

Thanks in advance for any suggestions.

 

 

 

MSDN hates XP as much as I do

$
0
0

It appears that the MSDN site has given up totally on supporting XP or assisting those that are still on it. If you do a search for any control reference information on MSDN you'll see that almost all mention of XP has been expunged, and Vista is usually listed as the minimum supported client now. I noticed this the other day when looking up the EM_SETCUEBANNER information, and I've seen it on every listview variable/macro I've looked up as well. So, don't be surprised if you see topics with remarks that say such-and-such setting or variable doesn't work on XP because MSDN says it's Vista+.

 

Also, don't be surprised if in the future that some of the Windows APIs drop backwards compatibility for supposedly unsupported clients such as XP.

Details on how AutoIt handles fractional exponents.

$
0
0

I've implemented a certain algorithm which uses fractional exponents (PowF(float, float)) to calculate intermediate values.

 

Now I'm trying to convert this calculation (from AutoIt) to simple ASM instructions. Since PowF is quite a complex operation in ASM, because you have to balance instruction count and error (which should be less than 16bit precision in this case), I'd like to know more about the implementation of fractional exponents in AutoIt itself. The goal is to accurately recreate the results AutoIt would produce given the same input values :)

 

If there are multiple different ways each calculation is handled given the size of the exponent, I'll only need the details for n^{0.9..1.5}. My approach would be to use a simple cvtps2dq SSE cycle, but I'm curious  :sorcerer:

Location of language strings?

$
0
0

In looking into the way AutoIt3Wrapper inserts the language strings into the exe, I haven't been able to determine the source of the blocks of language strings ... IOW, the value of $InpResFile in the following snippet from the wrapper script:

        Case 6 ; RT_STRING             Local $aLangs = IniReadSectionNames($InpResFile)             If @error Then                 Write_RC_Console_Msg("Resource Update skipped: string file did not contain valid input", "", "+")                 Return             EndIf             ; loop each language section             Local $aStrings, $aBlocks, $aBlock             Local $iBlock, $iIdx, $iID, $sStr, $iBlockIdx             Local $iElem, $sStruct, $oStruct             For $i = 1 To $aLangs[0]                 ; aLangs[i] = current language                 $aStrings = IniReadSection($InpResFile, $aLangs[$i])

Would anyone happen to know its whereabouts?

 

Thanks for any help.

 

 

 

 

 

Communication with AutoIt and Java does not work

$
0
0

Hi,

 

I am developing a test framework for automated tests. For this my Java Code generates AutoIt-scripts. Additionally there are some cases, where static scripts are needed, for example to execute several .bat-files.

 

Here starts my problem.

 

At first I am using Java to call an AutoIt-script, which executes a "server-bat". This works pretty well.

After this I try to do the same with a "client-bat", what does not work.

 

So here is my code for the server part, which works:

 

Java:

Plain Text         
public static boolean startServer(String pathToServerFolder)     {         File f = new File(pathToServerFolder);         boolean fExists = f.exists();                 System.out.println("Does directory exist? " + fExists);                 try {             ProcessBuilder builder;                         List<String> commands = new ArrayList<String>();             commands.add(Paths.PATH_TO_ROOT_DIR + Paths.PATH_TO_SERVER_STARTER_SCRIPT);                         System.out.println("Execute Server-Starter-Script in " + Paths.PATH_TO_ROOT_DIR + Paths.PATH_TO_SERVER_STARTER_SCRIPT + " \nwith parameter " + pathToServerFolder);             commands.add("\"" + pathToServerFolder + "\"");                             builder = new ProcessBuilder(commands);             builder.redirectErrorStream(true);             Process process = builder.start();                         return true;                         } catch (IOException e) {                 // TODO Auto-generated catch block                 e.printStackTrace();                 return false;             }     }

and here is my really simple AutoIt-script for that part:

$path = $CmdLine[1] FileChangeDir($path) Run("start-server.bat")

That's all.

 

Following I will post the code, which does not work. I really don't know, why it doesn't work because it is really just copy&paste with some different values.

 

Java-Code of the not working client part:

Plain Text         
public static boolean startClient(String pathToClientFolder)     {         try {             ProcessBuilder builder;                         List<String> commands = new ArrayList<String>();             commands.add(Paths.PATH_TO_ROOT_DIR + Paths.PATH_TO_CLIENT_STARTER_SCRIPT);             System.out.println("Execute Client-Starter-Script in " + Paths.PATH_TO_ROOT_DIR + Paths.PATH_TO_CLIENT_STARTER_SCRIPT + " \n with parameter " + pathToClientFolder);             commands.add(" \"" + pathToClientFolder + "\"");                             builder = new ProcessBuilder(commands);             builder.redirectErrorStream(true);             Process process = builder.start();                         return true;                         } catch (IOException e) {                 // TODO Auto-generated catch block                 e.printStackTrace();                 return false;             }     }

and the AutoIt-Code:

$path = $CmdLine[1] FileChangeDir($path) Run("start-small-console.bat")

I think, that the error occurs, when I am giving the path as a parameter, because an AutoIt-Error-message says: "Error:Subscript used on non-accessible variable." on Line 2. Something must be wrong with the path. But as you can see I defined some printlns which are outputting the path. If I copy the paths from the output, and paste them into the Windows Explorer, it opens the correct directory or the correct .bat-file. This confuses me really, because it is exactly the same code as above, in the server part. I don't know what's wrong with the path, and I don't know, what it could be else.

 

I hope you guys are able to help me.

Thank.

Modularity: Local outside any function: modularity

$
0
0

As I understand it: there is no distinction, when a variable is declared outside any function, between declaring it Global and declaring it Local.

This is unfortunate when:

  • a project has several dialogs: declaration of control variables can conflict.
  • a project has one complex dialog

In the latter case, I have one here with a dialog function that is 269 lines!

 

I could declare all the control variables as Global, but globals should be aoided where possible.

 

I think good practice would be to put each dialog in its own file (unless it is a really simple one).

 

Life would be easier if there were a distinction in how variables are declared outside functions:

  • Global would mean the variable is known to all .au3 files in the project
  • Local would mean that the variable is known only within the file in which it is declared.

So control variables could then be declared as known to all functions in the file (module) by declaring them as Local outside any function. Other languages have this feature.

 

I am working on a project with one not-very-complex dialog. I would like to be able to split its 269 lines into several functions, e.g. the creation of the dialog, enabling/disabling controls based on a control, and updating the values of the controls due to user actions (in this case, a listview). I already have factored out into functions parts that do not involve control variables: verifications of user entries and actions when the user clicks on OK (or equivalents).

 

Would this be script-breaking change? Probably, but only for those who don't follow the best coding practices: as AutoIt is now, one should not be declaring variables as Local outside functions, because one gets Global anyway. There is nothing Local about a variable declared outside functions.

 

I will be interested to learn what others think. If this is an old topic, I apologize. If I have it wrong, do tell me.

 

 

 

Needing some Java help

$
0
0

Hey Guys,

 

So i've just implemented Jira at my work and was given the task of being system administrator and configuring everything which is good experience for me for coding somethign other than autoit/basic however i know nothing about java.

 

Would anyone be able to help me by adding that if the custom_field in this code is less than 0 , so a minus number to then change the value to 0? i also have more code to exclude weekends and only account for workdays but im not sure how to incorporate that either, if i paste that code too can anyone help me with that also if its not too much trouble.

<!-- @@Formula: if (issue.get("resolutiondate") == null || issue.get("customfield_10007")==null)   return null; return (issue.get("resolutiondate").getTime() - issue.get("customfield_10007").getTime()) / (1000*60*60*24);  -->

Also would anyone happen to have some good sites to help me learn some very basic java... i know theres nothing like this forum for any other language but any sort of materials to help me would be great, i am a complete noobie too it and i cant seem to get it right :(


Can't write DLL using __stdcall that works with AutoIt (__cdecl works)

$
0
0

Here's my situation: I've dinked around with trying to create a C++ object in AutoIt by matching the object declaration as a struct, and failed miserably.  No doubt it's because while I understand in principal what "BEGIN_INTERFACE" and "END_INTERFACE" do, I don't really know what they do in actual fact, and consequently I can't replicate that when designing an AutoIt struct.

 

So - I figured I'd write a C DLL that fronts and/or wrappers my C++ objects that will allow me to basically steer them from AutoIt.  To validate that I know WTF I'm doing, I figured I'd write a dead simple C++ object and wrapper functions that allow me to communicate back and forth.  I can get it all to work if I declare my wrappers as __cdecl, but I can't get it to work if they're declared __stdcall.  I'm compiling from mingw.

 

Keep in mind that the code below is only intended to validate my thoughts.  So I took some fairly obvious and glaring shortcuts with safety and etcetera because I'm simply validating that I can instantiate a C++ object, and then have it call back to my AutoIt code.  We're not necessarily interested in style. 

 

What I'm interested in is why AutoIt can't see the functions if they're declared __stdcall.  I must be blind, or too close to the problem, because I just can't see why it doesn't work.  If I alter everything to use __cdecl it all works swimmingly.  With it as is, I get the error printout below.

 

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Scripts\test.au3" /UserParams    
+>12:38:15 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper
>Running AU3Check (3.3.12.0)  from:C:\Program Files (x86)\AutoIt3  input:C:\Scripts\test.au3
+>12:38:15 AU3Check ended.rc:0
>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Scripts\test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
'init' not found in the DLL file
'add_callback' not found in the DLL file
'add_callback' not found in the DLL file
'add_callback' not found in the DLL file
'add_callback' not found in the DLL file
'uninit' not found in the DLL file
+>12:38:15 AutoIt3.exe ended.rc:0
+>12:38:15 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.533

 

 

All my code:

C++         
// File: test.h #ifndef _TEST_H_ #define _TEST_H_ #ifdef BUILDING_TEST_DLL #define TEST_DLL __declspec(dllexport) #else #define TEST_DLL __declspec(dllimport) #endif #ifdef __cplusplus extern "C" { #endif void __stdcall TEST_DLL init(void); void __stdcall TEST_DLL uninit(void); void __stdcall TEST_DLL add_callback(const void * callback); void __stdcall TEST_DLL do_callback(void); #ifdef __cplusplus } #endif #endif // _TEST_H_
C++         
// File: test.cpp #include <stdlib.h> #include <vector> #include "test.h" #define test_callback size_t class TestObject {     public:         void __stdcall AddCallback(const void * pCallback);         void __stdcall DoCallback(void);         TestObject();         ~TestObject();     private:         std::vector<const void *> m_pCallbacks;         size_t m_uiLastIndex; }; TestObject::TestObject() {     m_pCallbacks.reserve(10);     m_uiLastIndex = 0; } TestObject::~TestObject() {     // No action needed since vector cleans up } void __stdcall TestObject::AddCallback(const void * pCallback) {     if(pCallback) m_pCallbacks.push_back(pCallback); } void __stdcall TestObject::DoCallback(void) {     size_t (*callback) (size_t);     callback = (size_t(*)(size_t)) m_pCallbacks[m_uiLastIndex];     callback(m_uiLastIndex);     m_uiLastIndex++;     if(m_uiLastIndex > (m_pCallbacks.size() -1)) {         m_uiLastIndex = 0;     } } // C Wrapper functions TestObject * test_object; void __stdcall init() {     test_object = new TestObject(); } void __stdcall TEST_DLL uninit(void) {     delete test_object; } void __stdcall TEST_DLL add_callback(const void * callback) {     test_object->AddCallback(callback); } void __stdcall TEST_DLL do_callback(void) {     test_object->DoCallback(); }
AutoIt         
OnAutoItExitRegister("TestDone") Local $func_template = "CallBack%d" Local $handles[4] Local $pointers[4] Local $dll = DllOpen("test.dll") DllCall($dll, "NONE", "init") If @error Then     TranslateDllCallError(@error, "init") EndIf For $i = 0 To UBound($handles) - 1     Local $name = StringFormat($func_template, ($i + 1))     $handles[$i] = DllCallbackRegister($name, "ULONG_PTR", "ULONG_PTR")     $pointers[$i] = DllCallbackGetPtr($handles[$i])     DllCall($dll, "NONE", "add_callback", "PTR", $pointers[$i])     If @error Then         TranslateDllCallError(@error, "add_callback")     Else         ConsoleWrite("Added pointer " & $i & @LF)     EndIf Next For $i = 1 To 10     DllCall($dll, "NONE", "do_callback") Next Func TranslateDllCallError($err, $func)     Switch $err         Case 1             ConsoleWriteError("Unable to use DLL file" & @LF)         Case 2             ConsoleWriteError("Unknown 'return type'" & @LF)         Case 3             ConsoleWriteError("'" & $func & "' not found in the DLL file" & @LF)         Case 4             ConsoleWriteError("Bad number of parameters" & @LF)         Case 5             ConsoleWriteError("Bad parameter" & @LF)         Case Else             ConsoleWriteError("Unknown error value" & @LF)     EndSwitch EndFunc Func CallBack1($param)     ConsoleWrite("CallBack1(" & $param & ")" & @LF)     Return $param EndFunc Func CallBack2($param)     ConsoleWrite("CallBack2(" & $param & ")" & @LF)     Return $param EndFunc Func CallBack3($param)     ConsoleWrite("CallBack3(" & $param & ")" & @LF)     Return $param EndFunc Func CallBack4($param)     ConsoleWrite("CallBack4(" & $param & ")" & @LF)     Return $param EndFunc Func TestDone()     For $i = 0 To UBound($handles) - 1         DllCallbackFree($handles[$i])     Next     DllCall($dll, "NONE", "uninit")     If @error Then         TranslateDllCallError(@error, "uninit")     EndIf     DllClose($dll) EndFunc
:: build.bat @echo off IF EXIST *.dll DEL *.dll IF EXIST *.o DEL *.o IF EXIST *.a DEL *.a g++ -Wall -c -DBUILDING_TEST_DLL test.cpp g++ -shared -o test.dll -static-libgcc -static-libstdc++ test.o -Wl,--out-implib,libtest_dll.a

What Language Was Autoit Coded With?

$
0
0

Anyone know what language Autoit V3 was coded in? Im very curious and can't find an answer.

Viewing all 750 articles
Browse latest View live