Sign in to follow this  
Followers 0
layer

AutoIt Command Line

13 posts in this topic

just an autoit command line... very simple :D

enjoy :)

; many thanks for Josbe for posting a WONDERFUL example on www.autoscript.com/forum/index.php? on making cool and stylish GUI's! :D
Global $iscut = 0
Opt ("WinWaitDelay", 20); If the value is less, it's more easy to move the window.
Opt ("GuiResizeMode", 800);
Local $move = 0, $offset

;gui variables, rather then including guiconstants..
$WS_POPUP = 0x80000000
$WS_BORDER = 0x00800000

$hWnd = GUICreate("Speedy", 400, 100, -1, -1, BitOR($WS_POPUP, $WS_BORDER))
$border = GUICtrlCreateLabel(@ScriptDir, 0, 0, 340, 18)
GUICtrlSetResizing($border, "")
GUICtrlSetCursor($border, 9)
GUICtrlSetBkColor($border, 0x00FF00)
$cmd = GUICtrlCreateInput("", 5, 50, 290, 20)
$exec = GUICtrlCreateButton("Exec", 300, 48, 50)
GUICtrlSetTip($exec, "Execute command")
$close = GUICtrlCreateButton("X", 380, 0, 20, 20)
GUICtrlSetTip($close, "Exit")
$min = GUICtrlCreateButton("V", 360, 0, 20, 20)
GUICtrlSetTip($min, "Minimize")
$cut = GUICtrlCreateButton("^", 340, 0, 20, 20)
GUICtrlSetTip($cut, "Cut window")
GUISetState(@SW_SHOW, $hWnd)
While 1
   $get = GUIGetMsg()
   If $get = $close Then Exit
   If $get = $min Then GUISetState(@SW_MINIMIZE, $hWnd)
   If $get = $cut Then
      If $iscut = 0 Then
         Opt ("WinWaitDelay", 1)
         $winpos = WinGetPos($hWnd)
         $iscut = 1
         For $i = 100 To 20 Step - 1
            WinMove($hWnd, "", $winpos[0], $winpos[1], 400, $i)
         Next
      ElseIf $iscut = 1 Then
         $winpos = WinGetPos($hWnd)
         $iscut = 0
         For $n = 20 To 100 Step 1
            WinMove($hWnd, "", $winpos[0], $winpos[1], 400, $n)
         Next
      EndIf
   EndIf
   If $move Then
      $mousepos = MouseGetPos()
      WinMove($hWnd, "", $mousepos[0] + $x_offset, $mousepos[1] + $y_offset)
   EndIf
   If $get = $border Then $move = Not $move
   If $move Then
      $mousepos = MouseGetPos()
      $winpos = WinGetPos($hWnd)
      $x_offset = $winpos[0] - $mousepos[0]
      $y_offset = $winpos[1] - $mousepos[1]
   EndIf
   If $get = $exec Then
      _ExecCommand(GUICtrlRead($cmd))
   EndIf
WEnd

Func _ExecCommand($command);based off SlimShady's _Execute command! :D
   $command = StringReplace($command, '"', '""')
   StringReplace($command, '"', '"')
   RunWait(@AutoItExe & ' /c "Exit(' & $command & ')"', @WorkingDir)
EndFunc  ;==>_ExecCommand

FootbaG

Share this post


Link to post
Share on other sites



Very cool :)

I suggest you change the drag thing a bit. When I move it I have to mouse down again for it to stop, it should stop on mouse up.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

yea, theres something wrong with that damn window.. i know that when u click it, u have to click it again to drop it, but also, if i move my mouse faster then slow... the mouse cursor moves off the GUI label thats acting as a border... and ive had no luck with all the mouseup and mousedown functions, whether it be with GetCursorInfo or whatever.. or GUIGetMsg()...


FootbaG

Share this post


Link to post
Share on other sites

You could cheat and use IsPressed.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

I'll see if i can help you


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

yea.. i was thinking of that, but im trying to use as little outside resources as possible :) and also, do you know, if it's possible to use the au3.api file, with an input control in autoit? just so even the noobiesh of the noobiesh could know how to use commands... :D


FootbaG

Share this post


Link to post
Share on other sites

i don't know


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This what you want?

If $move Then
      $mousepos = MouseGetPos()
      WinMove($hWnd, "", $mousepos[0] + $x_offset, $mousepos[1] + $y_offset)
   EndIf
   If $get = $border Then
      $move = Not $move
      $mousepos = MouseGetPos()
      $winpos = WinGetPos($hWnd)
      $x_offset = $winpos[0] - $mousepos[0]
      $y_offset = $winpos[1] - $mousepos[1]
   EndIf

*EDIT*

Might not have been clear. I changed:

If $get = $border Then $move = Not $move
   If $move Then

To:

If $get = $border Then
       $move = Not $move
Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

made another change I made the cursor change to the arrows while moving only.

; many thanks for Josbe for posting a WONDERFUL example on www.autoscript.com/forum/index.php? on making cool and stylish GUI's! :D
Global $iscut = 0
Opt ("WinWaitDelay", 20); If the value is less, it's more easy to move the window.
Opt ("GuiResizeMode", 800);
Local $move = 0, $offset

;gui variables, rather then including guiconstants..
$WS_POPUP = 0x80000000
$WS_BORDER = 0x00800000

$hWnd = GUICreate("Speedy", 400, 100, -1, -1, BitOR($WS_POPUP, $WS_BORDER))
$border = GUICtrlCreateLabel(@ScriptDir, 0, 0, 340, 18)
GUICtrlSetResizing($border, "")
GUICtrlSetBkColor($border, 0x00FF00)
$cmd = GUICtrlCreateInput("", 5, 50, 290, 20)
$exec = GUICtrlCreateButton("Exec", 300, 48, 50)
GUICtrlSetTip($exec, "Execute command")
$close = GUICtrlCreateButton("X", 380, 0, 20, 20)
GUICtrlSetTip($close, "Exit")
$min = GUICtrlCreateButton("V", 360, 0, 20, 20)
GUICtrlSetTip($min, "Minimize")
$cut = GUICtrlCreateButton("^", 340, 0, 20, 20)
GUICtrlSetTip($cut, "Cut window")
GUISetState(@SW_SHOW, $hWnd)
While 1
   $get = GUIGetMsg()
   If $get = $close Then Exit
   If $get = $min Then GUISetState(@SW_MINIMIZE, $hWnd)
   If $get = $cut Then
      If $iscut = 0 Then
         Opt ("WinWaitDelay", 1)
         $winpos = WinGetPos($hWnd)
         $iscut = 1
         For $i = 100 To 20 Step - 1
            WinMove($hWnd, "", $winpos[0], $winpos[1], 400, $i)
         Next
      ElseIf $iscut = 1 Then
         $winpos = WinGetPos($hWnd)
         $iscut = 0
         For $n = 20 To 100 Step 1
            WinMove($hWnd, "", $winpos[0], $winpos[1], 400, $n)
         Next
      EndIf
   EndIf
   If $move Then
      $mousepos = MouseGetPos()
      WinMove($hWnd, "", $mousepos[0] + $x_offset, $mousepos[1] + $y_offset)
   EndIf
   If $get = $border Then
        $move = Not $move
        if $move Then
            GUICtrlSetCursor($border, 9)
        Else
            GUICtrlSetCursor($border, -1)
        Endif
      $mousepos = MouseGetPos()
      $winpos = WinGetPos($hWnd)
      $x_offset = $winpos[0] - $mousepos[0]
      $y_offset = $winpos[1] - $mousepos[1]
   EndIf
   If $get = $exec Then
      _ExecCommand(GUICtrlRead($cmd))
   EndIf
WEnd

Func _ExecCommand($command);based off SlimShady's _Execute command! :D
   $command = StringReplace($command, '"', '""')
   StringReplace($command, '"', '"')
   RunWait(@AutoItExe & ' /c "Exit(' & $command & ')"', @WorkingDir)
EndFunc ;==>_ExecCommand

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

errr, nice work!, lol, thanks ejoc for your support! :)


FootbaG

Share this post


Link to post
Share on other sites

perhaps, for those of you who prefer:

$border = GUICtrlCreateLabel(FileGetShortName(@ScriptDir), 0, 0, 340, 18)

instead of the full blown name of the script dir..


FootbaG

Share this post


Link to post
Share on other sites

Accept Enter to execute command:

$exec = GUICtrlCreateButton("Exec", 300, 48, 50, -1, 1)

Normally I would use $BS_DEFPUSHBUTTON, but you arent using GUIConstants.au3


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

fixed it up, now $BS_DEFPUSHBUTTON is set on the "Exec" button, and a new hotkey was added, "Ctrl+Z" to clear the inout field...

; many thanks for Josbe for posting a WONDERFUL example on www.autoscript.com/forum/index.php? on making cool and stylish GUI's! :D
;thanks ejoc for making the custom border work! :)
Global $iscut = 0
Opt ("WinWaitDelay", 20); If the value is less, it's more easy to move the window.
Opt ("GuiResizeMode", 800);
Local $move = 0, $offset
HotKeySet("^z", "Clear")

;gui variables, rather then including guiconstants..
$WS_POPUP = 0x80000000
$WS_BORDER = 0x00800000
$BS_DEFPUSHBUTTON   = 0x0001

$hWnd = GUICreate("Speedy", 400, 100, -1, -1, BitOR($WS_POPUP, $WS_BORDER))
$border = GUICtrlCreateLabel(FileGetShortName(@ScriptDir), 0, 0, 340, 18)
GUICtrlSetResizing($border, "")
GUICtrlSetBkColor($border, 0x00FF00)
$cmd = GUICtrlCreateInput("", 5, 50, 290, 20)
$ctrlzlabel = GUICtrlCreateLabeL("Ctrl+z to clear SpeedyCommandLine", 5, 75, 200)
GUICtrlSetFont($ctrlzlabel, 9, 400, 0, "Comic Sans MS")
$exec = GUICtrlCreateButton("Exec", 300, 48, 50, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetTip($exec, "Execute command")
$close = GUICtrlCreateButton("X", 380, 0, 20, 20)
GUICtrlSetTip($close, "Exit")
$min = GUICtrlCreateButton("V", 360, 0, 20, 20)
GUICtrlSetTip($min, "Minimize")
$cut = GUICtrlCreateButton("^", 340, 0, 20, 20)
GUICtrlSetTip($cut, "Cut window")
GUISetState(@SW_SHOW, $hWnd)
While 1
   $get = GUIGetMsg()
   If $get = $close Then Exit
   If $get = $min Then GUISetState(@SW_MINIMIZE, $hWnd)
   If $get = $cut Then
      If $iscut = 0 Then
         Opt ("WinWaitDelay", 1)
         $winpos = WinGetPos($hWnd)
         $iscut = 1
         For $i = 100 To 20 Step - 1
            WinMove($hWnd, "", $winpos[0], $winpos[1], 400, $i)
         Next
      ElseIf $iscut = 1 Then
         $winpos = WinGetPos($hWnd)
         $iscut = 0
         For $n = 20 To 100 Step 1
            WinMove($hWnd, "", $winpos[0], $winpos[1], 400, $n)
         Next
      EndIf
   EndIf
   If $move Then
      $mousepos = MouseGetPos()
      WinMove($hWnd, "", $mousepos[0] + $x_offset, $mousepos[1] + $y_offset)
   EndIf
   If $get = $border Then
        $move = Not $move
        if $move Then
            GUICtrlSetCursor($border, 9)
        Else
            GUICtrlSetCursor($border, -1)
        Endif
      $mousepos = MouseGetPos()
      $winpos = WinGetPos($hWnd)
      $x_offset = $winpos[0] - $mousepos[0]
      $y_offset = $winpos[1] - $mousepos[1]
   EndIf
   If $get = $exec Then
      _ExecCommand(GUICtrlRead($cmd))
   EndIf
WEnd

Func _ExecCommand($command);based off SlimShady's _Execute command! :D
   $command = StringReplace($command, '"', '""')
   StringReplace($command, '"', '"')
   RunWait(@AutoItExe & ' /c "Exit(' & $command & ')"', @WorkingDir)
EndFunc;==>_ExecCommand 

Func Clear()
    GUICtrlSetData($cmd, "", "")
EndFunc

:)


FootbaG

Share this post


Link to post
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
Sign in to follow this  
Followers 0