Jump to content

Renderer

Active Members
  • Posts

    182
  • Joined

  • Last visited

Everything posted by Renderer

  1. @KaFu, I tried. Tried this from the Admin accout. It works. I found something interesting. Using the _ProcessGetName function i get in the Admin account the 'explorer.exe' process and in my non-Admin account I get the 'dllhost.exe'. Why is that, I don't know. So when the process behind the window is explorer.exe, then I am able to modify/manipulate the window and its controls. When the process is 'dllhost.exe' then I am not able.
  2. Hello everyone! I have a problem with the functions I mentioned in the title. I will post a script bellow: While True local $wList = WinList() for $i = 0 to UBound($wList) -1 if _ProcessGetName(WinGetProcess($wList[$i][0])) = 'dllhost.exe' Then if $wList[$i][0] = 'Internet Protocol v4 (TCP/IPv4) Properties' then local $wHandle = WinGetHandle($wList[$i][0]) ConsoleWrite(WinClose($wHandle) & @crlf) ; > Shows True on Console but window still here ConsoleWrite(WinKill($wHandle) & @crlf) ; > Shows True on Console but window still here EndIf EndIf Next WEnd The purpose of this program is to close the 'Internet Protocol v4' window, if the program detects, that it is open. But whatever function I use. It does not work. The same problem I encounter if I use functions for Control manipulation like ControlDisable/ControlHide. What should I do. It seems to me, something blocks/prevents the program from executing these function. Can someone help me?
  3. Hello everyone! Is there a function in autoit to get the mouse info inside a foreign window? Like for example WinGetMouseInfo('Utitled - Notepad'). There is only the GuiGetCursorInfo() function but it only gets the infomation of the cursor inside of a Window created inside an AutoIt Script using GUICreate and MouseGetPos to find the mouse info inside the desktop. Thanks!
  4. Hello everyone! I have a question regardig the calculation of the CPU Utilization. When I open the Taskmanager I can check the CPU Utilization. Can someone explain me how it is calculated? I am more intersted in the mathematical approach of this problem. Is there any algorithm that is used to calculate that? What are the constants/variables that must be used? I need to find a way to calculate the CPU Utilization in % for my current project. Thanks!
  5. Hi Guys! I have a small problem regarding nested dictionaries in AutoIT and recursion. Let's consider the following nested dictionary: dictionary = { "Key1": "Value1", "Key2": { "Sub-Key", "Sub-Item", "Sub-Key-2": { "Sub-Sub-Key": "Sub-Sub-Item" } } } Translated into AutoIT code it would be: $dict = ObjCreate("Scripting.Dictionary") $dict.Add("Key1", "Value1") $dict.Add("Key2", ObjCreate("Scripting.Dictionary")) $dict.Item("Key2").Add("Sub-Key", "Sub-Item") $dict.Item("Key2").Add("Sub-Key-2", ObjCreate("Scripting.Dictionary")) $dict.Item("Key2").Item("Sub-Key-2").Add("Sub-Sub-Key", "Sub-Sub-Item") I am trying to print this dictionary to console using recursion. I do not know how to apply it correctly. Here's an example: func KeyHasSubKeys($dict, $key) return (Ubound($dict.Item($key).Items) > 0) endfunc ;Check Key for Subkeys func PrintDict($dict) for $key in $dict if not KeyHasSubKeys($dict, $key) then ConsoleWrite($key & ":" $dict.Item($key) & @crlf) else for $SubKey in $dict.Item($key) ; ... this is were I get stuck next endif endfunc Can anyone help me solve this problem? The final output in console shoult be like the nested dictionary I posted above in plaintext. I think this problem can be solved using recursion, becuase it's about finding out if a key has subkeys ans so one. I am new to recursion in programming, so I cannot apply it correctly. Thanks in advance!
  6. Hi guys! I have a question regarding binary digits. How can I write an algorithm to generate all the possible binary combinations of n bits long? I konw the basics like 2 bit long binary strings can generate 2 ^ 2 = 4 possible combinations like 00, 01, 10, 00. How am I gonna put this into code? I really have no idea. Thanks in advance!
  7. Hi Guys, I have little problem i got stuck with. In the script bellow in the TreeView are listed the Files and Folders of the "Scriptdir". When a Folder/Item from the Treeview is selected, the content of it is listed in the ListView. The problem is when I select a new Item/ Foder in the Treeview the old items from the previous Treeview selection remain in the Listview. How can I fix this problem, so that when I select a new Item in the Treeview the old Items from the Listview are Removed? Thanks in advance #include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <ListViewConstants.au3> #include <ToolbarConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <array.au3> #include <file.au3> #include <GuiTreeView.au3> #include <misc.au3> #include <GuiListView.au3> global $title global $tv_Style = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) Func FileGetType($file) if StringInStr($file, ".") Then return StringSplit($file, ".", 1)[2] elseif not StringInStr($file, ".", 1) Then return "folder" EndIf EndFunc Func ListFiles_ToTreeView($hTreeView,$sSourceFolder, $hItem) Local $sFile, $newChild ; Force a trailing \ If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\" ; Start the search Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*") ; If no files found then return If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Now run through the contents of the folder While 1 ; Get next match $sFile = FileFindNextFile($hSearch) ; If no more files then close search handle and return If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Check if a folder If @extended Then ; If so then call the function recursively $newChild = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile) ListFiles_ToTreeView($hTreeView, $sSourceFolder & $sFile, $newChild) Else ; If a file than write path and name _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile) EndIf WEnd ; Close search handle FileClose($hSearch) return $newChild EndFunc ;==>ListFiles_ToTreeView Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListView_CreateArray (guinness) Func _ArraysAreDuplicate($array1, $array2) local $output[0] for $i = 0 to UBound($array1) -1 if $array1[$i] = $array2[$i] Then _ArrayAdd($output, True) Else _ArrayAdd($output, False) EndIf Next if _ArraySearch($output, False) > -1 Then return False elseif _ArraySearch($output, False) = -1 Then Return True EndIf EndFunc if $cmdline[0] Then $title = $cmdline[1] Else $title = @ScriptDir EndIf global $drives_list = DriveGetDrive("ALL") _ArrayDelete($drives_list, 0) $hWin = GUICreate($title, 802, 551, 254, 46, BitOR($ws_sizebox, $ws_minimizebox, $ws_maximizebox)) $ToolBar1 = _GUICtrlToolbar_Create($hWin, BitOR($TBSTYLE_TOOLTIPS,$TBSTYLE_WRAPABLE,$TBSTYLE_ALTDRAG,$TBSTYLE_FLAT,$WS_GROUP,$WS_VISIBLE,$WS_CHILD,$WS_CLIPSIBLINGS)) $TreeView = GUICtrlCreateTreeView(0, 32, 305, 513, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_FULLROWSELECT,$TVS_NOSCROLL,$TVS_NONEVENHEIGHT,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) $ListView = GUICtrlCreateListView("File | Date Of Creation | Type | Size | Link | ", 304, 32, 498, 490 ,BitOR($LVS_EDITLABELS,$WS_HSCROLL,$WS_VSCROLL)) GUISetState(@SW_SHOW) for $i = 0 to UBound($drives_list) -1 _GUICtrlTreeView_BeginUpdate($TreeView) local $file = ListFiles_ToTreeView($TreeView, $title , 0) _GUICtrlTreeView_EndUpdate($TreeView) Next global $list_folder global $current_view[0] global $trash[0] While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch local $current_selection = _GUICtrlTreeView_GetSelection($TreeView) local $selection_text = _GUICtrlTreeView_GetText($TreeView,$current_selection) if $current_selection > 0 Then local $select_folder_array = _FileListToArray(_GUICtrlTreeView_GetText($treeview, $current_selection)) for $i = 1 to UBound($select_folder_array) -1 if _ArraySearch($current_view, $select_folder_Array[$i]) = -1 Then if _ArraySearch($trash, $select_folder_array[$i]) = -1 Then _ArrayAdd($current_view, $select_folder_array[$i]) EndIf EndIf Next for $i = UBound($select_folder_array) -1 to 0 step -1 _ArrayDelete($select_folder_Array, $i) Next ; Refresh Folder Array EndIf for $i = UBound($current_view) -1 to 0 step -1 if _ArraySearch($current_view, $current_view[$i]) > -1 Then local $filename = $current_view[$i] local $link = $title & "\" & $selection_text & "\" & $filename local $date_array = FileGetTime($link, 1, 0) local $date_of_creation = $date_array[0] & "." & $date_array[1] & "." & $date_array[2] & "; " & $date_array[3] & ":" & $date_array[4] & ":" & $date_Array[5] local $file_type = FileGetType($link) local $file_size = FileGetSize($link) / 1024 if $file_size = 0 Then $file_size = "" EndIf if GUICtrlCreateListViewItem($filename & "|" & $date_of_creation & "|" & $file_type & "|" & $file_size & " KB" & "|" & $link, $ListView) Then _ArrayAdd($Trash, $current_view[$i]) EndIf if _ArraySearch($trash, $current_view[$i]) > -1 Then _ArrayDelete($current_view, $i) EndIf EndIf Next WEnd
  8. Hello Guys! I have a question regarding TreeView selections. How can I get the OLD and CURRENT selected Items in a TreeView? The script bellow does only get the current TreeView selected Item. global $hWin = GUICreate("TreeView --> ListView", 650,550) global $TreeView = GUICtrlCreateTreeView(0,0,250,550) ;TreeView Items global $tv_item_1 = GUICtrlCreateTreeViewItem("Item 1", $TreeView) global $tv_item_2 = GUICtrlCreateTreeViewItem("Item 2", $TreeView) global $tv_item_3 = GUICtrlCreateTreeViewItem("Item 3", $TreeView) GUISetState() global $current_selection global $old_selection While 1 Switch GUIGetMsg() case -3 ExitLoop EndSwitch local $tv_selection = _GUICtrlTreeView_GetSelection($TreeView); Gets the current TreeView Selection Consolewrite("Current Selection: " & $tv_selection & @crlf) WEnd Thanks in advance
  9. Hi guys, I want to ask you a question. It might be a stupid question. It has nothing to do with AutoIT but I think this forum is the last place where I can get an answer, since I have looked for one all over the internet. The question is about opening Folders and File Explorer. As far as I know when we open a Folder it is rendered in the File Explorer (explorer.exe). I want to know if there is a way to make a folder open with another program and all the details of that folder to be rendered in that program instead of File Explorer. What I mean is this: When I double click a folder, it should avoid opening in File Explorer, but instead another App (that I build) opens that folder and renders the content and all the other details. If you have any idea about how this could be done, please share it. It would be very helpful to me.
  10. Hi there, I have recently started learning Javascript. Now I started working with Objects. I got some problems when I want to define my own Object with it's own methods. The code looks like this: function Model(){ var model = document.createElement("div"); return model; this.append = function(parent) { document.getElementById(parent).appendChild(model); } } var farm = new Model(); farm.append("map"); The result should have looked like this: <div id="map"> <div></div> </div> But instead the "map" container is empty. The result I wanted is, that the new element I created with the object Model() is appended to the "map" container by using the .append() method. But instead it doesn't seam to happen like that. I do not get any error messages in the console even when using try - catch method. I have also tried the Object Prototypes like in the example bellow: function Model() { var model = document.createElement("div"); return model; } Model.prototype.append = function(parent) { document.getElementById(parent).appendChild(this); } var farm = new Model(); farm.append("map"); .. but the same story happen. The question is what am I doing wrong here? I am waiting for your answers. Thanks in advance!
  11. Hi there! I have got a small problem regarding arrays. I try to selectively delete some elements of an array. To do that, I create a new array, that contains the indexes of the array, from which they should be deleted. Bellow I've posted some code: global $iArray[5] = ["H","E","L","L","O"] global $index[3] = [2,3,4] ; Contains the Indexes of $iArray that should be deleted _ArrayDisplay($iArray, "Array Before Delete") ;First Attempt: _ArrayDelete($iArray, $index) _ArrayDisplay($iArray) ; Failed ;Second Attempt: for $i = 0 to UBound($index) -1 _ArrayDelete($iArray, $index[$i]) Next _ArrayDisplay($iArray); Failed The question is: How do I get to remove the indexes 2,3,4 contained by ($index array) from the main array ($iArray)? Thanks in advance!
  12. @seadoggie01, it works! Thanks a lot. Now I've got another problem. I have written a function do detect the collision between two square objects. This is the code block: Func _DetectCollision($hwnd,$controller,$collider) local $pACoord = ControlGetPos($hwnd,"",$controller) local $pBCoord = ControlGetPos($hwnd,"",$collider) ; Coordinates of point A including size local $pA_left = $pACoord[0] local $pA_top = $pACoord[1] local $pA_right = $paCoord[0]+$paCoord[2] local $pA_bottom = $paCoord[1]+$paCoord[2] ; Coordinates of point B including size local $pB_left = $pBCoord[0] local $pB_top = $pBCoord[1] local $pB_right = $pBCoord[0]+$pBCoord[2] local $pB_bottom = $pBCoord[1]+$pBCoord[2] if $pB_left > $pA_right or $pB_right < $pA_left or $pb_top > $pa_bottom or $pb_bottom < $pa_top Then return 0 else return 1 EndIf EndFunc How can I make the $controller stop moving when a collision with the $collider is detected? I have tried something like: while (true) if not _DetectCollision($body,$controller,$collider) then if _ispressed("25") then _MoveTop($body,$controller) endif ; ... endif and it does not work. What should I do in this case?
  13. Hello guys! I have created a script in which you can move a control by pressing the arrow (up, bottom, left, right) keys. I got stuck when I wanted to make the control stop when pressing the spacebar. How can I make the control stop moving while pressing the spacebar without affecting the script execution? Take a look at the script below: #include <misc.au3> #include <array.au3> func _Distance($body,$pointA,$pointB) local $getACoord = ControlGetPos($body,"",$pointA) local $getBCoord = ControlGetPos($body,"",$pointB) local $xA = $getACoord[0] local $yA = $getACoord[1] local $xB = $getBCoord[0] local $yB = $getBCoord[1] return Sqrt(($xB-$xA)^2+($yB-$yA)^2) EndFunc func _MoveTop($env,$obj) local $getObjCoord = ControlGetPos($env,"",$obj) ; return the current coordinates of the object local $objX = $getObjCoord[0] local $objY = $getObjCoord[1] if GUICtrlSetPos($obj,$objX,$objY-5) = 1 then return True Else return false EndIf endfunc func _MoveBottom($env,$obj) local $getObjCoord = ControlGetPos($env,"",$obj) ; return the current coordinates of the object local $objX = $getObjCoord[0] local $objY = $getObjCoord[1] if GUICtrlSetPos($obj,$objX,$objY+5) = 1 then return True Else return false EndIf endfunc func _MoveLeft($env,$obj) local $getObjCoord = ControlGetPos($env,"",$obj) ; return the current coordinates of the object local $objX = $getObjCoord[0] local $objY = $getObjCoord[1] if GUICtrlSetPos($obj,$objX-5,$objY) = 1 then return True Else return false EndIf endfunc func _MoveRight($env,$obj,$state) local $hReturn[0] local $getObjCoord = ControlGetPos($env,"",$obj) ; return the current coordinates of the object local $objX = $getObjCoord[0] local $objY = $getObjCoord[1] Switch $state case True GUICtrlSetPos($obj,$objX+5,$objY) case False GUICtrlSetPos($obj,$objX+5,$objY) EndSwitch return $state endfunc global $body = GUICreate("Game Basics [1] - Player Movement",650,550) global $controller = GUICtrlCreateGraphic(10,10,10,10) GUICtrlSetBkColor($controller,0) GUISetState() While True Switch GUIGetMsg() case -3 ExitLoop EndSwitch if _IsPressed("25") then local $left =_MoveLeft($body,$controller) if _IsPressed("20") Then While _IsPressed("20") $left = false WEnd EndIf ; this block will stop the execution of the script, therefore the controller will not be able to be moved anymore EndIf if _IsPressed("26") then _MoveTop($body,$controller) EndIf if _IsPressed("27") then _MoveRight($body,$controller,true) if _IsPressed("20") Then _MoveRight($body,$controller,false) EndIf EndIf if _IsPressed("28") then _MoveBottom($body,$controller) EndIf WEnd Thanks in advance!
  14. Hi guys, I want to ask you a question regarding the while loops. How can I prevent an action from repeating when it is in a while loop: Take a look at the script below: #include <misc.au3> global $body = GUICreate("Simple Window",430,340) GUISetState() while 1 switch GUIGetMsg() case -3 exitloop endswitch if _ispressed("0d") then GUICtrlCreateLabel("Some Text Here",10,10,120,20) endif ;it keeps running on and on ; ... wend How can I prevent the script from repeatedly creating the label when I press the button. Thanks in advance!
  15. Hello guys, I've got a small problem. I want to create a selection rectangle within a GUI like in paint. Here's the code I've written, but it doesn't work, unfortunately: #include <misc.au3> global $hWin = GUICreate("Selection rectangle",650,550) GUISetState() while 1 Switch GUIGetMsg() case -3 exitloop endswitch if _IsPressed("1") then $mp = GUIGetCursorInfo($hWin) $dot = GUICtrlCreateGraphic($mp[0],$mp[1],2,2) GUICtrlSetBkColor($dot,0) while _IsPressed("01") $pos = GUIGetCursorInfo($hWin) ControlMove($hWin,"",$dot,$pos[0],$pos[1],$pos[2],$pos[3]) WEnd EndIf wend Have you got any idea about how to do this correctly? Thanks in advance.
  16. Hello guys, I've got a little question: How do I check if the values or some of the values from an array ($alphabet) are also in the other array ($word)? Like: $alphabet[26] = [A,B,C,D,E,F,G, ...] $word = [H,E,L,L,O] How do I check if the values from $alphabeth (in this case H,E,L,L,O) are in the array called $word? Thanks in advance!
  17. Hi everyone! I have got stuck with a small problem. I am trying to split the following string into a 2d array: $iString = "Bob,24|Jane,25|Julian,26|" I want to have the output like: local $2D_Array[3][2] = [["Bob",24],["Jane",25],["Julian",26]] The code I've tried is: func StringSplit2D($iString,$iSep1,$iSep2) local $iSplit1 = StringSplit($iString,$iSep1) for $i = 0 to UBound($iSplit1) -1 local $2D_Array[UBound($iSplit1)][UBound($iSplit1[$i])] = [$iSplit1,$iSplit1[$i]] Next return $2d_Array EndFunc MsgBox(18,'',StringSplit2D("Bob,24|Jane,25|Julian,26|","|","1")) The "|" is the main separator, which splits the string into Rows and the "," is the secondary separator, that shall split the string into columns. I have never worked too much with 2d Arrays so maybe you could provide me some help with your answers. Thanks in advance.
  18. I just wanted to know how could I run the data from inside of a file without having it saved on the disk. Something like File Open -> Retain Data -> File Delete -> Display the Retained Data.
  19. Does this also work for any other type of file (txt, png, etc.)? If yes, then what should be different in this code?
  20. Hello everyone! I started this topic because I want to ask you if it is possible to run the data from inside of a file without needing to have that file stored on the Hard Drive. Let's assume we've got a file named "program.exe". Is there any method to run the content from inside of the file without needing to have it stored somewhere on my HDD? Normally to run the file I use the function: ShellExecute("sample.exe") I know, this question might sound strange and illogic but some answers could provide me some help. Thanks in advance!
  21. At this moment it looks like that: Registry: HKEY_CLASSES_ROOT\TextEditor.text\DefaultIcon\Standard (REG_SZ) : E:\Icon.ico HKEY_CLASSES_ROOT\TextEditor.text\Shell\ Standard (REG_SZ) : Open HKEY_CLASSES_ROOT\TextEditor.text\Shell\Open\Command\ Standard (REG_SZ) : "E:\TextEditor.exe" --started-from-file "%1" TextEditor.exe > code: global $GUI = GUICreate("Text Editor",550,450) global $GUI_Edit = GUICtrlCreateEdit("",0,0,550,450) GUISetState() while True Switch GUIGetMsg() Case -3 ExitLoop EndSwitch WEnd When I create a file (ex: Sample.text) the TextEditor.exe is opened but it displays "Text Editor" as title and no data into Edit. I guess the main problem is the TextEditor.exe . I need to code it, so that, when I open Sample.text it shows me "Sample.text" as title and the Text inside the Edit.
  22. I work on a text editor. I have created a new file extension (.text) in the Registry and associated it to my program.exe. All I want to do is to create a link between the program.exe and the extension (.text) so that the when I open a file.text, it could be fully operated through program.exe. Think about Notepad. You do not need to go to File > Open in order to open a file, you just click the file you want in order to open it and read it. The same I wanted to make for my program. I would be something like: click file.text < open through> [program.exe] -> dispaly Content of file.text . In short, the program.exe must be capable to get the content of a file associated to it.
  23. I have done it. I have managed to create a new extension and to associate it to my AutoIT program. Now I have to make the program recognize when the file is open and eventually get some data from the file and display it into a GUI. To be more specific, let's think about Notepad. It has the "txt" file associated to it. When you open a "txt" file, the data is being displayed in the Notepad app. The same I want to do with my program. At this moment I could create a file extension and associate it to the program I want, but I do not know how to make them fully work together. I hope I brought you a good understanding upon what I mean.
  24. I have created a small application in AutoIT and i want to assosciate it to a file extension. I have compiled it and put it in E:\Program.exe Then I tried manually to create a file association in the Registry Editor like bellow: HKEY_CURRENT_USER\Software\Classes\AppName.file.ext\DefautIcon DefaultIcon = E:\Icon.ico HKEY_CURRENT_USER\Software\Classes\AppName.file.ext\Shell\Open\Command Command = E:\Program.exe HKEY_CURRENT_USER\Software\Classes\.ext\(Standard) (Standard) = AppName.file.ext And It does not work.
  25. Hello everyone! I'm currently working on a small program and I got stuck on a problem. I need to know how to associate a file extension to an AutoIT Program. I've also tried this: RegWrite("HKEY_CLASSES_ROOT\",".extension","REG_SZ","E:\Program.exe") , but it does not work. I assume, I need first to register the program into the Registry, before i could associate it to a file extension. Has someone any idea about how can I do this in a right way? Thanks in advance!
×
×
  • Create New...