Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/05/2018 in all areas

  1. Hi and welcome to the forums, What program are you attempting to automate? Often there's a better way to accomplish the task besides using MouseClick with fixed coordinates. Have you tried using the Au3Info tool to look for the button control's properties? Dan
    1 point
  2. Even with my best glasses I can't see the place in this code where the new text is written in the file ...
    1 point
  3. I got the same problem as you @coffeeturtle. So what you need to do, is go into msse and flag the directory aut2exe as excluded from checks.
    1 point
  4. Thanks works fine. Using your example I just create this Modified/Simpler example: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> Example() Func Example() GUICreate("My GUI menu", 300, 200) Local $idViewMenu = GUICtrlCreateMenu("View", -1, 1) ; Is created before "?" menu Local $idViewStatusItem = GUICtrlCreateMenuItem("Radio Item", $idViewMenu, -1, 1) Local $idbtnGetState = GUICtrlCreateButton("Get [View->Radio Item] State", 50, 130, 200, 20) GUICtrlSetState(-1, $GUI_FOCUS) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idbtnGetState MsgBox(0, "", BitAND(GUICtrlRead($idViewStatusItem), $GUI_CHECKED) ? "Checked" : "Not Checked") EndSwitch WEnd EndFunc ;==>Example Hm.... so this is something bad on my side, in one of my project. I must review them ....
    1 point
  5. Hello. Check. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> Example() Func Example() GUICreate("My GUI menu", 300, 200) Local $sStatus = "Ready" Local $idFileMenu = GUICtrlCreateMenu("&File") Local $idFileItem = GUICtrlCreateMenuItem("Open", $idFileMenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) Local $idHelpMenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $idFileMenu) GUICtrlSetState(-1, $GUI_DISABLE) Local $idInfoItem = GUICtrlCreateMenuItem("Info", $idHelpMenu) Local $idExit = GUICtrlCreateMenuItem("Exit", $idFileMenu) Local $idRecentFilesMenu = GUICtrlCreateMenu("Recent Files", $idFileMenu, 1) GUICtrlCreateMenuItem("", $idFileMenu, 2) ; Create a separator line Local $idViewMenu = GUICtrlCreateMenu("View", -1, 1) ; Is created before "?" menu Local $idViewStatusItem = GUICtrlCreateMenuItem("Radio Item", $idViewMenu, -1, 1) ;~ GUICtrlSetState(-1, $GUI_CHECKED) Local $idbtnGetState=GUICtrlCreateButton("Get [View->Radio Item] State", 50, 130, 200, 20) GUICtrlSetState(-1, $GUI_FOCUS) Local $idStatusLabel = GUICtrlCreateLabel($sStatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState(@SW_SHOW) Local $sFilePath ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idExit Exit Case $idbtnGetState MsgBox(0, "", BitAND(GUICtrlRead($idViewStatusItem), $GUI_CHECKED) ? "Checked" : "Not Checked") Case $idInfoItem MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...") Case $idFileItem $sFilePath = FileOpenDialog("Choose a file...", @TempDir, "All (*.*)") If @error Then ContinueLoop EndIf GUICtrlCreateMenuItem($sFilePath, $idRecentFilesMenu) Case $idViewStatusItem ;Do Nothing. It Check/Uncheck itself. EndSwitch WEnd EndFunc ;==>Example Saludos
    1 point
  6. @sadakathullah, welcome to AutoIt and to the forum. when it comes to testing user restrictions, i find it is best to simulate the user actions and check the system response. for PrintScreen, i would simulate the key being pressed, then check the clipboard for the presence of an image. something like this: #include <Clipboard.au3> ConsoleWrite(_IsPrintScreenAllowed() & @CRLF) Func _IsPrintScreenAllowed() ; clear the clipboard _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_Close() ; if clipboard is not clear, stop with an error If _ClipBoard_CountFormats() <> 0 Then Return SetError(1, 0, True) ; send PrintScreen Send('{PRINTSCREEN}') ; give enough time for the clipboard to finish processing Sleep(1000) ; check if something exists in the clipboard If _ClipBoard_CountFormats() <> 0 Then Return True Else Return False EndIf EndFunc ;==>_IsPrintScreenAllowed this function may look long and intimidating, but it is quite simple. a more advanced coder can code it in half the line count, but loose much of its readability. P.S. i'm curious though, if the GPO you use to restrict PrintScreen also restricts the simulated key press; if you can test the code on a target which you already tested manually, do let me know. P.S.#2 naturally i agree with the post above, but i found it moot to argue with corporate policies.
    1 point
  7. I agree with what i read in forums and such https://social.technet.microsoft.com/Forums/office/en-US/78840a9c-0666-490a-8cda-939f292cec9f/to-disable-print-screen-through-group-policy It's kinda stupid to disable print screen, there are lots of ways to get the image anyway, like a smartphone. Anyway, you could go with the scancode option and disable the key entirely.
    1 point
  8. @jasty Yes, the retrieved elements of the array are copied into $array Here is a script that could match partially your function (at least, this is how I understood it) #include <Array.au3> #include <MsgBoxConstants.au3> Global $aBig_array[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] _ArrayDisplay($aBig_array, "$aBig_array - in main") Test() Func Test() $array = RetrieveDataOfSomeKind() ; an Array should be returned to populate $array _ArrayDisplay($array, "$array - in test()") If @error = 1 Then MsgBox($MB_TOPMOST, "Error", "$array is not an array") EndIf EndFunc Func RetrieveDataOfSomeKind() Local $aSmall_array[2] $aSmall_array[0] = $aBig_array[2] $aSmall_array[1] = $aBig_array[4] Return $aSmall_array EndFunc What Melba23 did explain concerned the ByRef keyword, for instance : #include <Array.au3> Global $aBig_array[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] _ArrayDisplay($aBig_array, "In main - before test()") Test($aBig_array) _ArrayDisplay($aBig_array, "In main - after test()") Func Test(ByRef $array) ; $aBig_array[] hasn't been copied in the function, because of ByRef keyword ; and it will never be copied, even if you alter an element of $array. ; ; Now, notice how altering an element of $array will modify the original $aBig_array $array[9] = 999999999 _ArrayDisplay($array, "$array - In test") EndFunc Same without ByRef (use it only if you really need a copy of the whole array in the function) #include <Array.au3> Global $aBig_array[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] _ArrayDisplay($aBig_array, "In main - before test()") Test($aBig_array) _ArrayDisplay($aBig_array, "In main - after test()") Func Test($array) ; $aBig_array[] hasn't been copied in the function, BUT : ; it will be copied, as soon as you alter any element of $array ! ; This functionality may eventually be removed in next AutoIt releases, ; so scripters will have to be extra careful concerning the ByRef keyword. ; The only case ByRef shouldn't be used is if you *really* need a copy of the array, here. ; ; Now, notice how altering an element of $array will NOT modify the original ($aBig_array) $array[9] = 999999999 _ArrayDisplay($array, "$array - In test") EndFunc One more thing : Const ByRef (or ByRef Const) is even better, in case you don't want at all to modify the original array. It's an extra protection for scripters : an error will be generated if you modify any element inadvertly during the function : Global $aBig_array[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Test($aBig_array) Func Test(ByRef Const $array) ; Notice how altering inadvertly an element of $array will generate an error : thanks Const ! $array[9] = 999999999 EndFunc ; Console shows the error : ; " Cannot assign values to constants " ; $array[9] = 999999999 ; ^ ERROR Good luck
    1 point
  9. Have a look at the RichTextFormat functions. It's not exactly Word, but very versatile. eg https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlRichEdit_Create.htm Skysnake
    1 point
  10. Hi, get a list of what you want to test, then we go over each one. To start with the print screen, do you want to test a registry key, or the key itself? For the mstsc you can run it, and check for it's window with windowexists.
    1 point
  11. MyEarth

    WinHTTP functions

    Hello @trancexx How i can save an image using WinHttp? In async mode, without wait to download. An example link: Many thanks for the help. In theory i don't need to save on the disk but loading directly on the GUI using GDI but i'll open another thread for this if i need help EDIT SOLVED with: https://github.com/dragana-r/autoit-winhttp/blob/master/WinHttp_Examples/_WinHttpSimpleBinaryConcat.au3
    1 point
  12. Found! GUICtrlSendMsg($iEdit, $EM_LIMITTEXT, -1, 0) ; Removes the limit on the number of characters of the 30000 Regards!
    1 point
  13. Melba23

    Get listview selected item

    lucamad, Welcome to the AutoIt forum. If you add the items to the ListView with the UDF, you need to carry on using the UDF on the items created: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> GUICreate("Lokyweb Uploader", -1, -1, -1, -1, BitOr($WS_SIZEBOX, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX), $WS_EX_ACCEPTFILES);x il drag & drop $listview = GUICtrlCreateListView("List", 2, 40, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SINGLESEL)) _GUICtrlListView_AddItem($listview, "test1", 1) _GUICtrlListView_AddItem($listview, "test2", 2) $button = GUICtrlCreateButton("Selected item", 10, 325) GUISetState() While (1) $msg = GUIGetMsg() if $msg = $button Then $iIndex = _GUICtrlListView_GetSelectedIndices($listview) msgbox (0, "Selected item", $iIndex) EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd This will return the 0-based index of the selected item. Be very careful mixing the buit-in commands and those from the UDF (regardless of which control type) as it can often end in tears. M23
    1 point
  14. NeuroToxic

    File Delete Line

    Func _Delete_Line_In_File($fileName, $lineNum) Local $len = FileGetSize($fileName) Local $txt = FileRead($fileName, $len) If @error = 1 Then Return 0 Local $pos1 = StringInStr($txt, @lf, 0, $lineNum - 1) Local $pos2 = StringInStr($txt, @lf, 0, $lineNum) If $pos1 > 0 Or $pos2 > 0 Then If $pos2 = 0 Then $pos2 = $len FileDelete($fileName) FileWrite($fileName, StringMid($txt, 1, $pos1) & StringMid($txt, $pos2 + 1)) Return 1 EndIf Return 0 EndFunc ;==> _Delete_Line_In_File()
    1 point
×
×
  • Create New...