Jump to content

PureAutoIt machine code compiler small executable


ghost911
 Share

Recommended Posts

I'm really hoping for this project to go forward as it will solve the two big problems we have with Autoit that are speed and protection, @ghost911 congratulations for the initiative.

Question: @ghost911 which Autoit files I need to have in the folder to test your language converter

 

Link to comment
Share on other sites

@Belini

hi the friend there is no automatic conversion there is just an identical equivalent in the language PUREBASIC sometimes there is a slight difference that must be adapted manually for the moment you have the list of functions in the AutoitCoding file and examples of adaptation in test.pb you can compare it to the original language of Example.au3

Link to comment
Share on other sites

From what I understand I should put IncludeFile "AutoitCoding.PB" at the beginning of the code and then program it as if it were in Autoit but it gives error on the first line where I add include.

Spoiler

 

68072a8d-da7a-4b1c-b80f-f55e9ada5865-ori


 

 

Edited by Belini
Link to comment
Share on other sites

be sure to open the example test.pb in the PureAutoitInclude.rar @Belini thankyou

because you are mistaken IncludeFile "AutoitCoding.PB" is to be included in a blank file and not in AutoitCoding.PB

the examples are in the test.pb file

Edited by ghost911
Link to comment
Share on other sites

Link to comment
Share on other sites

@ ghost911 I managed to change the functions made by Thomas Schulz to use in the same pattern that you are doing and maybe you can use in AutoitCoding.pb.

; =====================================================================================================================
;                                                Done by Thomas Schulz
; =====================================================================================================================

;{
; Version 1.4
;
; Copyright (c) 2011 by Thomas Schulz / ts-soft@web.de
; http://www.realsource.de
; All Rights Reserved.
;
; The contents of this file are subject To the Mozilla Public License Version
; 1.1 (the "License"); you may not use this file except in compliance with
; the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS" basis,
; WITHOUT WARRANTY OF ANY KIND, either express Or implied. See the License
; For the specific language governing rights And limitations under the
; License.
;}

Macro ChangeMatchMode(Flag = #AW_MatchFromStart)
  AW_ChangeMatchMode2(Flag)
EndMacro

Macro FindHiddenWindow(Flag = 0)
  AW_FindHiddenWindow2(Flag)
EndMacro

Macro ControlClick(title, controlID, Button = #PB_Button_Left, clicks = 1)
  AW_ControlClick3(title, controlID, Button, clicks)
EndMacro

Macro ControlMove(title, controlID, x, y, width = #PB_Ignore, height = #PB_Ignore)
  AW_ControlMove2(title, controlID, x, y, width, height)
EndMacro

Macro MouseClick(Button = #PB_MouseButton_Left, x = #PB_Ignore, y = #PB_Ignore, clicks = 1)
  AW_MouseClick4(Button, x, y, clicks)
EndMacro

Macro MouseDown(Button = #PB_MouseButton_Left)
  AW_MouseDown2(Button)
EndMacro

Macro MouseUp(Button = #PB_MouseButton_Left)
  AW_MouseUp2(Button)
EndMacro

Macro WinGetTitle(title = "")
  AW_WinGetTitle2(title)
EndMacro

Macro WinHideFromTaskBar(title, Flag = #True)
  AW_WinHideFromTaskBar2(title, Flag)
EndMacro

Macro WinMove(title, x, y, width = #PB_Ignore, height = #PB_Ignore)
  AW_WinMove2(title, x, y, width, height)
EndMacro

Macro WinWait(title, timeout = 0)
  AW_WinWait2(title, timeout)
EndMacro

Macro WinWaitActive(title, timeout = 0)
  AW_WinWaitActive2(title, timeout)
EndMacro

Macro WinWaitClose(title, timeout = 0)
  AW_WinWaitClose2(title, timeout)
EndMacro

Macro WinWaitNotActive(title, timeout = 0)
  AW_WinWaitNotActive2(title, timeout)
EndMacro

; IDE Options = PureBasic 4.60 (Windows - x86)
; CursorPosition = 4
; Folding = BA5
; EnableXP
; HideErrorLog
; CompileSourceDirectory

;{
; Version 1.4.1
;
; Copyright (c) 2010 - 2012 by Thomas Schulz / ts-soft@web.de
; http://www.realsource.de
; All Rights Reserved.
;
; Second Author: Little John
;
; The contents of this file are subject To the Mozilla Public License Version
; 1.1 (the "License"); you may not use this file except in compliance with
; the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS" basis,
; WITHOUT WARRANTY OF ANY KIND, either express Or implied. See the License
; For the specific language governing rights And limitations under the
; License.
;}

EnableExplicit

DataSection
  CLSID_Shell_Application:  ; {13709620-C279-11CE-A49E-444553540000}
  Data.l $13709620
  Data.w $C279, $11CE
  Data.b $A4, $9E, $44, $45, $53, $54, $0, $0
  IID_IShellDispatch:  ; {D8F015C0-C278-11CE-A49E-444553540000}
  Data.l $D8F015C0
  Data.w $C278, $11CE
  Data.b $A4, $9E, $44, $45, $53, $54, $0, $0

  CLSID_TaskBarList:
  Data.l $56FDF344
  Data.w $FD6D, $11D0
  Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
  IID_ITaskBarList:
  Data.l $56FDF342
  Data.w $FD6D, $11D0
  Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
EndDataSection

Enumeration ; WinTitleMatchMode
  #AW_MatchFromStart
  #AW_MatchAnySubString
  #AW_MatchExactString
  #AW_MatchParaIsHwnd
EndEnumeration

Structure WinParameter
  Title.s
  ClassName.s
  hWnd.i
  ID.i
EndStructure

ProcedureDLL AutoWin_Init()
  Global MatchMode
  Global FindHiddenWindows
  Global NewMap ClassNames.i()
EndProcedure

Procedure EnumWindowsProc(hWnd, lParam)
  Protected *param.WinParameter = lParam
  Protected Title.s{260}

  If Not FindHiddenWindows
    If Not IsWindowVisible_(hwnd)
      *param\hWnd = #False
      ProcedureReturn #True
    EndIf
  EndIf
  GetWindowText_(hWnd, @Title, 260)
  If Title
    *param\hWnd = hWnd
    Select MatchMode
      Case #AW_MatchAnySubString
        If FindString(Title, *param\Title, 1)
          ProcedureReturn #False
        EndIf
      Case #AW_MatchExactString
        If Title = *param\Title
          ProcedureReturn #False
        EndIf
      Default
        If Left(Title, Len(*param\Title)) = *param\Title
          ProcedureReturn #False
        EndIf
    EndSelect
  EndIf
  *param\hWnd = #False
  ProcedureReturn #True
EndProcedure

Procedure EnumChildProc(hWnd, lParam)
  Protected *param.WinParameter = lParam
  Protected CName.s{128}
  Protected count

  If *param\ClassName
    GetClassName_(hWnd, @CName, 128)
    CName = UCase(CName)
    If Left(CName, 1) = "#" : ProcedureReturn #True : EndIf
    If Val(Right(CName, 1)) : ProcedureReturn #True : EndIf
    If FindMapElement(ClassNames(), CName)
      count                = ClassNames(CName)
      ClassNames(CName) = count + 1
    Else
      ClassNames(CName) = 1
    EndIf
    If FindString(*param\ClassName, CName, 1)
      If MapKey(ClassNames()) + Str(ClassNames()) = *param\ClassName
        *param\hWnd = hWnd
        ProcedureReturn #False
      EndIf
    EndIf
  Else
    If GetDlgCtrlID_(hWnd) = *param\ID
      *param\hWnd = hWnd
      ProcedureReturn #False
    EndIf
  EndIf
  ProcedureReturn #True
EndProcedure

Procedure FindWindow(title.s)
   Static param.WinParameter
   Protected hWnd, text.s{260}

   ClearStructure(@param, WinParameter)
   If MatchMode = #AW_MatchParaIsHwnd
      hWnd = Val(title)
      If IsWindow_(hWnd)
         GetWindowText_(hWnd, @text, 260)
         param\hWnd = hWnd
         param\Title = text
      EndIf
   Else
      EnumWindows_(@EnumWindowsProc(), @param)
   EndIf
   ProcedureReturn @param
EndProcedure

Procedure FindControl(hWnd, controlID.s)
  Static param.WinParameter
  ClearStructure(@param, WinParameter)
  ClearMap(ClassNames())
  If Val(controlID)
    param\ID = Val(controlID)
  Else
    param\ClassName = UCase(controlID)
  EndIf
  EnumChildWindows_(hWnd, @EnumChildProc(), @param)
  ProcedureReturn @param
EndProcedure

ProcedureDLL ChangeMatchMode(Flag)
  MatchMode = Flag
EndProcedure

ProcedureDLL FindHiddenWindow(Flag)
  FindHiddenWindows = Flag
EndProcedure

ProcedureDLL ControlClick(title.s, controlID.s, Button, clicks)
  Protected i
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      Select Button
        Case #PB_Button_Left
          For i = 1 To clicks
            PostMessage_(*param\hWnd, #WM_LBUTTONDOWN, 0, 0)
            PostMessage_(*param\hWnd, #WM_LBUTTONUP, 0, 0)
            If i < clicks
              Delay(GetDoubleClickTime_())
            EndIf
          Next
          ProcedureReturn #True
        Case #PB_Button_Right
          For i = 1 To clicks
            PostMessage_(*param\hWnd, #WM_RBUTTONDOWN, 0, 0)
            PostMessage_(*param\hWnd, #WM_RBUTTONUP, 0, 0)
            If i < clicks
              Delay(GetDoubleClickTime_())
            EndIf
          Next
          ProcedureReturn #True
      EndSelect
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlDisable(title.s, controlID.s); Disables or "grays-out" a control
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      ProcedureReturn EnableWindow_(*param\hWnd, #False)
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlEnable(title.s, controlID.s); Enables a "grayed-out" control
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      ProcedureReturn EnableWindow_(*param\hWnd, #True)
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlFocus(title.s, controlID.s); Sets input focus to a given control on a window
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      ProcedureReturn SetFocus_(*param\hWnd)
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlGetHandle(title.s, controlID.s); Retrieves the internal handle of a control
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      ProcedureReturn *param\hWnd
    EndIf
  EndIf
EndProcedure

ProcedureDLL.s ControlGetText(title.s, controlID.s); Retrieves text from a control
  Protected *param.WinParameter
  Protected length, text.s

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      length = SendMessage_(*param\hWnd, #WM_GETTEXTLENGTH, 0, 0)
      If length
        text = Space(length)
        If SendMessage_(*param\hWnd, #WM_GETTEXT, length + SizeOf(Character), @text)
          ProcedureReturn text
        EndIf
      EndIf
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlHide(title.s, controlID.s); Hides a control
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      ProcedureReturn ShowWindow_(*param\hWnd, #SW_HIDE)
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlMove(title.s, controlID.s, x, y, width, height); Moves a control within a window
  Protected rect.RECT
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      If width = #PB_Ignore Or height = #PB_Ignore
        GetWindowRect_(*param\hWnd, @rect)
        width  = rect\right - rect\left
        height = rect\bottom - rect\top
      EndIf
      ProcedureReturn MoveWindow_(*param\hWnd, x, y, width, height, #True)
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlSetText(title.s, controlID.s, text.s); Sets text of a control
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      ProcedureReturn SendMessage_(*param\hWnd, #WM_SETTEXT, 0, @text)
    EndIf
  EndIf
EndProcedure

ProcedureDLL ControlShow(title.s, controlID.s); Shows a control that was hidden
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    *param = FindControl(*param\hWnd, controlID.s)
    If *param\hWnd
      ProcedureReturn ShowWindow_(*param\hWnd, #SW_SHOW)
    EndIf
  EndIf
EndProcedure

ProcedureDLL MouseClick(Button, x, y, clicks)
  Protected i

  If Not (x = #PB_Ignore Or y = #PB_Ignore)
    SetCursorPos_(x, y)
  EndIf
  Select Button
    Case #PB_MouseButton_Left
      For i = 1 To clicks
        mouse_event_(#MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        mouse_event_(#MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
        If i < clicks
          Delay(GetDoubleClickTime_())
        EndIf
      Next
      ProcedureReturn #True
    Case #PB_MouseButton_Middle
      For i = 1 To clicks
        mouse_event_(#MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
        mouse_event_(#MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
        If i < clicks
          Delay(GetDoubleClickTime_())
        EndIf
      Next
      ProcedureReturn #True
    Case #PB_MouseButton_Right
      For i = 1 To clicks
        mouse_event_(#MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
        mouse_event_(#MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
        If i < clicks
          Delay(GetDoubleClickTime_())
        EndIf
      Next
      ProcedureReturn #True
  EndSelect
EndProcedure

ProcedureDLL MouseDown(Button)
  Select Button
    Case #PB_MouseButton_Left
      mouse_event_(#MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
    Case #PB_MouseButton_Middle
      mouse_event_(#MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
    Case #PB_MouseButton_Right
      mouse_event_(#MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
  EndSelect
EndProcedure

ProcedureDLL MouseMove(x, y); Moves the mouse pointer
  ProcedureReturn SetCursorPos_(x, y)
EndProcedure

ProcedureDLL MouseUp(Button)
  Select Button
    Case #PB_MouseButton_Left
      mouse_event_(#MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    Case #PB_MouseButton_Middle
      mouse_event_(#MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
    Case #PB_MouseButton_Right
      mouse_event_(#MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
  EndSelect
EndProcedure

ProcedureDLL SendKeys (keys.s)
   ; Sends simulated keystrokes to the active window
   Protected r, s, notakey, alted, vk, ctrled, shifted
   Protected vk$, s$

   For r = 1 To Len(keys)
      vk$ = Mid(keys, r, 1)
      If vk$ = "{"                      ; Special key found.
         s       = FindString(keys, "}", r + 1) - (r + 1)  ; Get length of special key.
         s$      = Mid(keys, r + 1, s)  ; Get special key name.
         notakey = #False
         Select s$                      ; Get virtual key code of special key.
            Case "ALTDOWN" : alted = 1 : keybd_event_(#VK_MENU, 0, 0, 0) ; Hold ALT down.
            Case "ALTUP" : alted = 0 : keybd_event_(#VK_MENU, 0, #KEYEVENTF_KEYUP, 0) ; Release ALT.
            Case "BACKSPACE" : vk = #VK_BACK
            Case "CONTROLDOWN" : ctrled = 1 : keybd_event_(#VK_CONTROL, 0, 0, 0) ; Hold CONTROL down.
            Case "CONTROLUP" : ctrled = 0 : keybd_event_(#VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0) ; Release CONTROL.
            Case "DELETE" : vk = #VK_DELETE
            Case "DOWN" : vk = #VK_DOWN
            Case "END" : vk = #VK_END
            Case "ENTER" : vk = #VK_RETURN
            Case "F1" : vk = #VK_F1
            Case "F2" : vk = #VK_F2
            Case "F3" : vk = #VK_F3
            Case "F4" : vk = #VK_F4
            Case "F5" : vk = #VK_F5
            Case "F6" : vk = #VK_F6
            Case "F7" : vk = #VK_F7
            Case "F8" : vk = #VK_F8
            Case "F9" : vk = #VK_F9
            Case "F10" : vk = #VK_F10
            Case "F11" : vk = #VK_F11
            Case "F12" : vk = #VK_F12
            Case "ESCAPE" : vk = #VK_ESCAPE
            Case "HOME" : vk = #VK_HOME
            Case "INSERT" : vk = #VK_INSERT
            Case "LEFT" : vk = #VK_LEFT
            Case "PAGEDOWN" : vk = #VK_NEXT
            Case "PAGEUP" : vk = #VK_PRIOR
            Case "PRINTSCREEN" : vk = #VK_SNAPSHOT
            Case "RETURN" : vk = #VK_RETURN
            Case "RIGHT" : vk = #VK_RIGHT
            Case "SHIFTDOWN" : shifted = 1 : keybd_event_(#VK_SHIFT, 0, 0, 0) ; Hold SHIFT down.
            Case "SHIFTUP" : shifted = 0 : keybd_event_(#VK_SHIFT, 0, #KEYEVENTF_KEYUP, 0) ; Release SHIFT.
            Case "TAB" : vk = #VK_TAB
            Case "UP" : vk = #VK_UP
            Default
               If Left(s$, 5) = "DELAY"   ; ** neu (JL)
                  Delay(Val(Mid(s$, 6)))  ; Führende Leerzeichen stören Val() nicht.
               Else
                  notakey = #True
               EndIf
         EndSelect
         If notakey = #False
            If Left(s$, 3) <> "ALT" And Left(s$, 7) <> "CONTROL" And Left(s$, 5) <> "SHIFT" And Left(s$, 5) <> "DELAY"
               keybd_event_(vk, 0, 0, 0) : keybd_event_(vk, 0, #KEYEVENTF_KEYUP, 0)  ; Press the special key.
            EndIf
            r = r + s + 1  ; Continue getting the keystrokes that follow the special key.
         Else
            vk = VkKeyScanEx_(Asc(vk$), GetKeyboardLayout_(0)) ; Normal key found
            keybd_event_(vk, 0, 0, 0) : keybd_event_(vk, 0, #KEYEVENTF_KEYUP, 0) ; Press the normal key.
         EndIf
      Else
         vk = VkKeyScanEx_(Asc(vk$), GetKeyboardLayout_(0)) ; Normal key found
         If (vk & $0100) <> 0 And shifted = 0 : keybd_event_(#VK_SHIFT, 0, 0, 0) : EndIf ; Due to shifted character.
         If (vk & $0200) <> 0 And ctrled = 0 :  keybd_event_(#VK_CONTROL, 0, 0, 0) : EndIf
         If (vk & $0400) <> 0 And alted = 0 :   keybd_event_(#VK_MENU, 0, 0, 0) : EndIf
         keybd_event_(vk, 0, 0, 0) : keybd_event_(vk, 0, #KEYEVENTF_KEYUP, 0) ; Press the normal key.
         If (vk & $0100) <> 0 And shifted = 0 : keybd_event_(#VK_SHIFT, 0, #KEYEVENTF_KEYUP, 0) : EndIf ; Due to shifted character.
         If (vk & $0200) <> 0 And ctrled = 0  : keybd_event_(#VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0) : EndIf
         If (vk & $0400) <> 0 And alted = 0   : keybd_event_(#VK_MENU, 0, #KEYEVENTF_KEYUP, 0) : EndIf
      EndIf
   Next

   keybd_event_(#VK_MENU, 0, #KEYEVENTF_KEYUP, 0)     ; Release ALT key if user forgot.
   keybd_event_(#VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0)  ; Release CONTROL key if user forgot.
   keybd_event_(#VK_SHIFT, 0, #KEYEVENTF_KEYUP, 0)    ; Release SHIFT key if user forgot.
EndProcedure

ProcedureDLL WinActivate(title.s); Activates (gives focus to) a window
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    If SetForegroundWindow_(*param\hWnd)
      ProcedureReturn *param\hWnd
    EndIf
  EndIf
EndProcedure

ProcedureDLL WinActive(title.s); Checks to see if a specified window exists and is currently active
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    If GetForegroundWindow_() = *param\hWnd
      ProcedureReturn *param\hWnd
    EndIf
  EndIf
EndProcedure

ProcedureDLL WinClose(title.s); Closes a window
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    PostMessage_(*param\hWnd, #WM_CLOSE, 0, 0)
  EndIf
EndProcedure

ProcedureDLL WinExists(title.s); Checks to see if a specified window exists
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    ProcedureReturn #True
  EndIf
EndProcedure

ProcedureDLL WinHandle(title.s); Retrieves the internal handle of a window
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    ProcedureReturn *param\hWnd
  EndIf
EndProcedure

ProcedureDLL WinGetProcess(title.s); Retrieves the Process ID (PID) associated with a window
  Protected *param.WinParameter
  Protected PID

  *param = FindWindow(title)
  If *param\hWnd
    GetWindowThreadProcessId_(*param\hWnd, @PID)
    ProcedureReturn PID
  EndIf
EndProcedure

ProcedureDLL WinGetState(title.s); Retrieves the state of a given window
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    If IsZoomed_(*param\hWnd)
      ProcedureReturn #PB_Window_Maximize
    ElseIf IsIconic_(*param\hWnd)
      ProcedureReturn #PB_Window_Minimize
    Else
      ProcedureReturn #PB_Window_Normal
    EndIf
  EndIf
EndProcedure

ProcedureDLL WinGetStateEx(title.s); Retrieves the state as API-constant of a given window
  Protected wpl.WINDOWPLACEMENT
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    wpl\Length = SizeOf(WINDOWPLACEMENT)
    If GetWindowPlacement_(*param\hWnd, @wpl)
      ProcedureReturn wpl\showCmd
    EndIf
  EndIf
EndProcedure

ProcedureDLL.s WinGetTitle(title.s)
  Protected Caption.s{260}
  Protected *param.WinParameter

  If title = ""
    GetWindowText_(GetForegroundWindow_(), @Caption, 260)
    ProcedureReturn Caption
  Else
    *param = FindWindow(title)
    If *param\hWnd
      GetWindowText_(*param\hWnd, @Caption, 260)
      ProcedureReturn Caption
    EndIf
  EndIf
EndProcedure

ProcedureDLL WinHideFromTaskBar(title.s, Flag)
  Protected TBL.ITaskbarList
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    CoInitialize_(0)
    If CoCreateInstance_(?CLSID_TaskBarList, 0, 1, ?IID_ITaskBarList, @TBL) = #S_OK
      TBL\HrInit()
      If Flag
        TBL\DeleteTab(*param\hWnd)
      Else
        TBL\AddTab(*param\hWnd)
      EndIf
      TBL\Release()
    EndIf
    CoUninitialize_()
    ProcedureReturn *param\hWnd
  EndIf
EndProcedure

ProcedureDLL WinKill(title.s); Forces a window to close
  Protected PID, hProcess, Result
  Protected tLuid.LUID
  Protected tTokenPriv.TOKEN_PRIVILEGES
  Protected tTokenPrivNew.TOKEN_PRIVILEGES
  Protected lBufferNeeded, lhTokenHandle
  Protected SE_DEBUG_NAME.s = "SeDebugPrivilege"
  Protected *param.WinParameter

  OpenProcessToken_(GetCurrentProcess_(), #TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY, @lhTokenHandle)
  LookupPrivilegeValue_("", SE_DEBUG_NAME, tLuid)
  tTokenPriv\PrivilegeCount           = 1
  tTokenPriv\Privileges\Luid\LowPart  = tLuid\LowPart
  tTokenPriv\Privileges\Luid\HighPart = tLuid\HighPart
  tTokenPriv\Privileges\Attributes    = #SE_PRIVILEGE_ENABLED
  AdjustTokenPrivileges_(lhTokenHandle, 0, @tTokenPriv, SizeOf(tTokenPrivNew), @tTokenPrivNew, @lBufferNeeded)
  *param = FindWindow(title)
  If *param\hWnd
    GetWindowThreadProcessId_(*param\hWnd, @PID)
    hProcess = OpenProcess_(#PROCESS_TERMINATE, 0, PID)
    If hProcess
      Result = TerminateProcess_(hProcess, 0)
      CloseHandle_(hProcess)
      ProcedureReturn Result
    EndIf
  EndIf
EndProcedure

ProcedureDLL WinMinimizeAll(); Minimizes all windows
  Protected.IShellDispatch obj
  CoInitialize_(#Null)
  If Not CoCreateInstance_(?CLSID_Shell_Application, 0, 1, ?IID_IShellDispatch, @obj)
    obj\MinimizeAll()
    obj\Release()
    CoUninitialize_()
  EndIf
EndProcedure

ProcedureDLL WinMinimizeAllUndo(); Undoes a previous WinMinimizeAll function
  Protected.IShellDispatch obj
  CoInitialize_(#Null)
  If Not CoCreateInstance_(?CLSID_Shell_Application, 0, 1, ?IID_IShellDispatch, @obj)
    obj\UndoMinimizeALL()
    obj\Release()
    CoUninitialize_()
  EndIf
EndProcedure

ProcedureDLL WinMove(title.s, x, y, width, height)
  Protected rect.RECT
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    If width = #PB_Ignore Or height = #PB_Ignore
      GetWindowRect_(*param\hWnd, @rect)
      width  = rect\right - rect\left
      height = rect\bottom - rect\top
    EndIf
    ProcedureReturn MoveWindow_(*param\hWnd, x, y, width, height, #True)
  EndIf
EndProcedure

ProcedureDLL WinSetOnTop(title.s, flag)
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    If Flag
      ProcedureReturn SetWindowPos_(*param\hWnd, #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
    Else
      ProcedureReturn SetWindowPos_(*param\hWnd, #HWND_NOTOPMOST, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
    EndIf
  EndIf
EndProcedure

ProcedureDLL WinSetState(title.s, state); Shows, minimizes or maximizes a window
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    Select state
      Case #PB_Window_Maximize
        ProcedureReturn ShowWindow_(*param\hWnd, #SW_MAXIMIZE)
      Case #PB_Window_Minimize
        ProcedureReturn ShowWindow_(*param\hWnd, #SW_MINIMIZE)
      Default
        ProcedureReturn ShowWindow_(*param\hWnd, #SW_NORMAL)
    EndSelect
  EndIf
EndProcedure

ProcedureDLL WinSetStateEx(title.s, state); Shows, minimizes, maximizes or hide a window, state is API-constant
  Protected wpl.WINDOWPLACEMENT
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    wpl\Length = SizeOf(WINDOWPLACEMENT)
    wpl\showCmd = state
    ProcedureReturn SetWindowPlacement_(*param\hWnd, @wpl)
  EndIf
EndProcedure

ProcedureDLL WinSetTitle(title.s, newtitle.s); Changes the title of a window
  Protected *param.WinParameter

  *param = FindWindow(title)
  If *param\hWnd
    ProcedureReturn SetWindowText_(*param\hWnd, @newtitle)
  EndIf
EndProcedure

ProcedureDLL.i WinWaitActive (title.s, timeoutSec)
   ; Pauses execution of the program until the requested window is active
   Protected endTime, timebreak=#False
   Protected *param.WinParameter

   endTime = ElapsedMilliseconds() + timeoutSec*1000

   *param = FindWindow(title)
   While *param\hWnd <> GetForegroundWindow_()
      If (timeoutSec > 0) And (ElapsedMilliseconds() > endTime)
         timebreak = #True
         Break
      EndIf
      Delay(250)
      *param = FindWindow(title)
   Wend

   If timebreak
      ProcedureReturn 0
   Else
      ProcedureReturn *param\hWnd
   EndIf
EndProcedure

ProcedureDLL WinWaitClose(title.s, timeout)
  Protected time = ElapsedMilliseconds() + (timeout * 1000)
  Protected timebreak

  If Not WinExists(title)
    ProcedureReturn #True
  EndIf
  While WinExists(title)
    If timeout
      If ElapsedMilliseconds() > time
        timebreak = #True
        Break
      EndIf
    EndIf
    Delay(250)
  Wend
  If timebreak
    ProcedureReturn #False
  Else
    ProcedureReturn #True
  EndIf
EndProcedure

ProcedureDLL WinWaitNotActive(title.s, timeout)
   Protected time = ElapsedMilliseconds() + (timeout * 1000)
   Protected timebreak
   Protected *param.WinParameter

   *param = FindWindow(title)
   If *param\hWnd = 0
      ProcedureReturn #True   ; <---- new
   EndIf

   While GetForegroundWindow_() = *param\hWnd
      If timeout
         If ElapsedMilliseconds() > time
            timebreak = #True
            Break
         EndIf
      EndIf
      Delay(250)
   Wend

   If timebreak
      ProcedureReturn #False
   Else
      ProcedureReturn #True
   EndIf
EndProcedure
; =====================================================================================================================
;                                                Done by Thomas Schulz
; =====================================================================================================================

 

Link to comment
Share on other sites

Hello very well thank you it is nice miss more than to complete the functions !!!! @Belini

example:

MouseDown ()

missing button management

WinMove ()

Autoit :

WinMove ( "title", "text", x, y [, width [, height [, speed]]] )

Your function :

WinMove(title, x, y, width = #PB_Ignore, height = #PB_Ignore)

lacks speed management

a lot of function remains to complete that already make a good start to rework

 

Edited by ghost911
Link to comment
Share on other sites

My biggest concern is not even the size but the protection that in the case of Autoit is very fragile.

Link to comment
Share on other sites

  • 3 months later...

Hello I am currently working on the code converter how to find a variable in another autoit file

the converter will be programmed in the language of autoit thank you

 

I want to be able to invert the $ of the variables

 
Edited by ghost911
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...