Leaderboard
Popular Content
Showing content with the highest reputation on 01/05/2019 in all areas
-
Team positions: Advisor. "Sometimes I waist days adding a hamburger sprite sheet generator." Advisor can guide the direction of story and scripts to help maximize the use of development time. Sometimes I just need someone who is interested in this sort of thing to provide me with feedback. General programmer. Save / Load data file management. Getting this organized. To actually have a plan to follow instead of my haphazard .txt files, hardcoded data, and sometimes .ini files. Tell me the file management you decide and I'll code to the assigned rules. Now both our jobs are easier. Win win. We'll have to get you on salary. I also save to multiple locations, the job isn't complete cake. I might want you to convert old systems and write new, so that I don't have to. Math guy or gal. Always liked math? Like flexible shitty jobs? Then this is you. Critical analyzer. Tell me why it should be better. Unity. (Unity skills are transferable to this project by rendering in a 3D environment to 2D.) Sound effects (Can't be paid for until further development) If you have an interest in this sort of thing, want to learn, or just want to get in real close before the kill. I'll find a job for you.2 points
-
Features: World Menu: -> New: Set World Size and Tiles Load and Scan Image to World (Image of dialog in Overview above) -> File: Save (World) Load (World) Save World to Image (Draws the entire World as tiles to image) Clear (World layer range and area section.) Tile Frame (X and Y subsection of tile.) Currently whole World can be specifically set to a range of frame. Single tile and area specification coming soon. Properties (of World measured in tiles.) Tile Menu: -> Edit Edit Image (Tile) 1. Selected Tile is loaded into the editor 2. Press SPACEBAR to drop colored pixels under mouse Replace from Disk (Discards selected tile and loads _FileOpenDialog($FILTER_IMAGE) ) Resize (Scales selected Tile images) Replace Color (In selected Tiles. See link for Blood Shores) Save (Tiles) Load (Tiles) Clear (Tiles) Tile Groups (Assign Tile group properties and Tiles of groups. Such as what tiles, are what strength walls.) Properties (of all Tiles) Background Menu: Change scrolling image. Scrolls on X and Y axis. Used for animated water effect. Any image can be used. 2. Show. (Toggles display of scrolling background image.) Area Menu: Define Areas. Save Areas. NPC Menu: Create NPC Save NPCs Sprite Menu: Setup Spritesheet Window Menu: -> Size Screen Size (Set the size of the main window) Tile Palette Size (Set the width and height of Tile Palette, measured in Tiles.) Ruler -> Show Cursor (Toggles display of the cursor position sub-window.) Tile Palette (Toggles display of Tile Palette sub-window.) Info (Toggle the Info sub-window display at bottom of screen.) Board (Toggles Board Info sub-window, this window starts hidden) Help Menu: Settings (Relic it probably still works.) Hotkeys (Dialog() takes a list of keys that can be applied to actions.) Create Player (Temporary dialog to set data for player characters.) About (Put your mouse over the avatar, but don't click it. That's what gets him off.) - Move tiles to different world layer: IE: There are tools in MapIt to add layers after a image is scanned (scanned image always starts single layer). Tools to automate search for tile in layer: replace, move, etc. Auto search all trees, move from layer: 0 to layer: 1, next replace all trees on layer: 0 change to grass. Now trees are in the foreground of grass. We have just added a tile layer to a single layer world.2 points
-
MapIt Overview: Avoid posts that aren't about MapIt development. If you want to tell me good job or something try to use the Like buttons. If you have a question about MapIt I'd love to hear it. Criticism is okay with me too. Feel free to PM me about MapIt. Merging all these topics to this topic: Overview. End goal is to have a tile engine with sprites that is both a game and a world editor. Automate replacing tiles in world, or colors in tiles. Save / load worlds and tile images. Use lists of tiles for automations. Choose transparent color. MapIt is a tool to reverse map images into world file and tile images. Supported image files: bmp, jpeg, gif, your mum, png, tiff, tga When the Start and End areas are all zero; the entire image is parsed into tiles. Here is an image of the resulting world file 000.txt: Tile images are saved too: Tiles.zip. This is posted in collaborations b/c I want help. I want help bad enough that I could be willing to pay people for their time. There are plenty of jobs available, the best way to start is to get to know the project. There are at least 2 ways to do that, as a user and as a developer. I wouldn't be paying much and I'd have to see your work as valuable. I suppose a sliding scale. I'm not unreasonable and I like lots of silly things.2 points
-
Not really sure, but you could use something like: #include <Array.au3> #include <EditConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Global $g_idSearch, $g_idRadio[5][2] = [["", "Radio1"], ["", "Radio2"], ["", "Radio3"], ["", "Radio4"], ["", "Radio5"]] _Example() Func _Example() Local $hControlFocus, $y = 30 GUICreate("Example", 260, (UBound($g_idRadio) * 30 ) + 5) GUICtrlCreateLabel("Search1:", 5, 5, 60, 20, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 11, 800) $g_idSearch = GUICtrlCreateCombo("", 75, 5, 120, 20) _GUICtrlComboBox_BeginUpdate($g_idSearch) For $i = 0 To UBound($g_idRadio) - 1 _GUICtrlComboBox_AddString($g_idSearch, $g_idRadio[$i][1]) $g_idRadio[$i][0] = GUICtrlCreateRadio($g_idRadio[$i][1], 5, $y, 120, 20) $y += 25 Next _GUICtrlComboBox_EndUpdate($g_idSearch) Local $idEnter = GUICtrlCreateDummy() GUISetState() Local $aAccelKeys[1][2] = [["{ENTER}", $idEnter]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idEnter ;~ Check if Enter is pressed $hControlFocus = _WinAPI_GetFocus() Switch $hControlFocus Case GUICtrlGetHandle($g_idSearch) MsgBox(4096, "Search 1", "Search 1 : " & GUICtrlRead($g_idSearch)) EndSwitch EndSwitch WEnd EndFunc Func _Edit_Changed() _GUICtrlComboBox_AutoComplete($g_idSearch) EndFunc ;==>_Edit_Changed Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo If Not IsHWnd($g_idSearch) Then $hWndCombo = GUICtrlGetHandle($g_idSearch) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $g_idSearch, $hWndCombo Switch $iCode Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed _DebugPrint("$CBN_CLOSEUP" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box _DebugPrint("$CBN_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible _DebugPrint("$CBN_DROPDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box _DebugPrint("$CBN_EDITCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) _Edit_Changed() ; no return value Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text _DebugPrint("$CBN_EDITUPDATE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request _DebugPrint("$CBN_ERRSPACE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus Local $iSearch = _ArraySearch($g_idRadio, GUICtrlRead($g_idSearch), 0, 0, 0, 0, 1, 1) If $iSearch > -1 Then GUICtrlSetState($g_idRadio[$iSearch][0], $GUI_CHECKED) _DebugPrint("$CBN_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box Local $iSearch = _ArraySearch($g_idRadio, GUICtrlRead($g_idSearch), 0, 0, 0, 0, 1, 1) If $iSearch > -1 Then GUICtrlSetState($g_idRadio[$iSearch][0], $GUI_CHECKED) _DebugPrint("$CBN_SELCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_SELENDCANCEL ; Sent when the user selects an item, but then selects another control or closes the dialog box _DebugPrint("$CBN_SELENDCANCEL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list _DebugPrint("$CBN_SELENDOK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_SETFOCUS ; Sent when a combo box receives the keyboard focus For $i = 0 To UBound($g_idRadio) - 1 GUICtrlSetState($g_idRadio[$i][0], $GUI_UNCHECKED) Next _DebugPrint("$CBN_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint2 points
-
remove the global inside of loop1 point
-
Embed text in a file other than ".txt"
FrancescoDiMuro reacted to Melba23 for a topic
wattexi, Yes, please do explain just why you want to "hide" something inside another file, thus corrupting it, and then extract it later while restoring the original file. A number of possible explanations come to mind - some of which I really do not like very much. M23 P.S. And just to be absolutely clear - this is the Mod team determining the legality of the thread, so everyone else please keep out.1 point -
ControlGetFocus() help
baconaise reacted to FrancescoDiMuro for a topic
WM_COMMAND, as @Subz suggested1 point -
Memory leak script stopper ( or not )
ioa747 reacted to argumentum for a topic
I was asking around on how to detect memory leaks and came up with a logger ( or just stop execution, or restart ). Here is the code. ( should have done a UDF but maybe there is no need for such ) #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 #include <SQLite.au3> #include <WinAPISys.au3> #include <WinAPIProc.au3> #include <Date.au3> #include <Array.au3>; For _ArrayDisplay() Example() Func Example() ConsoleWrite(MemLeakTooMuch() & @CRLF) ; call once at first to initialize the baseline. Local $a = MemLeakLog(1) ; ..you could call this on the fly and get an array _ArrayDisplay($a) ; call on AdlibRegister() or other means ; Ex: AdlibRegister("OnMemLeakRestart", 3600000) ; once an hour ; While Sleep(50) ; ... ... ; WEnd EndFunc ;==>Example #Region MemLeak Func OnMemLeakRestart() ; Local Static $iTriggered = 0 If MemLeakTooMuch() Then If Not $iTriggered Then $iTriggered = 1 AdlibRegister("OnMemLeakRestart", 60000) ; since it triggered, check more often EndIf If _WinAPI_GetIdleTime() > 600000 Then ; over 10 min. maybe ?, to not bother the user ? ShellExecute(@ScriptFullPath) ; restart itself if it must, but if you do, ; keep that in mind while coding. Exit 3 ; use the exit code you please other than 1 or 2, EndIf ; as AutoIt may use it for itself. EndIf EndFunc ;==>OnMemLeakRestart Func MemLeakLog($ReturnAnArray = 0) Local $aMethod[5] = ["EXITCLOSE_NORMAL", "EXITCLOSE_BYEXIT", "EXITCLOSE_BYCLICK", "EXITCLOSE_BYLOGOFF", "EXITCLOSE_BYSHUTDOWN"] Local $iMethod = Execute("@exitMethod") Local $aDesc[14] = ["number of page faults", "peak working set size, in bytes", "current working set size, in bytes", _ "peak paged pool usage, in bytes", "current paged pool usage, in bytes", "peak nonpaged pool usage, in bytes", _ "current nonpaged pool usage, in bytes", "current space allocated for the pagefile, in bytes", _ "peak space allocated for the pagefile, in bytes", "current amount of memory that cannot be shared with other processes, in bytes", _ "ProcessHandleCount", "ProcessThreadsCount", "GDI objects", "USER objects"] Local $s = @YEAR & "." & @MON & "." & @MDAY & "_" & @HOUR & ":" & @MIN & ":" & @SEC $s &= " - RunTime: " & _Convert(gTimer()) & " - PID: " & @AutoItPID If IsInt($iMethod) Then $s &= " - ExitCode: " & @exitCode $s &= " - ExitMethod: " & $iMethod & " (" & $aMethod[$iMethod] & ")" EndIf Local $a[4][15] $a[1][0] = "Starting:" $a[2][0] = " Exiting:" $a[3][0] = " Diff.:" MemLeakTooMuch() Local $b = MemLeakTooMuch(-2), $c = MemLeakTooMuch(-3) For $n = 0 To UBound($c) - 1 $a[0][$n + 1] = $aDesc[$n] $a[1][$n + 1] = $b[$n] $a[2][$n + 1] = $c[$n] $a[3][$n + 1] = $c[$n] - $b[$n] Switch $n Case 0, 10, 11, 12, 13, 14 ; nothing, is a count number Case Else $a[3][$n + 1] = ByteSuffix($a[3][$n + 1]) EndSwitch $a[3][$n + 1] &= " ( x" & (($b[$n] > 0 And $b[$n] > 0) ? Round($c[$n] / $b[$n], 1) : "1") & " )" Next If Int(Eval("ReturnAnArray")) Then $a[0][0] = _Convert(gTimer()) Return $a Else FileWriteLine(StringTrimRight(@ScriptFullPath, 4) & ".ProcessInfo.log", $s & @CRLF & _ _SQLite_Display2DResult($a, 0, True) & Eval("sErrorHandler") & @CRLF) ; I save the data from ObjEvent("AutoIt.Error", "_ErrFunc") to $sErrorHandler EndIf EndFunc ;==>MemLeakLog Func MemLeakTooMuch($iPid = 0, $iMutliplier = 4) ; in case this is for some other PID, but only one =/ Local Static $aInitProcessMemoryInfo = 99, $aLastProcessMemoryInfo Local $ret = False, $a, $n, $aTemp If $iPid = -2 Then Return $aInitProcessMemoryInfo ; returns the initial readings If $iPid = -3 Then Return $aLastProcessMemoryInfo ; returns the last readings If $aInitProcessMemoryInfo = 99 Then $aTemp = _WinAPI_GetProcessMemoryInfo($iPid) If Not (UBound($aTemp) = 10) Then Return SetError(1, 0, $ret) $aLastProcessMemoryInfo = $aTemp Else $aTemp = _WinAPI_GetProcessMemoryInfo($iPid) If Not (UBound($aTemp) = 10) Then Return SetError(1, 0, $ret) $aLastProcessMemoryInfo = $aTemp For $n = 1 To UBound($aTemp) - 1 ; I don't think "page faults" is leakage, so it's omited. If $aTemp[$n] > $aInitProcessMemoryInfo[$n] * $iMutliplier Then $ret = True Next EndIf ReDim $aLastProcessMemoryInfo[14] ; to hold the next values $aLastProcessMemoryInfo[10] = _WinAPI_GetProcessHandleCount($iPid) If $aLastProcessMemoryInfo[10] > 2000 Then $ret = True ; dropping handles ? $a = _WinAPI_EnumProcessThreads($iPid) $aLastProcessMemoryInfo[11] = UBound($a) - 1 If $aLastProcessMemoryInfo[11] > 200 Then $ret = True ; dropping threads ? If Not $iPid Then $iPid = -1 $aLastProcessMemoryInfo[12] = _WinAPI_GetGuiResources(0, $iPid) ; count of GDI objects. $aLastProcessMemoryInfo[13] = _WinAPI_GetGuiResources(1, $iPid) ; count of USER objects If $aLastProcessMemoryInfo[12] > 1000 Then $ret = True ; dropping GDI objects ? If $aLastProcessMemoryInfo[13] > 2000 Then $ret = True ; dropping USER objects ? If $aInitProcessMemoryInfo = 99 Then gTimer() ; init. the timer now, if was not at the top of the script $aInitProcessMemoryInfo = $aLastProcessMemoryInfo OnAutoItExitRegister("MemLeakLog") ; ..if you wanna keep a log EndIf Return $ret EndFunc ;==>MemLeakTooMuch Func _Convert($ms) ; https://www.autoitscript.com/forum/topic/163621-convert-ms-to-dayhourminsec/?do=findComment&comment=1192334 Local $day, $hour, $min, $sec _TicksToTime($ms, $hour, $min, $sec) If $hour > 24 Then $day = $hour / 24 $hour = Mod($hour, 24) EndIf Return StringReplace(StringFormat("%03i %02i:%02i:%02i", $day, $hour, $min, $sec), "000 ", "") EndFunc ;==>_Convert Func gTimer() Local Static $Timer = TimerInit() Return TimerDiff($Timer) EndFunc ;==>gTimer Func ByteSuffix($iBytes) ; https://www.autoitscript.com/autoit3/docs/functions/FileGetSize.htm Local $iIndex = 0, $aArray = [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB'] While $iBytes > 1023 $iIndex += 1 $iBytes /= 1024 WEnd Return Round($iBytes) & $aArray[$iIndex] EndFunc ;==>ByteSuffix #EndRegion MemLeak I'm gonna use it for a pain in the neck script. If you find ways to improve it, or something I missed, let me know. 2019.01.05 update: Added GDI objects and USER objects. Added return array. Fixed boo-boo. Added Diff. multiplier.1 point -
here a simple way to implement it : msgbox (0,"",ControlGetHandle ($GUI_FUNDAMENTAL_WINDOW, "", $Search_Field) & "/" & _ ControlGetHandle ($GUI_FUNDAMENTAL_WINDOW, "", ControlGetFocus ($GUI_FUNDAMENTAL_WINDOW, "")))1 point
-
Basic example, using two inputs: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Global $g_idSearch1, $g_idSearch2 _Example() Func _Example() Local $hControlFocus GUICreate("Example", 260, 55) GUICtrlCreateLabel("Search1:", 5, 5, 60, 20, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 11, 800) $g_idSearch1 = GUICtrlCreateInput("", 75, 5, 120, 20) Local $idSearch1 = GUICtrlCreateButton("Go", 195, 5, 60, 20) GUICtrlSetFont(-1, 11, 800) GUICtrlCreateLabel("Search2:", 5, 30, 60, 20, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 11, 800) $g_idSearch2 = GUICtrlCreateInput("", 75, 30, 120, 20) Local $idSearch2 = GUICtrlCreateButton("Go", 195, 30, 60, 20) GUICtrlSetFont(-1, 11, 800) Local $idEnter = GUICtrlCreateDummy() GUISetState() Local $aAccelKeys[1][2] = [["{ENTER}", $idEnter]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idSearch1 MsgBox(4096, "Search 1", "Search 1 : " & GUICtrlRead($g_idSearch1)) Case $idSearch2 MsgBox(4096, "Search 2", "Search 2 : " & GUICtrlRead($g_idSearch2)) Case $idEnter ;~ Check if Enter is pressed $hControlFocus = _WinAPI_GetFocus() Switch $hControlFocus Case GUICtrlGetHandle($g_idSearch1) MsgBox(4096, "Search 1", "Search 1 : " & GUICtrlRead($g_idSearch1)) Case GUICtrlGetHandle($g_idSearch2) MsgBox(4096, "Search 2", "Search 2 : " & GUICtrlRead($g_idSearch2)) EndSwitch EndSwitch WEnd EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $g_idSearch1 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control ConsoleWrite("Search Item 1: " & GUICtrlRead($g_idSearch1) & @CRLF) EndSwitch Case $g_idSearch2 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control ConsoleWrite("Search Item 2: " & GUICtrlRead($g_idSearch2) & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc1 point
-
The DOM allows to do anything with elements and their contents, but first we need to reach the corresponding DOM object, get it into a variable, and then we are able to modify it. * Well, this little tool (although it is not very nice aesthetically) allows you to get visually a "selector" usable to reference DOM objects. Once you have the "selector" of an element you can pass it to the javascript querySelector() function that will return a reference to that element. To use this tool you have to: 1) open the web page you want to inspect into IE browser 2) run this script (if it find more instances of IE running, it allows you to chose one) 3) move the mouse over the browser. The "selector" of the element below the pointer is catched automatically while hovering. To copy the selector in the clipboard just right click on the element. As you can see, while hovering, the element pointed by the mouse is highlighted with a thin red dotted frame to allow you to better "take aim" when the selector is copied to the clipboard a little acoustic signal is emitted as a confirm, then you can paste it in your listing where you need it. I hope it can come in handy and save you time when you need to automate a site .... have fun (debugged on Sept. 30 2018) #include <IE.au3> #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <Misc.au3> ; for _IsPressed (23 END key) Global $hDLL = DllOpen("user32.dll") ; following global variables are automatically updated by events from the browser ; ------------------------------------------------------------------------------------- Global $g_iMouseX, $g_iMouseY ; coordinates of the mouse while mooving over the browser Global $bCopySelector = False ; becomes True when you right click on wanted element ; ------------------------------------------------------------------------------------- Global $oIE = _Get_IE() ; get IE instance to inspect If IsObj($oIE) Then $hIE = _IEPropertyGet($oIE, "hwnd") WinActivate($hIE) _InspectElements() EndIf DllClose($hDLL) Exit Func _InspectElements() ; it uses the global variable $oIE as source ; --- set IE to interact with AutoIt --- Local $oDocument Do ; wait for document Sleep(250) $oDocument = $oIE.document Until IsObj($oDocument) Local $oWindow = $oDocument.ParentWindow ; create a reference to the javascript eval method ; in the body section of the dovument $oWindow.setTimeout("document.body.JSeval = eval; ", 0) ; attach the $JSeval variable to the javascript eval method Local $JSeval Do $JSeval = Execute('$oIE.Document.body.JSeval') Until IsObj($JSeval) ; --------------------------------------------- ; Inject Javascript functions/elements to $oIE ; --------------------------------------------- ; Get the DOM path of an element (a CSS selector) ; ----------------------------------------------- ; This javascript function returns the CSS selector of the passed element. ; You can then use the returned path to get a reference to the pointed ; element by the QuerySelector() javascript function ; function copied from the following link: ; https://stackoverflow.com/questions/5728558/get-the-dom-path-of-the-clicked-a ; see answer by "Aleksandar Totic" (thanks to him) Local $sJScript = "" & _ " function getDomPath(el) {" & _ " if (!el) {" & _ " return;" & _ " }" & _ " var stack = [];" & _ " var isShadow = false;" & _ " while (el.parentNode != null) {" & _ " var sibCount = 0;" & _ " var sibIndex = 0;" & _ " for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {" & _ " var sib = el.parentNode.childNodes[i];" & _ " if ( sib.nodeName == el.nodeName ) {" & _ " if ( sib === el ) {" & _ " sibIndex = sibCount;" & _ " }" & _ " sibCount++;" & _ " }" & _ " }" & _ " var nodeName = el.nodeName.toLowerCase();" & _ " if (isShadow) {" & _ " nodeName += ""::shadow"";" & _ " isShadow = false;" & _ " }" & _ " if ( sibCount > 1 ) {" & _ " stack.unshift(nodeName + ':nth-of-type(' + (sibIndex + 1) + ')');" & _ " } else {" & _ " stack.unshift(nodeName);" & _ " }" & _ " el = el.parentNode;" & _ " if (el.nodeType === 11) {" & _ " isShadow = true;" & _ " el = el.host;" & _ " }" & _ " }" & _ " stack.splice(0,1);" & _ " return stack.join(' > ');" & _ " }" ; more infos here: https://www.kirupa.com/html5/finding_elements_dom_using_querySelector.htm ; Inject the above javascript function contained in the $sJScript variable into the document _JS_Inject($oIE, $sJScript) Local $_getDomPath ; a reference to call above function from AutoIt Do Sleep(250) $_getDomPath = $jsEval("getDomPath") Until IsObj($_getDomPath) ; ; ------------------- ; hook some IE events ; ------------------- Local $oEventObjects[2], $oEventsSource $oEventsSource = $oIE.document.documentElement ; element we want catch events from ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa769636(v=vs.85) $oEventObjects[0] = ObjEvent($oEventsSource, "_HTMLElementEvents2_", "HTMLElementEvents2") ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768283(v%3dvs.85) $oEventObjects[1] = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2") ; open a GUI where to show some element's properties ; -------------------------------------------------- Local $hGUIMain = GUICreate("Info", 500, 140, -1, -1, -1, $WS_EX_TOPMOST) Local $hProperties = GUICtrlCreateEdit("", 0, 0, 500, 140) GUICtrlSetFont(-1, 9, -1, -1, "Courier New") GUISetState() ;Show GUI ; -------------------------------------------------- ; --------- ; Main loop ; --------- Local $iMouseX, $iMouseY, $oElement, $oNewElement, $sSelector Local $oGotElement, $sElementInfos Local $sSaved_StyleOutline, $sSaved_StyleOutline2 ; Loop until the user exits. While IsObj($oIE) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop ; ---> end EndSwitch If ($g_iMouseX <> $iMouseX) Or ($g_iMouseY <> $iMouseY) Then $iMouseX = $g_iMouseX $iMouseY = $g_iMouseY ; $oElement = $oIE.document.elementFromPoint($iMouseX, $iMouseY) ; <-- this way is slower $oNewElement = $JSeval('document.elementFromPoint(' & $iMouseX & ',' & $iMouseY & ');') If $oNewElement <> $oElement Then If IsObj($oElement) Then $oElement.style.outline = $sSaved_StyleOutline $oElement = $oNewElement ; $bSelfie = False ; $iSelf_Timer = TimerInit() $sSaved_StyleOutline = $oElement.style.outline ; save new element's original outline style $sSelector = $_getDomPath($oElement) ; get CSS path If $sSelector <> "" Then ; We could use the $oNewElement, but just to proof that $sSelector is OK ; we get again a reference to the new pointed element using it's $sSelector $oGotElement = $JSeval('document.querySelector("' & $sSelector & '");') ; <-- how to use a selector $oGotElement.style.outline = "1px dashed red" ; mark new pointed element ; https://css-tricks.com/ $sElementInfos = "" & _ "nodeName: " & $oGotElement.nodeName & @CRLF & _ "id: " & $oGotElement.getAttribute('id') & @CRLF & _ "class: " & $oGotElement.getAttribute('class') & @CRLF & _ "type: " & $oGotElement.getAttribute('type') & @CRLF & _ "---------" & @CRLF & _ $sSelector ControlSetText($hGUIMain, "", $hProperties, $sElementInfos) EndIf EndIf EndIf ; $bCopySelector is setted to True by the right-click event on an element, ; see Volatile Func _HTMLElementEvents2_onContextmenu($oEvent) near script bottom If $bCopySelector And ($sSelector <> "") Then ; And (TimerDiff($iSelf_Timer) > $bSelfie_Delay) Then ; $sSaved_StyleOutline2 = $oGotElement.style.outline $oGotElement.style.outline = "5px dotted #ff0066" ; mark copied element ClipPut($sSelector) $sElementInfos &= @CRLF & "selector copied to ClipBoard" ControlSetText($hGUIMain, "", $hProperties, $sElementInfos) Beep(2000, 50) $bCopySelector = False Sleep(250) $oGotElement.style.outline = $sSaved_StyleOutline2 ; ToolTip('') EndIf If _IsPressed("23", $hDLL) Then ; END key pressed If IsObj($oElement) Then $oElement.style.outline = $sSaved_StyleOutline WinActivate($hGUIMain) ; WinSetState($hGUIMain, "", @SW_SHOW) $aWin = WinGetPos($hGUIMain) MouseMove($aWin[0] + $aWin[2] / 2, $aWin[1] + $aWin[3] / 2, 0) EndIf WEnd ; the end ; ------------------------------------------ For $i = 0 To UBound($oEventObjects) - 1 ; Tell IE we don't want to receive events. $oEventObjects[$i] .Stop $oEventObjects[$i] = 0 Next $oIE = 0 ; Remove IE from memory GUIDelete($hGUIMain) ; Remove GUI ; ------------------------------------------ EndFunc ;==>_InspectElements Func _Get_IE() ; Example 5 from the _IEAttach help ; Create an array of object references to all current browser instances ; The first array element will contain the number of instances found Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIEx While 1 $oIEx = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = $oIEx $aIE[0] = $i $i += 1 WEnd If $aIE[0] > 0 Then If $aIE[0] = 1 Then Return $aIE[1] ; only one IE is running, return this then ; ; Create a little list box to choose the IE instance from Local $hChoose_IE = GUICreate("IE Instances", 600, 350) Local $Label1 = GUICtrlCreateLabel($aIE[0] & " running Instances of IE browser found, click the one you want to attach to then click on 'ok'", 5, 5, 590, 20) Local $List1 = GUICtrlCreateList("", 5, 30, 590, 300, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) Local $hButton_choosed = GUICtrlCreateButton("OK", 5, 325, 590, 20) For $i = 1 To $aIE[0] GUICtrlSetData($List1, $i & ") " & _IEPropertyGet($aIE[$i], "locationurl")) Next GUISetState(@SW_SHOW) While 1 ; wait for a selection Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hChoose_IE) Return False Case $hButton_choosed $aSelected = _GUICtrlListBox_GetSelItems($List1) If $aSelected[0] Then GUIDelete($hChoose_IE) Return $aIE[$aSelected[1] + 1] Else MsgBox(0, "Info", "Please select an item") EndIf EndSwitch WEnd Else MsgBox(0, 'error', "Sorry" & @CRLF & @CRLF & "no running IE instances found") EndIf EndFunc ;==>_Get_IE ; this function creates a javascript script into the html document ; of the passed $oIE object using the createElement method. Func _JS_Inject($oIE, $sJScript, $bIsUrl = False) ; ; get a reference to the document object Local $objDocument = $oIE.document ; Local $oScript = $objDocument.createElement('script') ; $oScript.type = 'text/javascript' If $bIsUrl Then $oScript.src = $sJScript ; works if $sJScript is a link to a js listing (url) Else ; (https://stackoverflow.com/questions/35213147/difference-between-text-content-vs-inner-text) ; $oScript.innerText = $sJScript $oScript.TextContent = $sJScript ; works if $sJScript contains the listing itself EndIf ; $objDocument.getElementsByTagName('head').item(0).appendChild($oScript) ; $objDocument.getElementsByTagName('head').item(0).removeChild($oScript); ; EndFunc ;==>_JS_Inject ; ------------------------------------------------------------------- ; following function(s) are called by registered $oIE elements events ; ------------------------------------------------------------------- ; ; The function automatically fired by an event ; will receive as parameter an Event Obj. ; This obj has properties related to ; the object that fired the event. ; See following link: ; https://msdn.microsoft.com/en-us/library/aa703876(v=vs.85).aspx ; function called by the mousemove event ; we use this to update 2 global variables: Volatile Func _HTMLElementEvents2_onMousemove($oEvent) $g_iMouseX = $oEvent.clientX $g_iMouseY = $oEvent.clientY EndFunc ;==>_HTMLElementEvents2_onMousemove ; function called by the contextmenu event ; we use this to update 1 global variable ; and we also neutralize this event: Volatile Func _HTMLElementEvents2_onContextmenu($oEvent) $oEvent.cancelBubble = True ; event propagation cancelled $oEvent.returnValue = False ; prevent default behaviour $bCopySelector = True ; when True, selector will be copied to clipboard in main loop EndFunc ;==>_HTMLElementEvents2_onContextmenu ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768280%28v%3dvs.85%29 Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel) ;ConsoleWrite("Debug: navigate away cancelled." & @CRLF) ; https://stackoverflow.com/questions/6526876/how-to-cancel-or-dispose-current-navigation-at-webbrowser-element $oIE.stop EndFunc ;==>_IEEvent_BeforeNavigate2 Here is a simple example on how a "selector" can be used in AutoIt. suppose we want automate the login to the AutoIt site with our username and password. I've already prepared a very simple "template" where are missing some important parts without which the script can't work. Missing parts are the references to the elements of the AutoIt web page that we have to manage by our script. well, here is where the tool I have just posted here above comes to our help. follow this steps: 1) in IE open the AutoIt site at the forum page (https://www.autoitscript.com/forum/) 2) run the above tool (select the IE instance and/or bring it to front if needed) 3) when the script is "ready", move the mouse over the "Existing user? Sign In" string and right click the mouse button. Doing so the "selector" of that element is copied to the clipboard. Now we can paste it in our AutoLogIt.au3 script as value of the $sSignIn variable. 4) now click on the "Existing user? Sign In" to open the "Sig In" session from where we will copy selectors of each of the 2 input box Username and Password, in the same way as we have already done in step 3, and paste those selectors to the $sInputUserId and $sInputPasswd variables respectively. 5) do the same for the "Sign In" Button and paste it's selector to the $sSignInButn variable 6) of course also fill the $sMyUserId and $sMyPasswd variables with your data. That's It. Run the AutoLogIt script and it should Log you on automatically to the forum. AutoLogIt.au3 #include <ie.au3> $sMyUserId = "" ; <-- your userid here $sMyPasswd = "" ; <-- your password here ; set selectors here $sSignIn = "" ; <-- SigIn element selector here $sInputUserId = "" ; <-- UserId input selector here $sInputPasswd = "" ; <-- Password input selector here $sSignInButn = "" ; <-- Sig In button selector here $oIE = _IECreate("https://www.autoitscript.com/forum/") ; here is how to use the QuerySelector javascript function $hDOM_Element = $oIE.document.QuerySelector($sSignIn) ; get the "sign in" link element ; perform a click action on the above element $hDOM_Element.click() ; or _IEAction($hDOM_Element, "click") as well ; fill the username input $hDOM_Element = $oIE.document.QuerySelector($sInputUserId) $hDOM_Element.value = $sMyUserId ; fill the password input $hDOM_Element = $oIE.document.QuerySelector($sInputPasswd) $hDOM_Element.value = $sMyPasswd ; .... or also using the dot notation directly .... $oIE.document.QuerySelector($sSignInButn).click() Sleep(5000) ; this should logout $sMenu = "body > div:nth-of-type(2) > header > div > ul > li:nth-of-type(6) > a:nth-of-type(2)" $oIE.document.QuerySelector($sMenu).click() $sLogOut = "body > ul > li:nth-of-type(9) > a" $oIE.document.QuerySelector($sLogOut).click()1 point
-
I did this just for fun. #include <WinAPI.au3> #include <WinAPIEx.au3> #include <WinAPIMisc.au3> Beep() _Beep(500,1000,50) _Beep(500,1000,30) _Beep(500,1000,10) _Beep(500,1000,5) _Beep(500,1000,3) _Beep(500,1000,1) ;~ Traslated from http://stackoverflow.com/a/19772815 Func _Beep($iFrequency = 500, $imsDuration = 1000, $iVolume = 100);Volume 1 to 100 Local Const $PI = 3.141592653589 Local Const $TAU = 2 * $PI Local Const $iFormatChunkSize = 16 Local Const $iHeaderSize = 8 Local Const $iFormatType = 1 Local Const $iTracks = 1 Local Const $iSamplesPerSecond = 44100 Local Const $iBitsPerSample = 16 Local Const $iFrameSize = Floor($iTracks * (($iBitsPerSample + 7) / 8)) Local Const $iBytesPerSecond = $iSamplesPerSecond * $iFrameSize Local Const $iWaveSize = 4 Local Const $iSamples = Floor($iSamplesPerSecond * $imsDuration / 1000) Local Const $iDataChunkSize = Int($iSamples * $iFrameSize) Local Const $iFileSize = ($iWaveSize + $iHeaderSize + $iFormatChunkSize + $iHeaderSize + $iDataChunkSize) Local Const $sTagWAVHeader = "char ChunkID[4];int ChunkSize;char Format[4];char Subchunk1ID[4];" & _ "int Subchunk1Size;short AudioFormat;short NumChannels;int SampleRate;" & _ "int ByteRate;short BlockAlign;short BitsPerSample;char Subchunk2ID[4];" & _ "int Subchunk2Size;" Local $sTagWAVHeaderAndData = $sTagWAVHeader & "short AudioWave[" & $iDataChunkSize / 2 & "]" Local $tWAVHeader_Data = DllStructCreate($sTagWAVHeaderAndData) $tWAVHeader_Data.ChunkID = "RIFF" $tWAVHeader_Data.ChunkSize = $iFileSize $tWAVHeader_Data.Format = "WAVE" $tWAVHeader_Data.Subchunk1ID = "fmt " $tWAVHeader_Data.Subchunk1Size = $iFormatChunkSize $tWAVHeader_Data.AudioFormat = $iFormatType $tWAVHeader_Data.NumChannels = $iTracks $tWAVHeader_Data.SampleRate = $iSamplesPerSecond $tWAVHeader_Data.ByteRate = $iBytesPerSecond; $tWAVHeader_Data.BlockAlign = $iFrameSize $tWAVHeader_Data.BitsPerSample = $iBitsPerSample $tWAVHeader_Data.Subchunk2ID = "data" $tWAVHeader_Data.Subchunk2Size = $iDataChunkSize Local $iAmplitude = 16383 / (100 / $iVolume) Local $iShort = 0 $iTheta = $iFrequency * $TAU / $iSamplesPerSecond For $iStep = 0 To $iSamples - 1 $iShort = Int($iAmplitude * Sin($iTheta * ($iStep))) DllStructSetData($tWAVHeader_Data, "AudioWave", $iShort, $iStep + 1) Next _WinAPI_PlaySound(DllStructGetPtr($tWAVHeader_Data), $SND_MEMORY) EndFunc ;==>_Beep Saludos1 point
-
Toggle Button UDF
GoogleGonnaSaveUs reacted to wraithdu for a topic
... I'm gonna go shoot myself now.1 point -
Nice script! But what is wrong with the default toggle button? Global $gui = GUICreate("Test", 155, 155) For $i = 0 To 15 GUICtrlCreateCheckbox($i + 1, 10 + (35 * Mod($i, 4)), 10 + (35 * Floor($i / 4)), 30, 30, 0x1000) ;$BS_PUSHLIKE Next GUISetState() Do Until GUIGetMsg() = -31 point
-
History: Removed sprite_offset_y from individual NPC blits and applied it to surfNPC_Front, surfNPC_Back offset instead. (This fixes the clipping issue at top of world) surfNPC_Back of world (board) and surfNPC_Front. People now fall if location aWorld[0][x][y][tile] = 0. When falling NPC is drawn to surfNPC_Back. NPC drawing was off after moving like 1/2 a screen. surfNPC_Front was sized to aBoard[0]. Problem was drect was altered in the SDL_Blit. Not sure that is expected SDL action, or bug in SDL AutoIt port. Solved by creating a new drect for each case.0 points