Jump to content

firesofmay

Member
  • Posts

    31
  • Joined

  • Last visited

Posts posted by firesofmay

  1. Hey Guys,

     

    So right now I am using Alfred to look through my clipboard history. But sometimes what I want is to name certain items that are short lived.

    I don't want to save them as a snippet.

     

    For example: I quickly want to save a customer support ticket number.

    Now I can't remember the ticket number hence I can't search for it in the clipboard history.

    At the same time it's not really a snippet that i'll need forever. 

     

    Is there any workflow in Alfred where I can dynamically add Key/Value pairs, delete them and search for them?

     

    If none exists, what is the best way to go about building one.

    (I am familiar with python as a language)

     

    Thank you in advance! 🙂

  2.  

    You’ll see on the first post that’s the reason I decided to not include Firefox in the list — it’s not a reliable method. This is supposed to be a list that includes the shortest, easiest to compreend, most effective ways of getting that information, which is why Firefox is absent — like you said, it needs a hack. Camino was removed because it was discontinued.

     

    I do something similar to that script on my PinAdd workflow (if the user picks “depends” as the browser), but I use bash to call the relevant information. The goal of this post is not to use applescript, but much to the contrary, to show how to use it to the absolute minimum just to get the relevant information you need to, from each browser, so you can call it from your language of choice.

     

    I agree with you. It's not really a solution. But I had to figure out how to do that.

    To save others time I shared that script. If someone wants to use it can use it.

     

    Thanks again :)

  3. A simple code to get the url of whatever browser the user is in.

    Note firefox code is hacky at its best.

    tell application "System Events"
    	set myApp to name of first application process whose frontmost is true
    	if myApp is "Google Chrome" then
    		tell application "Google Chrome" to return URL of active tab of front window
    	else if myApp is "Opera" then
    		tell application "Opera" to return URL of front document
    	else if myApp is "Safari" then
    		tell application "Safari" to return URL of front document
    	else if myApp is "Firefox" then
    		tell application "System Events"
    			keystroke "l" using command down
    			keystroke "c" using command down
    		end tell
    		delay 0.5
    		return the clipboard
    	else
    		return
    	end if
    end tell
    
  4. Thanks David.

     

    I figured out how to call simple applescripts from Python:

    from subprocess import Popen, PIPE
     
    def run_this_scpt(scpt, args=[]):
         p = Popen(['osascript', '-'] + args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
         stdout, stderr = p.communicate(scpt)
         return stdout
     
    #Example of how to run it.
    run_this_scpt("""tell application "System Events" to keystroke "m" using {command down}""")
     
    #Example of how to run with args.
    run_this_scpt('''
        on run {x, y}
            return x + y
        end run''', ['2', '2'])
    
  5. Nope. My bad. Above seems to work for Simulator only when Simulator is not focused for some reason.

     

    This works:

    tell application "System Events"
    	tell process "iPhone Simulator"
    		activate
    		tell menu bar 1
    			tell menu bar item "Edit"
    				tell menu "Edit"
    					click menu item "Paste Text"
    				end tell
    			end tell
    		end tell
    	end tell
    end tell
    
  6. This script does a better job. I had issues with the above.

    on menu_click(mList)
    	local appName, topMenu, r
    	
    	-- Validate our input
    	if mList's length < 3 then error "Menu list is not long enough"
    	
    	-- Set these variables for clarity and brevity later on
    	set {appName, topMenu} to (items 1 through 2 of mList)
    	set r to (items 3 through (mList's length) of mList)
    	
    	-- This overly-long line calls the menu_recurse function with
    	-- two arguments: r, and a reference to the top-level menu
    	tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬
    		(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
    end menu_click
    
    on menu_click_recurse(mList, parentObject)
    	local f, r
    	
    	-- `f` = first item, `r` = rest of items
    	set f to item 1 of mList
    	if mList's length > 1 then set r to (items 2 through (mList's length) of mList)
    	
    	-- either actually click the menu item, or recurse again
    	tell application "System Events"
    		if mList's length is 1 then
    			click parentObject's menu item f
    		else
    			my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
    		end if
    	end tell
    end menu_click_recurse
    
    tell application "iPhone Simulator" to activate
    menu_click({"iPhone Simulator", "Edit", "Paste Text"})
    

    The menu selection script is taken from here

  7. I found a hacky way of using applescript for it instead.

    tell application "System Events"
    keystroke "v" using {command down, shift down}
    end tell
    

    This would simulate the "CMD" + "SHIFT" + "v" and paste the current text as plain text.

    If anyone else has better ideas let me know.

     

    Thanks.

  8. Hi,

     

    I wrote this workflow for Resting all your iOS simulators.

    It also injects some default images (you can add more images to it easily).

     

    Also it will restart your iOS simulator, press <cmd> to only reset the simulator.

     

    Download Link

     

    This is my first workflow, would love some feedback/criticism/suggestions.

     

    Cheers!

  9. Hi,

     

    I am trying to write a script in python which would paste a random string.

    It works normally, but when It tries to paste in iOS Simulator, it does not work.

     

    If I try to paste by pressing "CMD + v" it does not work.

    If I try to paste by pressing "CMD + SHIFT + v" it works.

     

    Is there a way to simulate "CMD + SHIFT + v" instead?

     

    Thanks.

×
×
  • Create New...