Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/14/2013 in all areas

  1. To post code on the forum, please use the following procedure: Click the Code button on the editor toolbar. Select the code type (for most people this will either be AutoIt or Plain Text - AutoIt is the default) Paste or type your code and then click OK.
    2 points
  2. To make that script a little more robust, I would put each of your functions in a loop and test them until they are correct. For example. Do WinActivate ("Windows Security") Sleep(500) Until WinActive("Windows Security") Same with Others. ControlSetText and ControlGetText ControlFocus and ControlGetFocus etc... And also check for whatever is supposed to occur after your ControlClick.
    2 points
  3. Arrays are copy on write, meaning they exist as a reference to the original until you change it. It won't be copied just because it was passed by value.
    2 points
  4. Yashied

    WinAPIEx UDF

    LAST VERSION - 3.8 03-Jul-12 This library contains the WinAPI functions are not included for unknown reasons to the native AutoIt WinAPI library. I use this UDF in nearly all of my programs, and decided to share it with the AutoIt community. I agree that over time some of these functions will be part of the native AutoIt library, but still... The library includes some undocumented, but useful functions (eg _WinAPI_GetFontResourceInfo()). The library also contains all the necessary constants to work with the appropriate functions. Most functions from this UDF intended for experienced users, but beginners will find the same lot of useful information for yourself. I will be to periodically add new functions to the library. The archive contains WinAPIEx library, and as usual an excellent examples from me. Some examples I took from this forum and to simplify them for better understanding. For those who use SciTE (full version) I have prepared the au3.userudfs.properties and au3.user.calltips.api files to highlight functions from this UDF in your scripts. Just copy this files to ...SciTEProperties and ...SciTEAPI, respectively. I hope this UDF will be useful for many as for me. I look forward to any feedback and suggestions. Maybe somebody wants to add new WinAPI functions? Credits Available functions Files to download WinAPIEx UDF v3.8 for AutoIt 3.3.6.1 Previous downloads: 27953 WinAPIEx UDF v3.8 for AutoIt 3.3.8.x Previous downloads: 14850
    1 point
  5. hi! i made the basic native arduino functions in autoit to control it trougth the serial port. it could be interesting for too many people you can find the codes here in my blog there are some more codes using arduino and autoit too xapus.blogspot.com
    1 point
  6. this is the project im working on it is almost done ;#GUIBuilder++.au3#================================== ;File Name.......:GUIBuilder++.au3 ;Creator.........:sean.campbell7 ;Created with....:Created with ISN AutoIt Studio ;Version.........:0.91 BETA ;============================================= Opt("GUIResizeMode", 802) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <editconstants.au3> #Include <GuiButton.au3> #include <array.au3> #include <misc.au3> #include <TabConstants.au3> $crc = 0 Global $guihandle = "$HGUI" $xx = 0 $au3 = "" $codescreen = GUICreate("compiled code", 350, 350, -1, -1, $WS_CAPTION, $WS_EX_TOPMOST) $code = GUICtrlCreateEdit("", 20, 20, 310, 240, 2048, -1) GUICtrlSetBkColor($code, 0xFFFFFF) $cc = GUICtrlCreateButton("Copy", 220, 280, 100, 30, -1, -1) $ok = GUICtrlCreateButton("Ok", 120, 280, 100, 30, -1, -1) $sc = GUICtrlCreateButton("Save as", 20, 280, 100, 30, -1, -1) Global $ctrldata[1][8], $rdm = 1, $copyobj[7] $toolbar = GUICreate("GUIBuilder++", @DesktopWidth -5, @DesktopWidth -300, 0, 0, 0x00010000 + 0x00020000) $d = GUICtrlCreateButton("Date", 50, 300, 50, 50, -1, -1) $pb = GUICtrlCreateButton("progress bar", 0, 300, 50, 50, -1, -1) $s = GUICtrlCreateButton("slider", 50, 250, 50, 50, -1, -1) $co = GUICtrlCreateButton("combo box", 0, 350, 50, 50, -1, -1) $li = GUICtrlCreateButton("listbox", 50, 400, 50, 50, -1, -1) $g = GUICtrlCreateButton("group", 0, 400, 50, 50, -1, -1) $t = GUICtrlCreateButton("treeview", 50, 350, 50, 50, -1, -1) $i = GUICtrlCreateButton("input", 0, 150, 50, 50, -1, -1) $l = GUICtrlCreateButton("Lable", 50, 100, 50, 50, -1, -1) $b = GUICtrlCreateButton("Button", 0, 100, 50, 50, -1, -1) $c = GUICtrlCreateButton("checkbox", 50, 150, 50, 50, -1, -1) $ic = GUICtrlCreateButton("icon", 0, 250, 50, 50, -1, -1) $im = GUICtrlCreateButton("image", 50, 200, 50, 50, -1, -1) $r = GUICtrlCreateButton("radiobox", 0, 200, 50, 50, -1, -1) $e = GUICtrlCreateButton("edit", 0, 450, 50, 50) $ca = GUICtrlCreateButton("calender", 50, 450, 50, 50) $prop = GUICtrlCreateButton("GUI properties", 0, 50, 100, 50) $iFile = GUICtrlCreateMenu("File") $iFile_Export = GUICtrlCreateMenuItem('E&xport' & @TAB & 'Ctrl + E',$iFile) GUISetState(@SW_SHOW, $toolbar) GUISetState(@SW_MAXIMIZE, $toolbar) Global $lao $GUIprop = GUICreate("Gui Properties", 350, 307, -1, -1, -1, $ws_ex_topmost + $WS_EX_TOOLWINDOW) $tab = GUICtrlCreatetab(20, 20, 310, 240, 1024, -1) GUICtrlCreateTabItem("General") $wintit = GUICtrlCreateInput("", 140, 110, 150, 22, -1, 512) $hgui = GUICtrlCreateInput("HGUI", 140, 80, 150, 22, -1, 512) GUICtrlCreateLabel("Window Title:", 40, 113, 80, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("Window handle:$", 40, 83, 96, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") $guihig = GUICtrlCreateInput(0, 140, 180, 50, 20, 8192, 512) GUICtrlCreateUpdown(-1) $guiwid = GUICtrlCreateInput("0", 140, 150, 50, 20, 8192, 512) GUICtrlCreateUpdown(-1) GUICtrlCreateLabel("GUI Hight:", 40, 183, 59, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("Px", 200, 183, 50, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("GUI Width:", 40, 153, 59, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("Px", 200, 153, 50, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateTabItem("") GUICtrlCreateLabel("GUI Colour", 40, 213, 71, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") $colour = GUICtrlCreateInput("0xF0F0F0", 140, 210, 75, 20, -1, 512) GUICtrlCreateButton("Colour", 220, 210, 50, 20, -1, -1) $gcl = GUICtrlCreateButton("Cancel", 180, 270, 100, 30, -1, -1) $gok = GUICtrlCreateButton("Ok", 80, 270, 100, 30, -1, -1) $ctrledit = GUICreate("Control editor", 230, 400, @DesktopWidth / 4 * 3, -1, $WS_CAPTION, $WS_EX_TOPMOST) $apply = GUICtrlCreateButton("apply", 15, 340, 100, 30) $compile = GUICtrlCreateButton("compile", 115, 340, 100, 30) GUICtrlCreateTab(10, 30, 210, 300, $TCS_VERTICAL) GUICtrlCreateTabItem("General") $xpos = GUICtrlCreateInput("", 60, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($xpos) GUICtrlCreateLabel("X", 50, 42, 22, 22) $ypos = GUICtrlCreateInput("", 120, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($ypos) GUICtrlCreateLabel("Y", 110, 42, 22, 22) $name = GUICtrlCreateInput("", 60, 100, 100, 22) GUICtrlCreateLabel("Data", 60, 85, 50, 22) GUICtrlCreateLabel("handle", 60, 125, 50, 22) $handle = GUICtrlCreateInput("", 60, 144, 100, 22) GUICtrlCreateTabItem("Apearance") $width1 = GUICtrlCreateInput("", 60, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($width1) $hight1 = GUICtrlCreateInput("", 120, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($hight1) GUICtrlCreateTabItem("Style") GUICtrlCreateTabItem("StyleEx") GUICtrlCreateTabItem("State") Global $key[1][2] GUISetState(@SW_SHOW, $ctrledit) $board = GUICreate("new window", 350, 350, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) $del = GUICtrlCreateDummy() $copy = GUICtrlCreateDummy() $paste = GUICtrlCreateDummy() Global $keys[3][2] $keys[0][1] = $del $keys[0][0] = "{del}" $keys[1][1] = $copy $keys[1][0] = "^c" $keys[2][1] = $paste $keys[2][0] = "^v" GUISetAccelerators($keys) GUISetState(@SW_SHOW, $board) While 1 $cMsg = GUIGetCursorInfo($board) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ok GUISetState(@SW_HIDE, $codescreen) GUISetState(@SW_SHOW, $board) $crc = 0 Case $prop $oo = WinGetClientSize($board) GUICtrlSetData($wintit, WinGetTitle($board)) GUICtrlSetData($guihig, $oo[1]) GUICtrlSetData($guiwid, $oo[0]) GUISetState(@SW_SHOW, $GUIprop) $xx = 1 Case $gok WinMove($board, "", @DesktopWidth / 2 - GUICtrlRead($guihig) / 2, @DesktopHeight / 2 - GUICtrlRead($guiwid) / 2, GUICtrlRead($guiwid) + 16, GUICtrlRead($guihig) + 34) WinSetTitle($board, "", GUICtrlRead($wintit)) $guihandle = "$" & GUICtrlRead($hgui) $xx = 0 GUISetState(@SW_Hide, $GUIprop) GUISetState(@SW_SHOW, $board) Case $gcl GUISetState(@SW_hide, $GUIprop) GUISetState(@SW_SHOW, $board) $xx = 0 Case $sc GUISetState(@SW_HIDE, $codescreen) GUISetState(@SW_HIDE, $board) GUISetState(@SW_HIDE, $ctrledit) $dat = FilesaveDialog("Save script", "", "Autoit 3 script files(*.au3)") If $dat <> "" Then FileWrite($dat & ".au3", $au3) endif $crc = 0 GUISetState(@SW_SHOW, $ctrledit) GUISetState(@SW_SHOW, $board) Case $iFile_Export _compile(0) GUISetState(@SW_HIDE, $codescreen) GUISetState(@SW_HIDE, $board) GUISetState(@SW_HIDE, $ctrledit) $dat = FilesaveDialog("Save script", "", "Autoit 3 script files(*.au3)") If $dat <> "" Then $id = FileOpen($dat & ".au3",2) FileWrite($id, $au3) endif GUISetState(@SW_SHOW, $ctrledit) GUISetState(@SW_SHOW, $board) Case $cc ClipPut($au3) Case $width1, $hight1 _itemsetsize(GUICtrlRead($width1), GUICtrlRead($hight1)) Case $xpos, $ypos _itemsetpos(GUICtrlRead($xpos), GUICtrlRead($ypos)) Case $name _itemsetname(GUICtrlRead($name)) Case $apply _itemsetname(GUICtrlRead($name)) _itemsetpos(GUICtrlRead($xpos), GUICtrlRead($ypos)) _itemsetsize(GUICtrlRead($width1), GUICtrlRead($hight1)) If GUICtrlRead($handle) <> "" Then For $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $lao and $lao <> "" Then $ctrldata[$i][7] = "$" & GUICtrlRead($handle) EndIf Next EndIf Case $del _deleteitem($lao) Case $copy _copy() Case $paste _paste() Case -7, -11 If $cMsg[4] > 0 Then _guictrldrag($cMsg[4], $board) Case $b _createitem("button") Case $l _createitem("label") case $pb _createitem("progress") case $i _createitem("input") Case $e _createitem("edit") Case $c _createitem("checkbox") Case $r _createitem("radiobox") Case $s _createitem("slider") Case $ic _createitem("icon") case $im _createitem("image") Case $d _createitem("date") case $ca _createitem("calender") Case $co _createitem("combo") Case $li _createitem("listbox") case $t _createitem("tree") Case $g _createitem("group") Case $compile _compile() Case $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE, $board) GUISetState(@SW_HIDE, $ctrledit) GUISetState(@SW_HIDE, $codescreen) GUISetState(@SW_HIDE, $GUIprop) Case $GUI_EVENT_RESTORE GUISetState(@SW_show, $ctrledit) GUISetState(@SW_Show, $board) If $crc Then GUISetState(@SW_SHOW, $codescreen) If $xx Then GUISetState(@SW_SHOW, $GUIprop) EndSwitch WinSetOnTop($ctrledit, "", 1) WEnd Func _guictrldrag($control, $hgui) $cbutton = $control $lao = $control $cInfo = GUIGetCursorInfo($hGUI) $aPos = ControlGetPos($hGUI, "", $cButton) $iSubtractX = $cInfo[0] - $aPos[0] $iSubtractY = $cInfo[1] - $aPos[1] Sleep(200) $cInfo = GUIGetCursorInfo($hGUI) If $cInfo[2] = 1 Then $cInfo = GUIGetCursorInfo($hGUI) If $cInfo[4] = $cButton Then Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $cButton, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) For $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $control and $control <> "" Then $ctrldata[$i][1] = $cInfo[0] - $iSubtractX $ctrldata[$i][2] = $cInfo[1] - $iSubtracty EndIf Next For $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $lao and $lao <> "" Then GUICtrlSetData($xpos, $ctrldata[$i][1]) GUICtrlSetData($ypos, $ctrldata[$i][2]) GUICtrlSetData($width1, $ctrldata[$i][3]) GUICtrlSetData($hight1, $ctrldata[$i][4]) GUICtrlSetData($name, $ctrldata[$i][5]) GUICtrlSetData($handle, StringTrimLeft($ctrldata[$i][7], 1)) EndIf next Until Not $cInfo[2] EndIf Else return 0 EndIf Do Until GUIGetMsg() = 0 _itemsetpos(_round($cInfo[0] - $iSubtractX), _round($cInfo[1] - $iSubtractY)) EndFunc Func _createitem($type, $x = 0, $y = 0, $width = -1, $hight = -1) $rdm += 1 Switch $type Case "button" If $width = -1 then $width = 50 If $hight = -1 then $hight = 30 $ct = GUICtrlCreateButton("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "label" If $width = -1 then $width = 100 If $hight = -1 then $hight = 20 $ct = GUICtrlCreateLabel("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "input" If $width = -1 then $width = 100 If $hight = -1 then $hight = 20 $ct = GUICtrlCreateinput("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "Edit" If $width = -1 then $width = 150 If $hight = -1 then $hight = 150 $ct = GUICtrlCreateEdit("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "progress" If $width = -1 then $width = 100 If $hight = -1 then $hight = 20 $ct = GUICtrlCreateProgress($x, $y, $width, $hight) GUICtrlSetData(-1, 50) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = 50 Case "checkbox" If $width = -1 then $width = 50 If $hight = -1 then $hight = 20 $ct = GUICtrlCreateCheckbox("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "radiobox" If $width = -1 then $width = 50 If $hight = -1 then $hight = 20 $ct = GUICtrlCreateRadio("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "slider" If $width = -1 then $width = 150 If $hight = -1 then $hight = 20 $ct = GUICtrlCreateSlider($x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = 0 Case "icon" If $width = -1 then $width = 50 If $hight = -1 then $hight = 50 $ct = GUICtrlCreateIcon(@scriptdir & "\dummy.ico", -1, $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "image" If $width = -1 then $width = 50 If $hight = -1 then $hight = 50 $ct = GUICtrlCreatePic(@scriptdir & "\dummy.bmp", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "" Case "date" If $width = -1 then $width = 150 If $hight = -1 then $hight = 20 $ct = GUICtrlCreateDate("", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "" Case "calender" If $width = -1 then $width = 180 If $hight = -1 then $hight = 164 $ct = GUICtrlCreateMonthCal("", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "" Case "combo" If $width = -1 then $width = 50 If $hight = -1 then $hight = 30 $ct = GUICtrlCreateCombo("my text", $x, $y, $width, $hight) GUICtrlSetData(-1, "item1|item2|item3", "item1") ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "item1|item2|item3" Case "listbox" If $width = -1 then $width = 150 If $hight = -1 then $hight = 150 $ct = GUICtrlCreatelist("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "tree" If $width = -1 then $width = 150 If $hight = -1 then $hight = 150 $ct = GUICtrlCreateTreeView("my text", $x, $y, $width, $hight) $td = GUICtrlCreateTreeViewItem("my text", $ct) GUICtrlCreateTreeViewItem("sub", $td) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" Case "group" If $width = -1 then $width = 150 If $hight = -1 then $hight = 150 $ct = GUICtrlCreateGroup("my text", $x, $y, $width, $hight) ReDim $ctrldata[$rdm + 1][8] $ctrldata[$rdm][0] = $ct $ctrldata[$rdm][1] = $x $ctrldata[$rdm][2] = $y $ctrldata[$rdm][3] = $width $ctrldata[$rdm][4] = $hight $ctrldata[$rdm][5] = "my text" EndSwitch GUICtrlSetCursor($ct, 9) $ctrldata[$rdm][6] = $type $ctrldata[$rdm][7] = "$" & $type & $rdm - 1 $lao = $ct For $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $lao and $lao <> "" Then GUICtrlSetData($xpos, $ctrldata[$i][1]) GUICtrlSetData($name, $ctrldata[$i][5]) GUICtrlSetData($width1, $ctrldata[$i][3]) GUICtrlSetData($hight1, $ctrldata[$i][4]) GUICtrlSetData($ypos, $ctrldata[$i][2]) GUICtrlSetData($handle, StringTrimLeft($ctrldata[$i][7], 1)) EndIf Next ControlFocus($board, "", GUICtrlGetHandle($ct)) EndFunc Func _deleteitem($item) GUICtrlDelete($item) For $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $item and $item <> "" Then _ArrayDelete($ctrldata, $i) $lao = $ctrldata[$i - 1][0] GUICtrlSetData($xpos, $ctrldata[$i - 1][1]) GUICtrlSetData($name, $ctrldata[$i - 1][5]) GUICtrlSetData($width1, $ctrldata[$i - 1][3]) GUICtrlSetData($hight1, $ctrldata[$i - 1][4]) GUICtrlSetData($ypos, $ctrldata[$i - 1][2]) GUICtrlSetData($handle, StringTrimLeft($ctrldata[$i - 1][7], 1)) EndIf Next ControlFocus($board, "", $item) EndFunc Func _itemsetpos($x, $y, $item = $lao) GUICtrlSetPos($item, $x, $y) for $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $item and $item <> "" Then $ctrldata[$i][1] = $x $ctrldata[$i][2] = $y GUICtrlSetData($xpos, $ctrldata[$i][1]) GUICtrlSetData($ypos, $ctrldata[$i][2]) EndIf Next EndFunc Func _itemsetname($name, $item = $lao) GUICtrlSetdata($item, $name) for $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $item and $item <> "" Then $ctrldata[$i][5] = $name EndIf Next EndFunc Func _itemsetsize($x, $y, $item = $lao) for $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $item and $item <> "" Then $ctrldata[$i][3] = $x $ctrldata[$i][4] = $y GUICtrlSetPos($item, $ctrldata[$i][1], $ctrldata[$i][2], $x, $y) EndIf Next EndFunc Func _round($number) If $number < 0 then Return 0 Global $n = $Number $ilen = StringLen($n) if StringTrimLeft($n, $ilen - 1) = 5 or StringTrimleft($n, $ilen - 1) = 0 Then Return $n if StringTrimLeft($n, $ilen - 1) > 5 Then Do $ilen = StringLen($n) if StringTrimLeft($n, $ilen - 1) <= 7 Then ;so that 7 will become 5 not 10 $n -= 1 ElseIf StringTrimLeft($n, $ilen - 1) >= 7 Then $n += 1 EndIf $ilen = StringLen($n) Until StringTrimLeft($n, $ilen - 1) = 5 or StringTrimleft($n, $ilen - 1) = 0 Else Do $ilen = StringLen($n) if StringTrimLeft($n, $ilen - 1) < 3 Then ;so that 3 will become 5 not 0 $n -= 1 ElseIf StringTrimLeft($n, $ilen - 1) >= 3 Then $n += 1 EndIf $ilen = StringLen($n) Until StringTrimLeft($n, $ilen - 1) = 5 or StringTrimleft($n, $ilen - 1) = 0 EndIf Return $n EndFunc Func _copy($item = $lao) For $i = 0 to UBound($ctrldata) - 1 If $ctrldata[$i][0] = $item and $item <> "" Then $copyobj[1] = $ctrldata[$i][1] $copyobj[2] = $ctrldata[$i][2] $copyobj[3] = $ctrldata[$i][3] $copyobj[4] = $ctrldata[$i][4] $copyobj[5] = $ctrldata[$i][5] $copyobj[6] = $ctrldata[$i][6] EndIf Next EndFunc Func _paste() If $copyobj[1] <> "" Then _createitem($copyobj[6], _round($cMsg[0]), _round($cMsg[1]), $copyobj[3], $copyobj[4]) _itemsetname($copyobj[5]) GUICtrlSetData($name, $copyobj[5]) EndIf EndFunc Func _compile($iflag=1) Global $au3 = ";created with guibuilder++" & @crlf & "#include <GUIConstantsEx.au3>" & @CRLF & "#include <WindowsConstants.au3>" & @CRLF $size = WinGetClientSize($board) $au3 &= $guihandle & " = GUICreate('" & WinGetTitle($board) & "'," & $size[0] & "," & $size[1] & ")" & @CRLF For $i = 0 To UBound($ctrldata) - 1 Switch $ctrldata[$i][6] Case "button" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateButton('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "label" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateLabel('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "input" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateInput('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "Edit" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateEdit('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "progress" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateProgress('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "checkbox" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateCheckbox('jmn" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "radiobox" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateRadio('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "slider" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateSlider('" & $ctrldata[$i][1] & "'," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf & "guictrlsetdata(-1," & $ctrldata[$i][5] & ")" & @crlf Case "icon" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateIcon('" & $ctrldata[$i][5] & "',-1," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "image" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreatePic('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "date" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateDate('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "calender" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateMonthCal('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "combo" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateCombo('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "listbox" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateList('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "tree" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateTreeView('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf Case "group" $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateGroup('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf EndSwitch next $au3 &= "GUISetState()" & @CRLF & "while 1" & @CRLF & @TAB & "Switch GUIGetMsg()" & @CRLF & @TAB & @TAB & "Case -3" & @CRLF & @TAB & "Exit" & @crlf & @TAB & "EndSwitch" & @CRLF & "WEnd" if $iflag Then GUICtrlSetData($code, $au3) GUISetState(@SW_SHOW, $codescreen) EndIf EndFunc
    1 point
  7. I forgot to mention, have a look at WinAPIEx as well, since I noticed these... _WinAPI_MonitorFromPoint( _WinAPI_GetMonitorInfo(
    1 point
  8. guinness, Good advice, as warned here...
    1 point
  9. guinness

    GuiCtrlSetTip Timeout

    You're welcome. Plus, you did have the best answer!
    1 point
  10. Just an update..further to my last post I have spend a few more hours tweaking this script..I added the winactivate loop in a few places and it seems to be very stable now even if I click elsewhere on the screen it returns to the pop up, after my chat with cor I now instead of calling arse to set the router up I create a tcp socket and telnet into the router to set the static arp up and show a progress bar just to waste a few seconds while the telnet is established and cmds sent and to finish it all at the end have a msgbox popup to show the script has completed and play the std windows alert.. next is to do some error checking on the telnet session by pinging the router first to make sure connection is established like cor does in arse.. regards Ricky
    1 point
  11. From reading the help file you should have seen this for ControlClick
    1 point
  12. I like linear error handling: $bcontinue = true $hwin = WinWait("[TITLE:Info]") If IsHWnd($hwin) Then ConsoleWrite("able to find window" & @CRLF) Else $bcontinue = false ConsoleWrite("UNable to find window"& @CRLF) EndIf If $bcontinue Then If ControlClick($hwin, "OK", "[CLASS:Button; INSTANCE:1]", "left", 1) Then ConsoleWrite("able to click button" & @CRLF) Else $bcontinue = false ConsoleWrite("UNable to click button"& @CRLF) EndIf EndIf ; expect window to close...added just to demonstrate another block of code If $bcontinue Then If WinWaitClose($hwin, "", 5) Then ConsoleWrite("able to close window from button click" & @CRLF) Else $bcontinue = false ConsoleWrite("UNable to close window from button click" & @CRLF) EndIf EndIf
    1 point
  13. Good point. Never declare variables inside loops, ever!
    1 point
  14. Move your array declaration outside of the loop.
    1 point
  15. When posting AutoIt code please use the blue A in the editor. ControlClick comes to mind. Case $iButton_Process _DeleteSelectedFile() ; and many lines of code here Case $iEnter ControlClick($hGUI, '', $iButton_Process) EndSwitch
    1 point
  16. Yeee thats how i like it (have i seen that code before?)
    1 point
  17. Good luck with that. I will ask a Mod to block you for about two days? You OK with that? -_0
    1 point
  18. mikell

    Help with WMI query

    $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery( "SELECT LastBootUpTime FROM Win32_OperatingSystem") For $objItem In $colItems $LastBootUpTime = WMIDateStringToDate($objItem.LastBootUpTime) Next Msgbox(0,"", $LastBootUpTime) Func WMIDateStringToDate($dtmDate) ; yyyy/mm/dd/hh/mm/ss Return (StringLeft($dtmDate, 4) & "/" & StringMid($dtmDate, 7, 2) _ & "/" & StringMid($dtmDate, 5, 2) & "/" & StringMid($dtmDate, 9, 2) _ & "/" & StringMid($dtmDate, 11, 2) & "/" & StringMid($dtmDate,13, 2)) EndFunc For WMI things you should use scriptomatic.au3
    1 point
  19. Nessie

    Audio Question

    If your audio card support that feature you can detect it via Under Vista and above you can try IMMDeviceEnumerator::GetDefaultAudioEndpoint() and IMMDevice::GetState() to check if a jack is connected or not. Under XP you can use 'waveInGetNumDevs'. Hi!
    1 point
  20. Thanks! Learned something new today
    1 point
  21. WideBoyDixon

    Mouse Wrap

    I think I've got my logic right but, as usual, I'm prepared to be wrong. I've used MonitorFromPoint and GetMonitorInfo to determine when and where to wrap especially with multiple monitors. Let me know what you think. HotKeySet("{ESC}", "_Quit") Global $hDLL = DllOpen("user32.dll") Global $rDesktop = WinGetPos("Program Manager") Global $gMonitorInfo = DllStructCreate("int;int[4];int[4];int;char[32]") DllStructSetData($gMonitorInfo, 1, DllStructGetSize($gMonitorInfo)) _Main() Exit Func _Main() Local $aMP, $hMonitor, $rMonitor, $sText While 1 Sleep(10) $aMP = MouseGetPos() $hMonitor = _GetMonitorFromPoint($aMP[0], $aMP[1]) If $hMonitor <> 0 Then $rMonitor = _GetMonitorRect($hMonitor) ; Left If ($aMP[0] - $rMonitor[0]) = 0 Then If _GetMonitorFromPoint($aMP[0] - 1, $aMP[1]) = 0 Then If _GetMonitorFromPoint($aMP[0] + $rDesktop[2] - 2, $aMP[1]) = 0 Then MouseMove($aMP[0] + $rMonitor[2] - 2, $aMP[1], 0) Else MouseMove($aMP[0] + $rDesktop[2] - 2, $aMP[1], 0) EndIf EndIf EndIf ; Top If ($aMP[1] - $rMonitor[1]) = 0 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] - 1) = 0 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] + $rDesktop[3] - 2) = 0 Then MouseMove($aMP[0], $aMP[1] + $rMonitor[3] - 2, 0) Else MouseMove($aMP[0], $aMP[1] + $rDesktop[3] - 2, 0) EndIf EndIf EndIf ; Right If ($aMP[0] - $rMonitor[0]) = $rMonitor[2] - 1 Then If _GetMonitorFromPoint($aMP[0] + 1, $aMP[1]) = 0 Then If _GetMonitorFromPoint($aMP[0] - $rDesktop[2] + 2, $aMP[1]) = 0 Then MouseMove($aMP[0] - $rMonitor[2] + 2, $aMP[1], 0) Else MouseMove($aMP[0] - $rDesktop[2] + 2, $aMP[1], 0) EndIf EndIf EndIf ; Bottom If ($aMP[1] - $rMonitor[1]) = $rMonitor[3] - 1 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] + 1) = 0 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] - $rDesktop[3] + 2) = 0 Then MouseMove($aMP[0], $aMP[1] - $rMonitor[3] + 2, 0) Else MouseMove($aMP[0], $aMP[1] - $rDesktop[3] + 2, 0) EndIf EndIf EndIf EndIf WEnd EndFunc ;==>_Main Func _GetMonitorFromPoint($iX, $iY) Local $aRet = DllCall($hDLL, "hwnd", "MonitorFromPoint", "int", $iX, "int", $iY, "int", 0) Return $aRet[0] EndFunc ;==>_GetMonitorFromPoint Func _GetMonitorRect($hMonitor) Local $aRet = DllCall($hDLL, "int", "GetMonitorInfo", "hwnd", $hMonitor, "ptr", DllStructGetPtr($gMonitorInfo)) Local $aRect[4] For $i = 1 To 4 $aRect[$i - 1] = DllStructGetData($gMonitorInfo, 2, $i) Next $aRect[2] -= $aRect[0] $aRect[3] -= $aRect[1] Return $aRect EndFunc ;==>_GetMonitorRect Func _Quit() DllClose($hDLL) Exit EndFunc ;==>_Quit EDIT: Some script tidying and removed wrapping line WBD
    1 point
  22. James

    ColourUnderMouse

    Howdy fellow nerds (I may be speaking for myself here, said my Dad), I got annoyed when looking at a website and I wanted to know what that cool green colour under my mouse was and if my friends were programming games for bots, and I was the only one with access to the game, they would ask me what the colour was and I had to take a screenshot, then find the colour exactly. Well frankly, its easier to make this than to do that all the f**kin time (Excuse my language, I'm an English Teenager!) I made this with a little bonus, which I decided to add when I couldn't see the colours, and I thought my script had broken. If your mouse is over a black colour then the label with the RGB code turns white and if your over white then the label turns black! *Applauds*, thankyou, thankyou. Anyways, without further adew here it is: ColourUnderMouse! #cs Name: Colour Under Mouse Author: James Brooks aka Secure_ICT Description: Shows colours under the mouse #ce #include <GuiConstants.au3> #include <Color.au3> #include <Misc.au3> $DLL = DllOpen("user32.dll") Global $Color, $hexcolor $GUI = GUICreate("Test", 170, 50, @DesktopWidth / 2 * 1.66, @DesktopHeight / 4 * 3.50, $WS_POPUP, $WS_EX_TOOLWINDOW) $cLabel = GUICtrlCreateLabel("", 5, 5, 100, 15) $iLabel = GUICtrlCreateLabel("RGB formatting", 5, 20, 100, 15) $eLabel = GUICtrlCreateLabel("Press ESC to escape!", 5, 35, 150, 15) GUICtrlSetColor(-1, 0x00000) WinSetOnTop($GUI, "", 1) GUISetState(@SW_SHOW) While Not _IsPressed("1B", $DLL) Sleep(100) $Color = _GetColor() GUISetBkColor($Color, $GUI) GUISetBkColor($Color, $cLabel) _ColorShow() WEnd If _IsPressed("11", $DLL) & _IsPressed("72") Then ClipPut($hexcolor) ConsoleWrite("Colour: " & $hexcolor & " was added to your clipboard!") EndIf DllClose($DLL) WinActivate($GUI) Func _GetColor() $mPos = MouseGetPos() Return PixelGetColor($mPos[0], $mPos[1]) EndFunc ;==>_GetColor Func _ColorShow() $R = Hex(_ColorGetRed($Color), 2) $G = Hex(_ColorGetGreen($Color), 2) $B = Hex(_ColorGetBlue($Color), 2) $hexcolor = "#" & $R & $G & $B If $Color = Hex(_ColorGetRed($Color), 2) = "#000000" Then GUICtrlSetColor($cLabel, 0xffffff) GUICtrlSetColor($iLabel, 0xffffff) GUICtrlSetColor($eLabel, 0xffffff) ElseIf $Color = Hex(_ColorGetRed($Color), 2) = "#ffffff" Then GUICtrlSetColor($cLabel, 0x000000) GUICtrlSetColor($iLabel, 0x000000) GUICtrlSetColor($eLabel, 0x000000) Else GUICtrlSetColor($cLabel, 0x000000) GUICtrlSetColor($iLabel, 0x000000) GUICtrlSetColor($eLabel, 0x000000) EndIf GUICtrlSetData($cLabel, $hexcolor) EndFunc ;==>_ColorShow Press ESC to escape and Shift+F3 to put the current colour which is under the mouse to the clipboard! - James Edit: Minor spelling mistake! Edit: I used the wrong word! Edit: Another spelling mistake. Edit: Update! Added some more text for information purposes.
    1 point
×
×
  • Create New...