Jump to content

Form Creater Project


 Share

Recommended Posts

So I was bored at work today and decided to id give a shot at making things a bit easier for future AutoIT scripts I write. So far it just makes a new blank form and the option to add an input box by clicking on two spots on the form, trying to think up a way to use mousedrag so that setting the deminsions are more visable.

This was not as easy as I thought it would be but I'm still learning how to program!

Somehow I went braindead and figured I'd let other people toss out ideas or heck if anyone wants to work on it with me feel free to aim me.

AIM: Arcaik71

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                 Autoit Form Creater in the works            ;
;- Current Objectives                                           ;
;  - Removeable Objects                                       ;
;  - Set Object properties                                     ; 
;  - Moused drag for (x,y) (x1,y1) box-type objects           ;
;  - output Form in code to notpad or .au3 file               ;
;  - Revise code to utilize arrays                             ;
;                                                               ;
;Author : Nezoic                                                 ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


#include <GUIConstants.au3>
$mainwindow = GUICreate("AutoIt Form Creater 1.0", 450, 70)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$btnExit = GUICtrlCreateButton("Exit", 400, 33, 40)
$btnCreateNewForm = GUICtrlCreateButton("Create", 355, 33, 40)
$btnNewInput = GUICtrlCreateButton("Input Field", 5, 5, 70)

GUICtrlCreateLabel ( "Form Size:", 300, 6, 52, 15); 
$FormX = GUICtrlCreateInput ( 0, 355, 5, 40, 20)
$FormY = GUICtrlCreateInput ( 0, 400, 5, 40, 20)

GUISwitch($mainwindow)
GUISetState()

while 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE OR $msg = $btnExit Then ExitLoop   
    If $msg = $GUI_EVENT_CLOSE OR $msg = $btnCreateNewForm Then CreateForm()
    If $msg = $btnNewInput AND WinExists("New Form") Then CreateInputFeild()
    sleep(10)
Wend

Func CreateForm()
   If WinExists("New Form") Then
      MsgBox(0, "STUPID", "A form is currently created")
      return
   EndIf
   $New_Form_Window = GUICreate("New Form", GUICtrlRead($FormX), GUICtrlRead($FormY))
   GUISwitch($New_Form_Window)
   GUISetState()
   AlignTBar()  
return
EndFunc

Func AlignTBar()
   $win_title = "New Form"
   If WinExists($win_title) Then
      WinActivate($win_title, "") 
      WinSetOnTop($win_title, "", 0)
      $formloc = WinGetPos("")
   Else
      MsgBox(0, "  STUPID  ", "No new form to create box")
      Exit
   EndIf
   $tx = $formloc[0]
   $ty = $formloc[1] - 100
   WinMove("AutoIt Form Creater 1.0", "", $tx, $ty)
EndFunc

Func CreateInputFeild()
   Opt("MouseCoordMode", 2)
   Dim $box, $MC1, $MC2
   $win_title = "New Form"
  
   If WinExists($win_title) Then
      WinActivate($win_title, "") 
      WinSetOnTop($win_title, "", 0) 
   else 
      MsgBox(0, "  STUPID  ", "No new form to create box")
      Exit
   EndIf

   while $box = 0
;;;;;;;;;;;;;;;;;;;;;; Put this junk in array or something;;;;;;;;;;;;;;;;;;;
      $pos = MouseGetPos()
      If _IsPressed('01') = 1 AND $MC1 = 0 then
         $pos = MouseGetPos()
         $x = $pos[0]
         $y = $pos[1]   
         $MC1 = 1 
         sleep(500)
      EndIf
      If _IsPressed('01') = 1 AND $MC1 = 1 then
         $pos = MouseGetPos()
         $x1 = $pos[0] - $x
         $y1 = $pos[1] - $y   
         $MC2 = 1 
      EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      if $MC1 = 1 AND $MC2 = 1 Then
         $NewInputBox = GUICtrlCreateInput ( 0, $x, $y, $x1, $y1)
         $box = 1
         MsgBox(0, "Feild created ","(X:" & $x & " , " & "Y:" & $y & ") - "_
         & "(X1:" & $x1 & " , " & "Y1:"& $y1 & ")")
       EndIf 
   Wend
return
EndFunc

Func CreateListWindow()
EndFunc

Func CreateCheckBox()
EndFunc

Func CreateBullet()
EndFunc


Func CLOSEClicked()
  If @GUI_WINHANDLE = $mainwindow Then 
      WinClose("AutoIt Form Creater 1.0", "")
  EndIf 
EndFunc

Func _IsPressed($hexKey)
  Local $aR, $bO
  
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf
  
  Return $bO
EndFunc
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...