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

framework/web interface to CouchDB, can suggest me?

$
0
0

Hi

 

Someone can suggest to me, a easy framework to buid a web interface to CouchDB?

 

Regards,

Detefon


Windows forms

$
0
0

Is it just me or are C# windows forms a bit shit.

 

I was looking for a particular look for my form, in my head it was resizeable with a thin border, but all the sizeable styles have huge fat borders.

 

Does anyone know of a way to get a thin border on a sizeable form?

neutralize keystrokes?

$
0
0

Running the script provided in the help file related to the "_WinAPI_SetWindowsHookEx" function, It seems that the keystrokes are retained(?) by the _KeyProc() function during the elaboration, and displayed into the InputBox only after(?) the returning from that function.
 I was wondering if could be possible in some way, neutralize some keys and throw them away before that them are showed  in the InputBox.
The purpose of this, is the possibility to use some InputBox allowing only the entering of certain chars and disallow some others. For example if I have an InputBox where must be entered an HEX number, I would allow only keystrokes from 0 to 9 and from A to F, neutralizing all others (but Tab anf CR).

Thanks in advance for any suggestion

 

here a little modified version of the script provided in the help file, that use an InputBox instead of Notepad.

AutoIt         
#include <MsgBoxConstants.au3> #include <StructureConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $g_hHook, $g_hStub_KeyProc, $g_sBuffer = "" Example() Func Example()     OnAutoItExitRegister("Cleanup")     Local $hMod     $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")     $hMod = _WinAPI_GetModuleHandle(0)     $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod)     GUICreate('Test ')     $Input1 = GUICtrlCreateInput("", 8, 8, 105, 21)     GUISetState(@SW_SHOW)     While 1         Sleep(10)     WEnd EndFunc   ;==>Example Func EvaluateKey($iKeycode)     If (($iKeycode > 64) And ($iKeycode < 91)) _ ; a - z             Or (($iKeycode > 96) And ($iKeycode < 123)) _ ; A - Z             Or (($iKeycode > 47) And ($iKeycode < 58)) Then ; 0 - 9         $g_sBuffer &= Chr($iKeycode)         Switch $g_sBuffer             Case "Jon"                 ToolTip("What can you say?")             Case "AutoIt"                 ToolTip("AutoIt Rocks")         EndSwitch     ElseIf ($iKeycode > 159) And ($iKeycode < 164) Then         Return     ElseIf ($iKeycode = 27) Then ; esc key         Exit     Else         $g_sBuffer = ""     EndIf EndFunc   ;==>EvaluateKey ; =========================================================== ; callback function ; =========================================================== Func _KeyProc($nCode, $wParam, $lParam)     Local $tKEYHOOKS     $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)     If $nCode < 0 Then         Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)     EndIf     If $wParam = $WM_KEYDOWN Then         EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))     Else         Local $iFlags = DllStructGetData($tKEYHOOKS, "flags")         Switch $iFlags             Case $LLKHF_ALTDOWN                 ConsoleWrite("$LLKHF_ALTDOWN" & @CRLF)             Case $LLKHF_EXTENDED                 ConsoleWrite("$LLKHF_EXTENDED" & @CRLF)             Case $LLKHF_INJECTED                 ConsoleWrite("$LLKHF_INJECTED" & @CRLF)             Case $LLKHF_UP                 ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @CRLF)         EndSwitch     EndIf     Return  _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndFunc   ;==>_KeyProc Func Cleanup()     _WinAPI_UnhookWindowsHookEx($g_hHook)     DllCallbackFree($g_hStub_KeyProc) EndFunc   ;==>Cleanup

$text = _GUICtrlListView_GetItemText($hListView, 1, 1) ; here always return null both on x86 or x64,

$
0
0

$hListView = ControlGetHandle($handle,"","SysListView321")

$text = _GUICtrlListView_GetItemText($hListView, 1, 1)  ; here always return null both on x86 or x64,

 

Anyone can help me? thx!!!!!!!!!!!

 

the information of target listview as following

 

 

>>>> 窗口 <<<<
标题: 遗传算法 属性
类名: #32770
坐标: 119, 135
大小: 672, 545
样式: 0x94CC2044
扩展样式:0x00010501
句柄: 0x014D1380
 
>>>> 控件 <<<<
类名: SysListView32
实例: 1
类别名: SysListView321
名称:
高级(类名):[CLASS:SysListView32; INSTANCE:1]
ID: 2140
文本:
坐标: 21, 39
大小: 615, 400
控件点击坐标:213, 168
样式: 0x50011C05
扩展样式:0x00000204
句柄: 0x00A21036
 
>>>> 鼠标 <<<<
坐标: 361, 372
光标ID: 0
颜色: 0xFFFFFF
 
>>>> 状态栏 <<<<
 
>>>> 工具栏 <<<<
 
>>>> 可见文本 <<<<
模拟数目: 1
确定
取消
 
 
>>>> 隐藏文本 <<<<
CustomCombo
.45
CustomCombo

How to obtain the owner of a Hotkey?

$
0
0

After searching the forum and MSDN, I believe that is it not possible to obtain the owner of a hotkey.

To enhance my _Hotkey() function (see here), I would like to show the owner of a hotkey, if Hotkeyset() fails.

I believe to the power of the developers to make the impossible possible. 

I prepared a skeleton script to start with.

Just the last function _HotkeyOwner() needs some tweaks.

AutoIt         
;~ Hotkey checker #include <WinAPI.au3> _HotKey("{ESC}") _HotKey("{F12}") Func _HotKey($hotkey = "")     Switch @HotKeyPressed         Case "{ESC}"             Exit MsgBox(64 + 262144, Default, "Exit", 1)         Case "{F12}"             Beep()         Case Else             If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed)             If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application." & @LF & "Error: " & @error & " Extented: " & @extended & @LF & "Lasterror: " & _WinAPI_GetLastErrorMessage() & @LF & _HotkeyOwner($hotkey))     EndSwitch EndFunc   ;==>_HotKey While Sleep(100) ; here should be your application. WEnd ; meanwhile, here is a dummy loop. Func _HotkeyOwner($hotkey)     Return "No Hotkeyowner detected for hotkey " & $hotkey EndFunc   ;==>_HotkeyOwner

Please confirm, that there is no solution   :  or better, ... show me the impossible. :thumbsup:

Thanks Exit

GetLocaleInfoEx ?

$
0
0

I had a need to play a little "Locale" game today, and saw in MS documentation the GetLocaleInfoEx function. but no luck finding it, not even mentioned a single time here on the forums.

 

is there a good reason why it's not already in WinApiLocale.au3 ?

 

This is not bashing on anyone for their oversight, just curious really.

Also does not seem to be in WinAPIEx.au3.

 

There are others similar functions missing.

Oh, and I would contribute if I only had the ability... :(

 

Thanks to contributors to WinAPI and related for what you have already done.!

User Javascript Context trouble, chromium/firefox greasemonkey

$
0
0

I don't know where else to ask, and I've been here more than other places so I assume maybe there is someone who's experienced an issue I just stumbled into while developing a user javascript file..

 

I created a simple extension for a website, rather large actually.. I was testing it on Firefox during its development using greasemonkey and everything worked well, I could access variables created by scripts delivered by the site in the context of the window and listen to fired off events created by another jquery script in the window, but when I attempted to use it in chromium by dragging dropping file called "script.user.js" into extensions window, somehow chromium seems to not allow the script to interact with the variables of the other script, I cannot listen to events or use the existing jquery that is in the sites main scripts, I have to manually include my own copy of jquery,

 

chromium somehow does it so that the scritp has its own context to the window and does not allow it to interact with the context of the other script... This is strange. Greasemonkey under firefox does not do this though and seems it is more lenient on permissions...

 

This has complicated development of the script to keep it comparable on both browsers. Does anyone know what can be done to make chromium allow the script to "see"  and interact with the other scripts that are delivered server side? I'm not sure if this is a good explanation, I hope you can understand.

 

tl;dr somehow chromium does not let a userscript file access variables outside of the script file in a webpage while firefox does, any fix to this?

Extract icon's from almost any file (exe,lnk,......)

$
0
0

This is written in c# maybe it can be implemeted in autoit.

Or if some one has time and can transfer this to autoit code?

For now i use it this way and on a later time i try to transfer it to autoit code.

C#         
using System; using System.IO; using System.Threading; using System.Drawing; using System.Runtime.InteropServices; namespace Icon_extractor {     class Program     {         static void Main(string[] args)         {             switch (args.Length)             {                 case 0:                     uitleg();                     break;                 case 1:                     if (args[0] == "/?")                     {                         uitleg();                     }                     break;                 case 4:                     Icon myIcon = Getpicture(Convert.ToString(args[0]), Convert.ToBoolean(args[1]));                     if (Convert.ToBoolean(args[3]))                     {                         Bitmap bmp = myIcon.ToBitmap();                         using (FileStream fs = new FileStream(Convert.ToString(args[2]) + ".bmp", FileMode.Create)) bmp.Save(fs, System.Drawing.Imaging.ImageFormat.Bmp);                     }                     else                     {                         using (FileStream fs = new FileStream(Convert.ToString(args[2]) + ".ico", FileMode.Create)) myIcon.Save(fs);                     }                     break;             }         }         static Icon Getpicture(string fName, Boolean smallicon)         {             Shfileinfo shinfo = new Shfileinfo();             //Use this to get the small Icon             if (smallicon)             {                 IntPtr hImgSmall = Win32.SHGetFileInfo(fName, 0, ref shinfo,                                                        (uint)Marshal.SizeOf(shinfo),                                                        Win32.ShgfiIcon |                                                        Win32.ShgfiSmallicon);             }             else             {                 //Use this to get the large Icon                 IntPtr hImgLarge = Win32.SHGetFileInfo(fName, 0,                                                        ref shinfo, (uint)Marshal.SizeOf(shinfo),                                                        Win32.ShgfiIcon | Win32.ShgfiLargeicon);             }             //The icon is returned in the hIcon member of the shinfo             //struct             return Icon.FromHandle(shinfo.hIcon);         }         private static void uitleg()         {             Console.WriteLine("extract icon to .ico file");             Console.WriteLine("1st parameter file to extract");             Console.WriteLine("2de parameter true = small false = big icon");             Console.WriteLine("3de parameter place and name to save with give no extension");             Console.WriteLine("3de parameter true = bmp  false = ico");             Thread.Sleep(10000);         }     }     [StructLayout(LayoutKind.Sequential)]     public struct Shfileinfo     {         public IntPtr hIcon;         public IntPtr iIcon;         public uint dwAttributes;         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]         public string szDisplayName;         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]         public string szTypeName;     };     class Win32     {         public const uint ShgfiIcon = 0x100;         public const uint ShgfiLargeicon = 0x0;    // 'Large icon         public const uint ShgfiSmallicon = 0x1;    // 'Small icon         [DllImport("shell32.dll")]         public static extern IntPtr SHGetFileInfo(string pszPath,                                     uint dwFileAttributes,                                     ref Shfileinfo psfi,                                     uint cbSizeFileInfo,                                     uint uFlags);     } }

Convert C# into autoit

$
0
0
HELLO:
Convert C# into autoit, can you help? , can you help? Example of this is a PDF conversion to Image, calls the DLL file
 
C#         
  1. using System;
  2. using System.Configuration;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Runtime.InteropServices;
  6. using System.Windows.Forms;
  7. using System.Drawing.Imaging;
  8. using System.Diagnostics;
  9.  
  10. namespace Acrobat.pdf2image
  11. {
  12.     public class Program
  13.     {
  14.         /// <summary>
  15.         /// PDF Document transformation method for the picture
  16. ,method:ConvertPDF2Image("F:\\A.pdf", "F:\\", "A", 0, 0, null, 0);
  17.         /// default value
  18. ,startPageNum  default value
  19. =1,endPageNum  default value is the total number of pages
  20.         /// imageFormat default value =ImageFormat.Jpeg,resolution  default value = 1
  21.         /// </summary>
  22.         /// <param name="pdfInputPath">PDF file path
  23. </param>
  24.         /// <param name="imageOutputPath">image Output Path</param>
  25.         /// <param name="imageName">imageName,Do not need to bring the extension
  26. </param>
  27.         /// <param name="startPageNum">startPage number,default value
  28. =1</param>
  29.         /// <param name="endPageNum">endPage number,default value= PDF Total number of pages
  30. </param>
  31.         /// <param name="imageFormat">imageFormat</param>
  32.         /// <param name="resolution">resolution,The greater the number the more clear
  33. default value
  34. =1</param>
  35.         public static void ConvertPDF2Image(string pdfInputPath, string imageOutputPath,
  36.             string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, double resolution)
  37.         {
  38.             Acrobat.CAcroPDDoc pdfDoc = null;
  39.             Acrobat.CAcroPDPage pdfPage = null;
  40.             Acrobat.CAcroRect pdfRect = null;
  41.             Acrobat.CAcroPoint pdfPoint = null;
  42.  
  43.             // Create the document (Can only create the AcroExch.PDDoc object using late-binding)
  44.             // Note using VisualBasic helper functions, have to add reference to DLL
  45.             pdfDoc = (Acrobat.CAcroPDDoc)Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.PDDoc", "");
  46.  
  47.             // validate parameter
  48.             if (!pdfDoc.Open(pdfInputPath)) { throw new FileNotFoundException(); }
  49.             if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
  50.             if (startPageNum <= 0) { startPageNum = 1; }
  51.             if (endPageNum > pdfDoc.GetNumPages() || endPageNum <= 0) { endPageNum = pdfDoc.GetNumPages(); }
  52.             if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
  53.             if (imageFormat == null) { imageFormat = ImageFormat.Jpeg; }
  54.             if (resolution <= 0) { resolution = 1; }
  55.  
  56.             // start to convert each page
  57.             for (int i = startPageNum; i <= endPageNum; i++)
  58.             {
  59.                 pdfPage = (Acrobat.CAcroPDPage)pdfDoc.AcquirePage(i - 1);
  60.                 pdfPoint = (Acrobat.CAcroPoint)pdfPage.GetSize();
  61.                 pdfRect = (Acrobat.CAcroRect)Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.Rect", "");
  62.  
  63.                 int imgWidth = (int)((double)pdfPoint.x * resolution);
  64.                 int imgHeight = (int)((double)pdfPoint.y * resolution);
  65.  
  66.                 pdfRect.Left = 0;
  67.                 pdfRect.right = (short)imgWidth;
  68.                 pdfRect.Top = 0;
  69.                 pdfRect.bottom = (short)imgHeight;
  70.  
  71.                 // Render to clipboard, scaled by 100 percent (ie. original size)
  72.                 // Even though we want a smaller image, better for us to scale in .NET
  73.                 // than Acrobat as it would greek out small text
  74.                 pdfPage.CopyToClipboard(pdfRect, 0, 0, (short)(100 * resolution));
  75.  
  76.                 IDataObject clipboardData = Clipboard.GetDataObject();
  77.  
  78.                 if (clipboardData.GetDataPresent(DataFormats.Bitmap))
  79.                 {
  80.                     Bitmap pdfBitmap = (Bitmap)clipboardData.GetData(DataFormats.Bitmap);
  81.                     pdfBitmap.Save(Path.Combine(imageOutputPath, imageName) + i.ToString() + "." + imageFormat.ToString(), imageFormat);
  82.                     pdfBitmap.Dispose();
  83.                 }
  84.             }
  85.  
  86.             pdfDoc.Close();
  87.             Marshal.ReleaseComObject(pdfPage);
  88.             Marshal.ReleaseComObject(pdfRect);
  89.             Marshal.ReleaseComObject(pdfDoc);
  90.             Marshal.ReleaseComObject(pdfPoint);
  91.  
  92.         }
  93.  
  94.         [STAThread]
  95.         public static void Main(string[] args)
  96.         {
  97.             ConvertPDF2Image("F:\\Events.pdf", "F:\\", "A", 0, 0, null, 0);
  98.         }
  99.  
  100.     }
  101. }

ConsoleWrite

$
0
0

Just wondering if this is a bug.

Local $a1[2] = [1,2] Local $a2[2] = [1,2] $cw = ConsoleWrite($a1 & @CRLF & $a2 & @CRLF & "some text" & @CRLF) ConsoleWrite("error and return = " & @error & " " & $cw & @LF)

Output..

>Running:(3.3.12.0)blah... --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop error and return = 0 0 +>20:59:36 AutoIt3.exe ended.rc:0 >Exit code: 0    Time: 0.536

I understand an array might not have a value to display, there are other values in the expression that do.

 

Arrays

$
0
0

If I remember correctly, AutoIt used to be able to compare arrays like with two on opposing ends of "=" operator.

 

It does/can not now, wondering what changed, if I recall correctly that is.

 

But what is odd is that a comparison can be true if case sensitive.

Local $a1[2] = [1,2] Local $a2[2] = [1,2] If $a1 = $a2 Then     MsgBox(0, "Arrays", "Test 1") EndIf If $a1 == $a2 Then     MsgBox(0, "Arrays", "Test 2") EndIf

I'm just curious is all, it's not causing me any woes.

Implementation of a standalone TEB and PEB read Method for the Simulation of GetModuleHandle and GetProcAddress functions for loaded PE Module

$
0
0
Attached File  GetModuleFunc.h   8.34KB   5 downloads

1. Introduction
This writing describes in detail method for retrieving the address of exported function for loaded module without using any available API on either 32bit or 64bit Windows systems. Structures definitions are taken from Microsoft SDK 7.1, unless otherwise specified.
Loaded module is searched by name, not path. The code is written in form of function that has two parameters, WCHAR pointer to the module name and CHAR pointer to the function name, written in C++ and compiled using Microsoft Visual Studio Express 2013 for Windows Desktop. Basic knowledge of C++ is assumed.
Attached GetModuleFunc.h has the full code for the function.

2. TEB
Thread Environment Block is chunk of memory filled with various information about the thread. TEB is defined inside winternl.h as:
typedef struct _TEB {     PVOID Reserved1[12];     PPEB ProcessEnvironmentBlock;     PVOID Reserved2[399];     BYTE Reserved3[1952];     PVOID TlsSlots[64];     BYTE Reserved4[8];     PVOID Reserved5[26];     PVOID ReservedForOle;  // Windows 2000 only     PVOID Reserved6[4];     PVOID TlsExpansionSlots; } TEB, *PTEB;
After the executable is loaded by the Windows PE loader and before the thread starts running, TEB is saved to fs(x86) or gs(x64 flavor) processor register. Seventh pointer inside is pointer to the TEB for the current thread.
Even not officially documented, this behavior is observed on/for all available Windows operating systems with NT kernel.
Acquiring pointer to the TEB is done using Microsoft specific compiler intrinsics:
#include <winnt.h> #include <winternl.h> #if defined(_M_X64)     auto pTeb = reinterpret_cast<PTEB>(__readgsqword(6 * sizeof(LPVOID))); #else     auto pTeb = reinterpret_cast<PTEB>(__readfsdword(6 * sizeof(LPVOID))); #endif
Among others, one of the fields inside the TEB is pointer to the PEB (Process Environment Block).

3. PEB
Process Environment Block is memory area filled with information about a process. PEB is defined inside winternl.h as:
typedef struct _PEB {     BYTE Reserved1[2];     BYTE BeingDebugged;     BYTE Reserved2[1];     PVOID Reserved3[2];     PPEB_LDR_DATA Ldr;     PRTL_USER_PROCESS_PARAMETERS ProcessParameters;     PVOID Reserved4[3];     PVOID AtlThunkSListPtr;     PVOID Reserved5;     ULONG Reserved6;     PVOID Reserved7;     ULONG Reserved8;     ULONG AtlThunkSListPtr32;     PVOID Reserved9[45];     BYTE Reserved10[96];     PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;     BYTE Reserved11[128];     PVOID Reserved12[1];     ULONG SessionId; } PEB, *PPEB;
Pointer to the PEB is read from the TEB:
auto pPeb = pTeb->ProcessEnvironmentBlock;
3.1. PEB_LDR_DATA
Contains information about the loaded modules for the process. Ldr field of the PEB points to PEB_LDR_DATA structure, defined inside winternl.h as:
typedef struct _PEB_LDR_DATA {     BYTE Reserved1[8];     PVOID Reserved2[3];     LIST_ENTRY InMemoryOrderModuleList; } PEB_LDR_DATA, *PPEB_LDR_DATA;
Pointer to the PEB_LDR_DATA is read from the PEB:
auto pLdrData = pPeb->Ldr;
3.2. LIST_ENTRY
InMemoryOrderModuleList field of the PEB_LDR_DATA is doubly-linked list that contains the loaded modules for the process, defined inside winnt.h as:
typedef struct _LIST_ENTRY {    struct _LIST_ENTRY *Flink;    struct _LIST_ENTRY *Blink; } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
auto pModListHdr = &pLdrData->InMemoryOrderModuleList;
4. LDR_DATA_TABLE_ENTRY
Each item in the list is a pointer to an LDR_DATA_TABLE_ENTRY structure, defined inside winternl.h as:
typedef struct _LDR_DATA_TABLE_ENTRY {     PVOID Reserved1[2];     LIST_ENTRY InMemoryOrderLinks;     PVOID Reserved2[2];     PVOID DllBase;     PVOID Reserved3[2];     UNICODE_STRING FullDllName;     BYTE Reserved4[8];     PVOID Reserved5[3];     union {         ULONG CheckSum;         PVOID Reserved6;     } DUMMYUNIONNAME;     ULONG TimeDateStamp; } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
DllBase field is the base address of the loaded module.
This stucture doesn't give wanted info for the module, being its name. One option is to read FullDllName which includes full path and extract module name from it. However, some independent authors give slightly different definition which include another field - BaseDllName.
Modified LDR_DATA_TABLE_ENTRY struct can be defined, including BaseDllName field and freed from superfluous fields. InMemoryOrderLinks will be iterated, so that field is the top of the struct:
typedef struct _LDR_DATA_TABLE_ENTRY {         /*LIST_ENTRY InLoadOrderLinks;*/         LIST_ENTRY InMemoryOrderLinks;         LIST_ENTRY InInitializationOrderList;         PVOID DllBase;         PVOID EntryPoint;         PVOID Reserved3;         UNICODE_STRING FullDllName;         UNICODE_STRING BaseDllName;     } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
4.1. Iteration
Going throug the items in the list is straightforward. The last item points to the first, meaning the end is reached, hence it can be written:
for (auto pModListCurrent = pModListHdr->Flink; pModListCurrent != pModListHdr; pModListCurrent = pModListCurrent->Flink) {     // Get current module in list     auto pModEntry = reinterpret_cast<PLDR_DATA_TABLE_ENTRY>(pModListCurrent);     //... }
4.2. Reading Module Name
This data is stored in form of UNICODE_STRING. winternl.h definition is:
typedef struct _UNICODE_STRING {     USHORT Length;     USHORT MaximumLength;     PWSTR  Buffer; } UNICODE_STRING;
Module name lookup is case insensitive. Lengths specified inside UNICODE_STRING represent bytes, which means number of WCHAR characters is half of the numbers.
One of the ways to make case insensitive comparison of the specified module name and listed one is to turn both to uppercase before comparing them:
for (int i = 0; i < pModEntry->BaseDllName.Length / 2 /* length is in bytes */; ++i) {     if (sModuleName[i] == '\0') // the end of the string         break;     else if ((sModuleName[i] & ~' ') != (pModEntry->BaseDllName.Buffer[i] & ~' ')) // case-insensitive         break;     else if (i == iLenModule - 1) // gone through all characters and they all matched     {         //... the rest of the code     } }
iLenModule is length of the wanted module name. It's get by counting number of characters inside the string until null-terminator is encountered:
int iLenModule = 0; for (; sModuleName[iLenModule]; ++iLenModule);
Comparison written in this manner allows for matching function argument L"kernel32" to listed L"kernel32.dll", which mimics to a decent degree (not completely for brevity) behavior of GetModuleHandle WinAPI function. In case of two different loaded modules whose names differs only in extensions, first listed is matched.

5. PE format walkthrough
The Portable Executable (PE) format is a file format for executables, object code, DLLs, etc... It describes how and where inside the file the executable code is, import table, export table, resources, and every other data needed for loader.
Exported functions are listed inside the Export Table. Reaching export table is done in few steps parsing the PE data.

5.1. IMAGE_DOS_HEADER
The matching module's DllBase points to the first byte of the loaded image. PE starts with legacy DOS header defined inside winnt.h as:
typedef struct _IMAGE_DOS_HEADER {      // DOS .EXE header     WORD   e_magic;                     // Magic number     WORD   e_cblp;                      // Bytes on last page of file     WORD   e_cp;                        // Pages in file     WORD   e_crlc;                      // Relocations     WORD   e_cparhdr;                   // Size of header in paragraphs     WORD   e_minalloc;                  // Minimum extra paragraphs needed     WORD   e_maxalloc;                  // Maximum extra paragraphs needed     WORD   e_ss;                        // Initial (relative) SS value     WORD   e_sp;                        // Initial SP value     WORD   e_csum;                      // Checksum     WORD   e_ip;                        // Initial IP value     WORD   e_cs;                        // Initial (relative) CS value     WORD   e_lfarlc;                    // File address of relocation table     WORD   e_ovno;                      // Overlay number     WORD   e_res[4];                    // Reserved words     WORD   e_oemid;                     // OEM identifier (for e_oeminfo)     WORD   e_oeminfo;                   // OEM information; e_oemid specific     WORD   e_res2[10];                  // Reserved words     LONG   e_lfanew;                    // File address of new exe header   } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
Therefore it can be written:
auto pImageDOSHeader = reinterpret_cast<PIMAGE_DOS_HEADER>(pModEntry->DllBase);
e_lfanew is offset to a NT header.

5.2. IMAGE_NT_HEADERS
Another area of PE is NT header. This is effectively the starting point of the portable executable format description. Definition and the size of it depends on bitness. For 32bit it's:
typedef struct _IMAGE_NT_HEADERS {     DWORD Signature;     IMAGE_FILE_HEADER FileHeader;     IMAGE_OPTIONAL_HEADER32 OptionalHeader; } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
...and 64bit version is:
typedef struct _IMAGE_NT_HEADERS64 {     DWORD Signature;     IMAGE_FILE_HEADER FileHeader;     IMAGE_OPTIONAL_HEADER64 OptionalHeader; } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
5.3. IMAGE_NT_HEADERS
OptionalHeader field is another structure discribing in detail PE file. It's directly followed by number of IMAGE_DATA_DIRECTORY structures. The exact number of these structures is saved inside IMAGE_NT_HEADERS as NumberOfRvaAndSizes field.
For 32bit PE IMAGE_NT_HEADERS is defined as:
C++         
typedef struct _IMAGE_OPTIONAL_HEADER {     //     // Standard fields.     //     WORD    Magic;     BYTE    MajorLinkerVersion;     BYTE    MinorLinkerVersion;     DWORD   SizeOfCode;     DWORD   SizeOfInitializedData;     DWORD   SizeOfUninitializedData;     DWORD   AddressOfEntryPoint;     DWORD   BaseOfCode;     DWORD   BaseOfData;     //     // NT additional fields.     //     DWORD   ImageBase;     DWORD   SectionAlignment;     DWORD   FileAlignment;     WORD    MajorOperatingSystemVersion;     WORD    MinorOperatingSystemVersion;     WORD    MajorImageVersion;     WORD    MinorImageVersion;     WORD    MajorSubsystemVersion;     WORD    MinorSubsystemVersion;     DWORD   Win32VersionValue;     DWORD   SizeOfImage;     DWORD   SizeOfHeaders;     DWORD   CheckSum;     WORD    Subsystem;     WORD    DllCharacteristics;     DWORD   SizeOfStackReserve;     DWORD   SizeOfStackCommit;     DWORD   SizeOfHeapReserve;     DWORD   SizeOfHeapCommit;     DWORD   LoaderFlags;     DWORD   NumberOfRvaAndSizes;     IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
...and for 64bit version it's:
C++         
typedef struct _IMAGE_OPTIONAL_HEADER64 {     WORD        Magic;     BYTE        MajorLinkerVersion;     BYTE        MinorLinkerVersion;     DWORD       SizeOfCode;     DWORD       SizeOfInitializedData;     DWORD       SizeOfUninitializedData;     DWORD       AddressOfEntryPoint;     DWORD       BaseOfCode;     ULONGLONG   ImageBase;     DWORD       SectionAlignment;     DWORD       FileAlignment;     WORD        MajorOperatingSystemVersion;     WORD        MinorOperatingSystemVersion;     WORD        MajorImageVersion;     WORD        MinorImageVersion;     WORD        MajorSubsystemVersion;     WORD        MinorSubsystemVersion;     DWORD       Win32VersionValue;     DWORD       SizeOfImage;     DWORD       SizeOfHeaders;     DWORD       CheckSum;     WORD        Subsystem;     WORD        DllCharacteristics;     ULONGLONG   SizeOfStackReserve;     ULONGLONG   SizeOfStackCommit;     ULONGLONG   SizeOfHeapReserve;     ULONGLONG   SizeOfHeapCommit;     DWORD       LoaderFlags;     DWORD       NumberOfRvaAndSizes;     IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
PE files generated by Microsoft tools allways create IMAGE_NUMBEROF_DIRECTORY_ENTRIES (16) IMAGE_DATA_DIRECTORY structures, 15 of which are documented in this order (winnt.h):
#define IMAGE_DIRECTORY_ENTRY_EXPORT          0   // Export Directory #define IMAGE_DIRECTORY_ENTRY_IMPORT          1   // Import Directory #define IMAGE_DIRECTORY_ENTRY_RESOURCE        2   // Resource Directory #define IMAGE_DIRECTORY_ENTRY_EXCEPTION       3   // Exception Directory #define IMAGE_DIRECTORY_ENTRY_SECURITY        4   // Security Directory #define IMAGE_DIRECTORY_ENTRY_BASERELOC       5   // Base Relocation Table #define IMAGE_DIRECTORY_ENTRY_DEBUG           6   // Debug Directory //      IMAGE_DIRECTORY_ENTRY_COPYRIGHT       7   // (X86 usage) #define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE    7   // Architecture Specific Data #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR       8   // RVA of GP #define IMAGE_DIRECTORY_ENTRY_TLS             9   // TLS Directory #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG    10   // Load Configuration Directory #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT   11   // Bound Import Directory in headers #define IMAGE_DIRECTORY_ENTRY_IAT            12   // Import Address Table #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT   13   // Delay Load Import Descriptors #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14   // COM Runtime descriptor
5.4. IMAGE_DATA_DIRECTORY
Definition is:
typedef struct _IMAGE_DATA_DIRECTORY {     DWORD   VirtualAddress;     DWORD   Size; } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
It can now be written:
auto pExport = reinterpret_cast<PIMAGE_DATA_DIRECTORY>(&pImageNtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]);
VirtualAddress field is RVA of the directory counting from the first byte (base) of the loaded module. If both VirtualAddress and Size fields are filled then the module exports functions.

5.5. IMAGE_EXPORT_DIRECTORY
Definition is (winnt.h):
typedef struct _IMAGE_EXPORT_DIRECTORY {     DWORD   Characteristics;     DWORD   TimeDateStamp;     WORD    MajorVersion;     WORD    MinorVersion;     DWORD   Name;     DWORD   Base;     DWORD   NumberOfFunctions;     DWORD   NumberOfNames;     DWORD   AddressOfFunctions;     // RVA from base of image     DWORD   AddressOfNames;         // RVA from base of image     DWORD   AddressOfNameOrdinals;  // RVA from base of image } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
Base is ordinal value of the first exported function.
NumberOfFunctions is overall number of exported functions from the module.
NumberOfNames is number of functions exported only by name.
AddressOfFunctions is RVA of the array of RVAs of exported functions addresses.
AddressOfNames is RVA of the array of RVAs of exported functions names.
AddressOfNameOrdinals is RVA of the array of WORD values each representing index of function exported by name, into the array of addresses.

It's:
auto pExports = reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(reinterpret_cast<ULONG_PTR>(pImageDOSHeader) + pExport->VirtualAddress);
6. Getting function RVA
Every exported function is accessible by odinal value. Functions exported by name are also accessible by name.
Finding function by its ordinal value is fairly simple and fast. The lowest ordinal value is Base field of IMAGE_EXPORT_DIRECTORY struct. The highest ordinal value is get by adding the number of exported functions to that number, minus one of course. If the specified ordinal value is within this range, RVA is read from the array of functions addresses:
if (iOrdinal) // function is wanted by its ordinal value {     // Check to see if valid ordinal value is specified     if (iOrdinal >= pExports->Base && iOrdinal < pExports->Base + pExports->NumberOfFunctions)         dwExportRVA = pdwBufferAddress[iOrdinal - pExports->Base]; }
In case of functions exported by name, name lookup needs to be performed.
The code is:
// Array of functions names auto pdwBufferNames = reinterpret_cast<LPDWORD>(reinterpret_cast<ULONG_PTR>(pImageDOSHeader) + pExports->AddressOfNames); // Array of functions indexes into array of addresses auto pwBufferNamesOrdinals = reinterpret_cast<LPWORD>(reinterpret_cast<ULONG_PTR>(pImageDOSHeader) + pExports->AddressOfNameOrdinals);
And then the loop:
// Loop through all functions exported by name for (DWORD j = 0; j < pExports->NumberOfNames; ++j) {     // Read the listed function name     auto sFunc = reinterpret_cast<LPCSTR>(reinterpret_cast<ULONG_PTR>(pImageDOSHeader) + pdwBufferNames[j]);     //... }
When the name of the function is matched (case sensitive) the RVA of the function will be read from pdwBufferAddress array at index read from pwBufferNamesOrdinals at loop counter value index:
dwExportRVA = pdwBufferAddress[pwBufferNamesOrdinals[j]];
6.1. Export Forwarding
RVA of the function will resolve fonction's pointer. However there is one special case when the RVA offset points to a value inside the exports section and not to the function body which is normally found in some other sections of PE.
When that happens, RVA will resolve to a null-terminated ANSII string value. This is called Export Forwarding. RVA is then replaced by the RVA value of the resolved function.
if (dwExportRVA > pExport->VirtualAddress && dwExportRVA < pExport->VirtualAddress + pExport->Size) {     // Read forwarded data.     auto sForwarder = reinterpret_cast<LPCSTR>(reinterpret_cast<ULONG_PTR>(pImageDOSHeader) + dwExportRVA);     //... }
The format of the forwarding string is: ModuleName.FunctionName or ModuleName.#OrdinalValue
To resolve the RVA of the new exported function a recursive call to this function will be used. ModuleName has to be wide string. WCHAR buffer is allocated and all characters from ModuleName portion of forwarded string copied to it:
WCHAR sForwarderDll[MAX_PATH]; // Reinterpret WCHAR buffer as CHAR one auto sForwarderDll_A = reinterpret_cast<CHAR*>(sForwarderDll); // Now go through all characters for (int iPos = 0; sForwarder[iPos]; ++iPos) {     // Fill WCHAR buffer reading/copying from CHAR one     sForwarderDll_A[2 * iPos] = sForwarder[iPos]; // copy character     sForwarderDll_A[2 * iPos + 1] = '\0';     if (sForwarder[iPos] == '.')     {         sForwarderDll[iPos] = '\0'; // null-terminate the ModuleName string         break;     } }
In case forwarding string specifies function name, pointer to that string is simply a pointer to a character following the dot.
For OrdinalValue version the presence of hashtek character after the dot has to be checked and the hashtag string converted to integer value before recusrvive call made.
The full code for this is:
C++         
// Allocate big enough buffer for the new module name WCHAR sForwarderDll[MAX_PATH]; LPCSTR sForwarderFunc = nullptr; DWORD dwForwarderOrdinal = 0; // Reinterpret WCHAR buffer as CHAR one auto sForwarderDll_A = reinterpret_cast<CHAR*>(sForwarderDll); // Now go through all characters for (int iPos = 0; sForwarder[iPos]; ++iPos) {     // Fill WCHAR buffer reading/copying from CHAR one     sForwarderDll_A[2 * iPos] = sForwarder[iPos]; // copy character     sForwarderDll_A[2 * iPos + 1] = '\0';     if (sForwarder[iPos] == '.')     {         sForwarderDll[iPos] = '\0'; // null-terminate the ModuleName string         ++iPos;         if (sForwarder[iPos] == '#')         {             ++iPos; // skip # character             // OrdinalValue is hashtag, convert ASCII string to integer value             for (; sForwarder[iPos]; ++iPos)             {                 dwForwarderOrdinal *= 10;                 dwForwarderOrdinal += (sForwarder[iPos] - '0');             }             if (dwForwarderOrdinal > MAX_ORDINAL) // something is wrong                 return nullptr;             // Reinterpret the ordinal value as string             sForwarderFunc = reinterpret_cast<LPSTR>(dwForwarderOrdinal);             break;         }         else         {             sForwarderFunc = &sForwarder[iPos]; // FunctionName follows the dot             break;         }     } }
6.2. Finalizing
Once funcion address RVA is get, it's added to the base address and returned from the function:
return reinterpret_cast<LPVOID>(reinterpret_cast<ULONG_PTR>(pImageDOSHeader) + dwExportRVA);
7. Anti-Virus Software considerations
This method enables compiling PE files with empty imports directory. In combination with accessing fs register at TEB/PEB offset it has been observed that 18.2% of AV scanners tend to flag 32bit executables, containing no code other than this function, as malware.
64 bit executables compiled from the same source never gets flagged.

8. Example
The attached zip contains two executables compiled from the source of 1K-Mandelbrot project, written by Emil Persson. The source had no explicit License Agreement. It's modified not to use WinAPI, rather to use method desribed here to call functions from used dlls and then compiled.
Beautiful examples of visualisation of complex calculations, done in efficient way using OpenGL.
Requirement is OpenGL 2.0.
Attached File  Mandelbrot_Examples.zip   6.43KB   13 downloads

9. Conclusion
This method isn't usually used by executables ran from user mode. It depends on officially undocumented feature, therefore it should be avoided using for production software.
Limited speed tests show that it's faster than standard GetModuleHandle/GetProcAddress method.
Mimicking WinAPI behavior is achieved to a high level for valid input, with omitted special error handling and reporting. The only major difference is unsupported full-path processing.


References:
Microsoft Corporation: Microsoft Portable Executable and Common Object File Format Specification, Revision 6.0
Matt Pietrek: Under The Hood - http://www.microsoft.com/msj/archive/s2ce.aspx
An In-Depth Look into the Win32 Portable Executable File Format - http://msdn.microsoft.com/en-us/magazine/bb985992.aspx
An In-Depth Look into the Win32 Portable Executable File Format, Part 2 - http://msdn.microsoft.com/en-us/magazine/cc301808.aspx
Mark Russinovich, David A. Solomon, Alex Ionescu : Microsoft Windows Internals, 6th edition
VirusTotal: Web Service - https://www.virustotal.com/
Emil Persson: 1K-Mandelbrot - http://www.humus.name/index.php?page=3D&ID=85



Dragana R. <trancexx at yohoo dot com>

Relocated my AutoIt Tutorials and created some new ones.

$
0
0

Since I made my specific channel for tutorials, I have now chosen to make the original videos on techwg channel unlisted, upload them on my new channel TutsTeach (channel is 1 year old and active), made a new playlist on the new channel and removed the videos on techwg from the playlist on techwg and put the new videos on TutsTeach on there. So nobody will be without, if people bookmarked the individual videos from techwg or the original playlist, the links will still work. I have also updated the AutoIt wiki page with the new playlist URL on the correct TutsTeach channel.

 

I have created a new video on hotkeys and two videos on automating programs. The first of the two automation videos covers step by step automation of an installer using MouseClick and the second video just covers additional methods of interacting with controls on windows to make sure people have different methods which will fit the particular situation they are scripting around.

 

The official playlist link is https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z

Atan2

$
0
0

Are there any plans for an Atan2 function?

Bank card reader

$
0
0
I found this topic on example scripts forum: http://www.autoitscript.com/forum/topic/161865-iban-validator/
and it looked interesting.
I knew more or less how we can validate an IBAN code but again seen this coded is impressive.
 
I do all of my payments via pc(pc banking). For people who do this you should know card readers.
Card reader is a small machine, almost like a small calculator, which validates the informations given from the bank's server and gives back a response to be able to log in your bank's website or do payments.
The whole process looks very impressive, however I believe it is just math equations. So I decided to try to find out how it works.
A simple google search gave me this wiki informations: <snip>
I also found this : <snip>
I am still reading and searching for more informations.
 
Does anyone find this interesting? Anyone has any idea on how the whole process is done?

WinList() With Variables Possible?

$
0
0

I was working trying to get a script that would use WinList() to create and display an array of windows with the tile defined by REGEXPTITLE such as Google Chrome.

Example:

  1. #include <Array.au3>
  2.  
  3. $list = WinList("[REGEXPTITLE:(?i)(.*Google*)]")
  4.  

I have with the code above made an array listing all windows with the title google which works great but my question is that, is it possible to use a variable in place of the Google in the above code? I have tried the below codes but am unable to get it to work. The array always comes back empty.

 

The first two i have tried with a quotation around Google but still revive an empty array.

  1. #include <Array.au3>
  2.  
  3. $wintitle = Google
  4.  
  5. $list = WinList("[REGEXPTITLE:(?i)(.*$Wintitle*)]")
  6.  
  1. #include <Array.au3>
  2.  
  3. $wintitle = Google
  4.  
  5. $list = WinList('"[REGEXPTITLE:(?i)(.*' & $Wintitle & '*)]"')
  6.  
  1. #include <Array.au3>
  2.  
  3. $wintitle = "[REGEXPTITLE:(?i)(.*Google*)]"
  4.  
  5. $list = WinList($wintitle)
  6.  
  1. #include <Array.au3>
  2.  
  3. $app = Google
  4.  
  5. $wintitle = '"[REGEXPTITLE:(?i)(.*' & $app & '*)]"'
  6.  
  7. $list = WinList($wintitle)
  8.  

It's been a while, trying to revisit functions as first class objects. I have a question.

$
0
0

I thought that it might be useful to dynamically rebind a variable to a function so the same call to a function could be set to actually use a different function which requires the same parameters. But I recall seeing somewhere on the forum about it's use in HotKeySet but I do not recall what the benefit was of using a variable for a function in the hotkey vs using the name in a string. Could you clarify that and I would like to know other good uses/shortcuts that this $function ability provides.

 

Thanks.

Is a crash more powerful than an Exit?

$
0
0

If there is something in your script that actually crashes the exe out, is that type of "exit" more powerful in terms of halting all operations that the exe was doing, than simply issuing an Exit command? For example, are there circumstances where Exit may fail or be delayed whereas a crash is instant or something?

Problem with Context menu.

$
0
0

I am making a script to create a list of currently open windows of a specified program with program icons similar to windows preview when you point your mouse at a running program on your task bar which brings up a list of open windows for that program. Each window in this list will have a separate context menu upon right click. I have everything working great but the items in the context menu are giving me grief. When i open the context menu and try to click a menu item it does not create a message box that i have specified in the script for testing them. I thought i would have you guys take a look at the script and see what you though might be the problem. Note: This is extremely experimental script.

AutoIt         
  1. #include <Array.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. #include <MsgBoxConstants.au3>
  5.  
  6. GUICreation()
  7.  
  8. Windowcheck()
  9.  
  10. Func GUICreation()
  11.     Opt("GUIOnEventMode", 1)
  12.     $app = 'google'
  13.     Global $path = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
  14.     $wintitle = "[REGEXPTITLE:(?i)(.*" & $app & "*)]"
  15.     Global $list = WinList($wintitle)
  16.     $WinNum = $list[0][0] * 20
  17.     $GUI = GUICreate("List Windows", 300, $WinNum, -1, -1, $WS_POPUP)
  18.     Global $end = 0
  19.  
  20. Func Windowcheck()
  21.     Switch $list[0][0]
  22.        Case 1
  23.           $1 = GUICtrlCreateLabel($list[1][0], 20, 5)
  24.           GUICtrlCreateIcon($path, -1, 0, 0, 20, 20)
  25.           GUICtrlSetCursor($1,0)
  26.           GUICtrlSetOnEvent($1, "item1")
  27.           $i1m = GUICtrlCreateContextMenu($1)
  28.           Global $id1 = GUICtrlCreateMenuItem("Minimize", $i1m)
  29.           Global $id2 = GUICtrlCreateMenuItem("Restore", $i1m)
  30.        Case 2
  31.           $1 = GUICtrlCreateLabel($list[1][0], 20, 5)
  32.           GUICtrlCreateIcon($path, -1, 0, 0, 20, 20)
  33.           GUICtrlSetCursor($1,0)
  34.           GUICtrlSetOnEvent($1, "item1")
  35.           $i1m = GUICtrlCreateContextMenu($1)
  36.           Global $id1 = GUICtrlCreateMenuItem("Minimize", $i1m)
  37.           Global $id2 = GUICtrlCreateMenuItem("Restore", $i1m)
  38.           $2 = GUICtrlCreateLabel($list[2][0], 20, 25)
  39.           GUICtrlCreateIcon($path, -1, 0, 20, 20, 20)
  40.           GUICtrlSetCursor($2,0)
  41.           GUICtrlSetOnEvent($2, "item2")
  42.           $i2m = GUICtrlCreateContextMenu($2)
  43.           Global $id1 = GUICtrlCreateMenuItem("2", $i2m)
  44.     EndSwitch
  45.  
  46.        Case $id1
  47.           MsgBox($MB_SYSTEMMODAL, "Test", "Minimize Clicked")
  48.        Case $id2
  49.           MsgBox($MB_SYSTEMMODAL, "Test", "Restore Clicked")
  50.     EndSwitch

This script is made to show google chrome windows currently.

 

I have looked at the example script in the function documentation for the context menu and it works great but i cant seem to decipher why the example works and mine does not. Example script provided below.

AutoIt         
  1. ; right click on gui to bring up context Menu.
  2. ; right click on the "ok" button to bring up a controll specific context menu.
  3.  
  4. #include <ButtonConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <MsgBoxConstants.au3>
  7.  
  8. Example()
  9.  
  10. Func Example()
  11.     GUICreate("My GUI Context Menu", 300, 200)
  12.  
  13.     Local $idContextmenu = GUICtrlCreateContextMenu()
  14.  
  15.     Local $idNewsubmenu = GUICtrlCreateMenu("new", $idContextmenu)
  16.     Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu)
  17.  
  18.     Local $idButton = GUICtrlCreateButton("OK", 100, 100, 70, 20)
  19.     Local $idButtoncontext = GUICtrlCreateContextMenu($idButton)
  20.     Local $idMenuAbout = GUICtrlCreateMenuItem("About button", $idButtoncontext)
  21.  
  22.     Local $idMenuOpen = GUICtrlCreateMenuItem("Open", $idContextmenu)
  23.     Local $idMenuSave = GUICtrlCreateMenuItem("Save", $idContextmenu)
  24.     GUICtrlCreateMenuItem("", $idContextmenu) ; separator
  25.  
  26.     Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu)
  27.  
  28.  
  29.     ; Loop until the user exits.
  30.     While 1
  31.         Switch GUIGetMsg()
  32.             Case $GUI_EVENT_CLOSE
  33.                 ExitLoop
  34.             Case $idButton
  35.                 MsgBox($MB_SYSTEMMODAL, "Button Clicked", 'OK')
  36.             Case $idMenuAbout
  37.                 MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'About')
  38.             Case $idMenuOpen
  39.                 MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Open')
  40.             Case $idMenuSave
  41.                 MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Save')
  42.             Case $idMenuInfo
  43.                 MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Info')
  44.             Case $idNewsubmenuText
  45.                 MsgBox($MB_SYSTEMMODAL, "SubMenu Selected", 'Text')
  46.         EndSwitch
  47.     WEnd
  48.     GUIDelete()
  49. EndFunc   ;==>Example

I have also attached the scripts for you guys to download and run directly.

Attached Files

elliptic curve encryption is faster than others. AutoIt implementation?

$
0
0

Given that EC encryption is significantly faster, is it possible we can get this added to AutoIt?

Viewing all 750 articles
Browse latest View live