| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| FreeER Grandmaster Cheater Supreme
 
 ![]() Reputation: 53 
 Joined: 09 Aug 2013
 Posts: 1091
 
 
 | 
			
				|  Posted: Tue Jan 09, 2018 9:11 am    Post subject: |   |  
				| 
 |  
				| No you don't have to write the process id, CE provides it to the function (though it's not actually used in this case) 
 
 simple enough, full code: 	  | Quote: |  	  | they count always 0. Would be great to use this fact and create term like this "When 'first' value 0 - clear clipboard from old value" | 
 
 
  	  | Code: |  	  | onOpenProcess = function(pid) reinitializeSymbolhandler()
 local al = getAddressList()
 al.disableAllWithoutExecute()
 al.getMemoryRecordByDescription('enable on attach').Active = true
 swapValueBackup = nil -- part of restore script
 end
 
 local getmr = getAddressList().getMemoryRecordByDescription
 local first = getmr('first')
 local second = getmr('second')
 
 -- OnGetDisplayValue called when value in CE GUI changes
 -- alternative would be a timer that constantly reads memory...
 first.OnGetDisplayValue = function(mr, newvalue)
 if newvalue == '0' then
 swapValueBackup = nil
 end
 end
 
 -- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
 swapValueBackup = nil -- needs to be reset when process is closed since the value is random
 local swapValuesHotKeyKeys = {VK_F5}
 
 swapValuesHotKey = createHotkey(function()
 if not swapValueBackup then
 swapValueBackup = first.Value
 first.Value = second.Value
 else
 first.Value = swapValueBackup
 end
 end, swapValuesHotKeyKeys)
 | 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| !BEWARE! !BEWARE! Deletes post on answer
 
  Reputation: 0 
 Joined: 26 Jun 2013
 Posts: 57
 Location: !BEWARE!
 
 | 
			
				|  Posted: Tue Jan 09, 2018 10:41 am    Post subject: |   |  
				| 
 |  
				| Auto execute script still dont work, must hit button manual and after game reboot have lua error:
 Notice I dont use "Select a process to open" after start CE but load it auto in Generall settings "automaticlly attach to processes name [game.exe]" and "Even autoattach when another process has already been selected" 	  | Code: |  	  | Error:[string "onOpenProcess = function(pid) ..."]:4: attempt to call a nil value (field 'disableAllWithoutExecute')
 | 
 
 Hotkey dont work in circle mode, can use only two times. "On" and "off". third time to turn "On" its not response
 
 And clear clipboard dont work, still loading old value, maybe its cause by this lua error above.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| FreeER Grandmaster Cheater Supreme
 
 ![]() Reputation: 53 
 Joined: 09 Aug 2013
 Posts: 1091
 
 
 | 
			
				|  Posted: Tue Jan 09, 2018 4:24 pm    Post subject: |   |  
				| 
 |  
				| Hm, not sure why you'd get that error... even if the getAddressList somehow returned nil I'd expect something different. Though it may not be entirely necessary to call al.disableAllWithoutExecute(), I did it more as a "just in case, it can't hurt" kind of thing. 
 Not sure why the script wouldn't enable at the start either unless you normally can't enable it immediately.
 
 And if you're wanting to toggle it on and off even when the value isn't set to 0 (or the process restarted) then you'd need to modify the code since it's based purely on the backup value being set
 
 
  	  | Code: |  	  | swapValuesHotKey = createHotkey(function() if not swapValueBackup then
 swapValueBackup = first.Value
 first.Value = second.Value
 else
 first.Value = swapValueBackup
 swapValueBackup = nil -- reset so it can be toggle again
 end
 end, swapValuesHotKeyKeys)
 | 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| !BEWARE! !BEWARE! Deletes post on answer
 
  Reputation: 0 
 Joined: 26 Jun 2013
 Posts: 57
 Location: !BEWARE!
 
 | 
			
				|  Posted: Tue Jan 09, 2018 5:52 pm    Post subject: |   |  
				| 
 |  
				| So if i good understand. Cant make third swap because Clipboard is bussy? Created graph to make all clear:
 
 
  	  | Quote: |  	  | ______________|__after game__|_after load_|first swap_|II_ swap|III_swap| ______________|___reboot____|game match|_turn_ON_|turn_OFF|turn_ON|
 |__CLIPBOARD__|_____?_______|____?____|____1____|___1___|___1___|<Bussy from I swap]
 |_FIRST_VALUE_|_____0_______|____1____|____2____|___1___|___2___|
 |SECOND_VALUE|_____0_______|____2____|____2____|___2___|___2___|
 | 
 
 I thought clipboard every turn on going be overwritten.
 How in your script reset clipboard? must restart aplication Cheat Engine?
 Maybe make turn on/off on two keys. Off key could be instantly clear clipboard value. And then turn on/off process could be loop
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| !BEWARE! !BEWARE! Deletes post on answer
 
  Reputation: 0 
 Joined: 26 Jun 2013
 Posts: 57
 Location: !BEWARE!
 
 | 
			
				|  Posted: Wed Jan 10, 2018 4:22 pm    Post subject: |   |  
				| 
 |  
				| I did some tests and game dont crashing when i add first value to second. So it can be simple swap both values so that 1 becomes 2 and 2 becomes 1
 Could you convert this script to loop in two sides?
 
  	  | Code: |  	  | -- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx local swapValuesHotKeyKeys = {VK_F12}
 swapValuesHotKey = createHotkey(function()
 local getmr = getAddressList().getMemoryRecordByDescription
 local first = getmr('first') -- gets memory record with name/description 'first'
 local second = getmr('second') -- ^ but 'second'
 first.Value = second.Value
 end, swapValuesHotKeyKeys)
 | 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| FreeER Grandmaster Cheater Supreme
 
 ![]() Reputation: 53 
 Joined: 09 Aug 2013
 Posts: 1091
 
 
 | 
			
				|  Posted: Wed Jan 10, 2018 4:51 pm    Post subject: |     |  
				| 
 |  
				| That's a simple change 	  | Quote: |  	  | So it can be simple swap both values so that 1 becomes 2 and 2 becomes 1 | 
 
 
 
  	  | Code: |  	  | -- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx local swapValuesHotKeyKeys = {VK_F12}
 swapValuesHotKey = createHotkey(function()
 local getmr = getAddressList().getMemoryRecordByDescription
 local first = getmr('first') -- gets memory record with name/description 'first'
 local second = getmr('second') -- ^ but 'second'
 first.Value, second.Value = second.Value, first.Value -- swap values
 end, swapValuesHotKeyKeys)
 | 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |